Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For complex parsers, you may want to avoid creating the lexers and parsers each time you want to parse input. In this case you can do the following, which will reset the lexer and parser by setting the input propertycharStream or tokenStream property (as appropriate):

Code Block
package {

	import org.antlr.runtime.*;

	public class AntlrActionScriptTest {

		private static var lexer:TLexer = new TLexer(null);
		private static var parser:TParser = new TParser(null);

		public function AntlrActionScriptTest(input:String) {
			lexer.charStream = new ANTLRStringStream(input);
			parser.tokenStream = new CommonTokenStream(lexer);
			parser.entry_rule();
 		}
	}
}

...