From: Jim Freeze Date: 2003-12-12T02:26:22+09:00 Subject: Re: problems with racc: $end token On Friday, 12 December 2003 at 2:16:53 +0900, Luke A. Kanies wrote: > On Fri, 12 Dec 2003, Jim Freeze wrote: > > > What if you do: return ["", ""] ? > > I still get a syntax error, but this time the apparently-magical token > '$end' is not used. > > I know I'm supposed to return false as the token, and that somehow racc > converts that into the $end token. I just don't know how it does that, > nor do I know why racc doesn't then gracefully cease trying to parse, > rather than continuing on and hitting a syntax error. Well, in the sample code I see: @q.push [false, '$'] # optional from 1.3.7 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. -- Jim Freeze ----------