On Fri, 12 Dec 2003, Jim Freeze wrote:

> Well, in the sample code I see:
>
>     @q.push [false, '$']   # optional from 1.3.7

Yep, I've tried that, along with about nine other variations of having an
end token.

> I have successfully left that out of my parsers.
> Essentially, the samples just tokenize the file
> (and store the tokens in @q) then call do_parse.
>
> do_parse apparently gets tokens from the stack by
> calling next_token, which returns to tokens one
> at a time by calling @q.shift. This would suggest
> that when you are done all you need to do is return
> the same value as [].shift #=> nil.

Yeah, all the code does it that way, but there shouldn't be a functional
difference between collecting the tokens in parse() and returning them in
next_token(), and just collecting and returning them in next_token().
Either way, I've switched to a method like the examples, and I've
corrected my regex problems, and I still get an error.

At this point I think it's a problem with my grammar, that I'm somehow not
correctly specifying the end of the parsing.  Obviously, though, I don't
know how to say "hey, the file is over, stop looking" or whatever the
magic words are.  I _know_ that the false token is supposed to do that,
but for some reason racc thinks it shouldn't be expecting that token yet.

In case anyone feels like pointing out my idiocy, here's my grammar as it
stands now:

token DEFINE NAME STRING PARAM LCURLY RCURLY VALUE RETURN COMMENT
INLINECOMMENT EOF

rule
file: objects EOF
    ;

objects: object { [val[0]] }
    | objects object { [val[0], val[1]].flatten }
    ;

object: DEFINE NAME LCURLY RETURN vars RCURLY returns {
Cricket::Object.create(val[1],val[3]) }
    ;

vars: var { [val[0]] }
    | vars var { [val[0], val[1]].flatten }
    ;

var: PARAM VALUE returns { [val[0],val[1]] }
    ;

returns: return
    | returns return
    ;

return: comment RETURN
    ;

comment: # nothing
    | COMMENT
    | INLINECOMMENT
    ;

end

It's for parsing text like this:

# a comment
define contact {
contact_name                   vwf1607 ; inline comment
alias                          Lawrence Hubenak
host_notification_period       none
host_notification_commands     host-notify-by-email
service_notification_period    none
service_notification_commands  notify-by-email
email                          lawrence.hubenak / hcahealthcare.com
pager                          lawrence.hubenak / my2way.com
}

I.e., nagios configs.

Well, I guess I'll figure it out eventually, I was just hoping not get
much past the 8 or so hours I've already wasted on it.

Thanks,
Luke

-- 
I have an answering machine in my car.  It says, "I'm home now. But
leave a message and I'll call when I'm out."  -- Stephen Wright