From: Charles Mills Date: 2005-03-17T00:34:48+09:00 Subject: Re: Examples for racc? Ben Giddings wrote: > Hey all, > > I was trying to use racc the other day, and couldn't get even the most > basic sample started. Does anybody know of any fully working sample > grammar files for it? See below. > > The calculator that is mentioned in the docs would be fine, if it had > the next_token, on_error and parse implemented. My main problem is that > I'm not sure what legal values next_token can return. > Depends on your grammer, but a token should be a two element array, whose first element describes the type of the token (usually a symbol - like :IDENTIFIER) and the second element is the value of the token (usually a string - like 'x'). Any token whose type (first element) is false signals end of input. You should write next_token() so it always returns [false, false] (second element could be anything) when end of input is reached. (If next_token() returns nil you will cause RACC to raise an error.) > It would be great if there was some fully-working sample code along with > the docs, instead of just the example snippets. I even tried > understanding some of the japanese results that google found, but to no > avail. > There is a link on my website (http://cmills.freeshell.org/) to a presentation I gave at the PDX user group on RACC. It includes a power point presentation on RACC and a bunch of small working example programs - the grammer for some is only a few lines long. -Charlie