[antlr-interest] Java Target - How to Generate the Parser and Lexer at Runtime?

Jim Idle jimi at temporal-wave.com
Sat May 22 12:17:43 PDT 2010


You need to read the wiki articles and follow the examples.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Sameh W. Zaky
> Sent: Saturday, May 22, 2010 11:56 AM
> To: Bart Kiers
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Java Target - How to Generate the Parser
> and Lexer at Runtime?
> 
> 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
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list