small medium large xlarge

08 Mar 2011, 18:35
Jerry Evans (1 post)

I hope a 2nd edition of this book is in the pipeline. It’s a great reference and has (generally) made my recent ANTLR work much simpler.

That said, I’ve some (nitpicking, sorry!) suggestions re the section on AST construction. Specifically:

  1. The written material omits any discussion on the correct way to express a rewrite rule for something like this:
   : a=rhs_alt (OR b=rhs)* 

The core issue of cardinality, IMVHO, could be described in more detail.

  1. The text does not explicitly describe how you reference the left-hand side of a rule. By implication $rhs is legal but its status uncertain.

  2. I know ANTLR V2 is long gone but there are still a number of decent grammars out there for V2. A few examples of translation would be good - I know there is the Wiki but the book is supposed to be the definitive reference right? Here’s an example of a V2 idion that crops up in the bison grammar

	{ ## = #( [ALT, "alt"], #rhs ); }
	( OR^ rhs_alt )*

I hope this is constructive.

best regards


05 Dec 2011, 20:06
Terence Parr (53 posts)

hi Jerry, thanks very much for the suggestions. as for question 1, I see on my printed page 174 in section “referencing previous rule AST’s and rewrite rules” something similar to what you’re asking for. Ter

You must be logged in to comment