Strip - strip a grammar to just the grammar components
Strip
As of ANTLR v3.1.2.
(copied from the release notes)
To strip a grammar down to just the grammar components do this:
$ java org.antlr.tool.Strip T.g
If T.g is:
grammar T; options {k=1; output=AST;} @header {kill} @lexer::header {...} @members { akdsfljklas } z scope A; : q=a[34] ids+=ID ; a[int i] returns [float f] options {k=1;} @init {rmoeve} : {sfkljlsf} B^ {on end} | '3' -> '3' {end} {aaa} ; b scope { String name; } : B -> {$arg!=null&&op!=null}? ^($op RULE_REF $arg) -> ^(RULE_REF $arg) ; c : {true}? B | {false}?=> C ; fragment A : '0' {skip();} ; // leave lexer actions B : ~A 'z' ;
you'll get the following output
grammar T; options {k=1; output=AST;} z : a ID ; a options {k=1;} : B | '3' ; b : B ; c : /*{true}?*/ B | /*{false}?=>*/ C ; fragment A : '0' {skip();} ; // leave lexer actions B : ~A 'z' ;