[antlr-interest] How to see the bare grammar?

Steve Lianoglou lists.steve at arachnedesign.net
Thu Oct 19 18:04:35 PDT 2006


> I'm examining a large grammar (boo, if you must know) where the .g  
> file is 3400 lines. Is there a way to strip out the semantic action  
> code, leaving bare EBNF (preferably nicely formatted)?

If use the antlr plugin (http://antlreclipse.sourceforge.net/) with  
Eclipse, there is an "Overview" tab that you can select while looking  
at your grammar file.

It appears as if it removes some of the extra antlr stuff.

For instance, this in the normal grammar:

if_statement
	:	"if"^ LPAREN! test RPAREN! (statement | block)
		(	// combat the dangling else -- inspired by the java1.5 grammar
			options { warnWhenFollowAmbig = false; }:
			"else"! (statement | block)
		)?
	;

Is turned into this in the "Overview":
if_statement :
	"if" LPAREN test RPAREN
	( statement | block )
	( "else" ( statement | block ) )?
	;

I'm guessing it may do something similar for the rest of the things  
you'd like to temporarily "get out of the way"

-steve




More information about the antlr-interest mailing list