[antlr-interest] Java Target - How to Generate the Parser and Lexer at Runtime?
Sameh W. Zaky
sameh.wz at gmail.com
Sat May 22 11:56:18 PDT 2010
OK, I will clarify my question (sorry that I was not clear in my previous
mail).
The 2 files are different mainly in the constructors
*When I use the method you told me about in the first message, the output
Parser.java has the constructors:*
*public **RulesGrammarParser(TokenStream input) {*
* this(input, new RecognizerSharedState());*
* }*
*public RulesGrammarParser(TokenStream input, RecognizerSharedState state) {
*
* super(input, state);*
* *
* }*
*But when I use click 'Run..' in ANTLRWorks I get the output Parser.java has
the constructors:*
*public RulesGrammarParser(TokenStream input) {*
* this(input, DebugEventSocketProxy.DEFAULT_DEBUGGER_PORT, new
RecognizerSharedState());*
* }*
*public RulesGrammarParser(TokenStream input, int port,
RecognizerSharedState state) {*
* super(input, state);*
* DebugEventSocketProxy proxy =*
* new DebugEventSocketProxy(this, port, null);*
* setDebugListener(proxy);*
* try {*
* proxy.handshake();*
* }*
* catch (IOException ioe) {*
* reportError(ioe);*
* }*
* }*
*public RulesGrammarParser(TokenStream input, DebugEventListener dbg) {*
* super(input, dbg, new RecognizerSharedState());*
*}*
*In addition to this method:*
*protected boolean evalPredicate(boolean result, String predicate) {*
* dbg.semanticPredicate(result, predicate);*
* return result;*
* }*
*and these declarations:*
*public static final String[] ruleNames = new String[] {*
* "invalidRule", "in", "evaluation", "gt", "consequence", "lte", *
* "times", "lte_math", "divided_by", "enumeration_value",
"gte_math", *
* "range", "check", "variable", "last_connection", "numeric_value", *
* "term", "gte", "modulus", "plus", "source_name", "connection",
"lt", *
* "source", "function", "equal", "name_of_quality", "condition",
"primary", *
* "minus", "value_of_quality", "arithmeticExpression"*
* };*
* *
* public int ruleLevel = 0;*
* public int getRuleLevel() { return ruleLevel; }*
* public void incRuleLevel() { ruleLevel++; }*
* public void decRuleLevel() { ruleLevel--; }*
And by input text, I mean the input.. The text that I write in ANTLRWorks
when I click 'Run..'
Thanks for your time :-)
On Sat, May 22, 2010 at 8:41 PM, Bart Kiers <bkiers at gmail.com> wrote:
> But now I need to change my question because I found out that Parser.java
>> generated from this action is different than Parser.java generated when I
>> click 'Run..' in ANTLRWorks and give it an input text..
>>
>
> Please explain what "different" means. And what do you mean by "input
> text"?
>
> Kind regards,
>
> Bart.
>
--
Sameh W. Zaky
More information about the antlr-interest
mailing list