[antlr-interest] Re: Any syntax predicate can be removed.

Ruslan Zasukhin sunshine at public.kherson.ua
Thu Aug 29 15:03:47 PDT 2002


on 8/29/02 23:22, Loring Craymer at Loring.Craymer at jpl.nasa.gov wrote:

> Ruslan--
> 
> There are cases where syntactic predicates are necessary (identifying
> recursive rules, exit conditions on subrules) in fact, and in practice only
> simple grammars have no syntactic predicates.  LL(k) is not as strong as
> LALR, but LL(infinity) [syntactic predicates give infinite lookahead] is
> enough to deal with any finite code written in a context free grammar.

Yes I have read about this in Terr's docs.

> So sometimes you have to use them.  As long as they are not in frequently
> exercised rules, the cost is minimal; ANTLR could be rewritten to eliminate
> most of the overhead, and it might make sense to look into that for ANTLR 3.

Well, I have not look deeply how this is implemented...
I have see 
    -- store of position
    -- and try - catch blocks.

It is interesting for me, if Lexer have read e.g. 10 tokens during syntax
predicate resolving, then on return to stored position Lexer and Parser will
start the same work again.

IF yes, then this is not best way.

Terrence perfectly describe concept

    Lexer -> Stream of Tokens -> Parser.

Then it needs simply implement Token Stream as buffered queue.
In this case this 10-100 tokes which we get during syntax predicate will be
stored as NUMBERS in buffer.

On re-iteration, Parser simply will read that numbers.
I think this is the best solution from point of view of minimal overhead.


-- 
Best regards,
Ruslan Zasukhin              [ I feel the need...the need for speed ]
---------------------------------------------------------------------
ParadigmaSoft                            http://www.paradigmasoft.com

Valentina is cross-platform, fantastic fast database engine, supports
C/C++, Java, SQL, REALbasic, Director, XCMD, COM, Visual BASIC, ...
---------------------------------------------------------------------



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list