[antlr-interest] Re: recursive semantic scanning (recursive lookahead?)
thereisnofreeid
chantal.ackermann at web.de
Wed Apr 2 04:09:25 PST 2003
hi again,
I have come up with a new idea but I am still stuck with infinite
recursion messages. I moved the term decision logic to the parser. the
lexer just splits the input into WORD tokens. in the parser I have the
following rules:
protected startTerm
: ( { searchedTerms.firstTermStartsWith(LT(1).getText() + ' ' +
LT(2).getText()) }?
( startTerm WORD ) ) => startTerm
| ( { searchedTerms.secondTermStartsWith(LT(1).getText() + ' ' +
LT(2).getText()) }?
( startTerm WORD ) ) => startTerm
| ( { searchedTerms.firstTermStartsWith(LT(1).getText()) }?
( WORD ) ) => startTerm
| ( { searchedTerms.secondTermStartsWith(LT(1).getText()) }?
( WORD ) ) => startTerm
;
protected term1
: ( { searchedTerms.equalsFirstTerm(LT(1).getText() + ' ' +
LT(2).getText()) }?
( startTerm WORD ) ) => term1
| ( { searchedTerms.equalsFirstTerm(LT(1).getText()) }?
( WORD ) ) => term1
;
protected term2
: ( { searchedTerms.equalsSecondTerm(LT(1).getText() + ' ' +
LT(2).getText()) }?
( startTerm WORD ) ) => term2
| ( { searchedTerms.equalsSecondTerm(LT(1).getText()) }?
( WORD ) ) => term2
;
protected term
: ( WORD ) => term
;
I get inifinite recursions for term1, term2 and term. Well, I want to
implement an recursion, but how can I tell the parser to stop the
iteration whenever the equals methods return false? that still does
not solve the problem that startTerm is just a helper token and if
startTerm is not recognized as part of term1 or term2 the WORD tokens
it consists of shall be marked as term tokens. as I write this, I
think, it is not possible to do this in any way. or could a TreeParser
provide some more means to do this?
thanks for any input
Chantal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list