[antlr-interest] Syntactic predicates

Monty Zukowski monty at codetransform.com
Fri Jul 30 17:02:27 PDT 2004


By having rules with capital letters I'm assuming these are lexer 
rules, however your text indicates that they are actually parser rules. 
  Would you please clarify which they are?

I would go for clarity and use the syntactic predicates.  Then I would 
profile and determine if any particular rules have performance issues 
and if so I would refactor rules.  I believe you will find that 
improving your lexer will give you a bigger payoff than tweaking the 
parser, but of course you never really know until you gather 
performance data.

Monty

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html

On Jul 30, 2004, at 1:36 PM, Bharath Sundararaman wrote:

>
> Hi Antlrs,
>
> If I had 3 rules of the form:
>
> A: ID blue;
> B: ID black;
> C: ID red;
>
> And another rule
>
> Color: A | B | C;
>
> Is it a bad idea to use syntactic predicates instead of splitting out 
> common
> factors? I avoid syntactic predicates as much as possible to avoid
> backtracking and subsequent slowing down.
>
> I have many rules with around a dozen alternatives which don't have the
> exact same left prefix. I'm having a hard time left factoring these 
> rules
> and even if I did, AST generation is cumbersome because I usually split
> large complex rules into several parts for readability (if I don't 
> break the
> rules into parts, its very hard to debug errors) and I have to return 
> values
> at many places for AST generation, type checking and so on.
>
> I created two different grammars, one with very less syntactic 
> predicates
> and another with more syntactic predicates. Is there a good benchmark 
> to
> compare these grammars based on syntactic predicates? The language I'm
> dealing with is similar to PASCAL. I don't have to deal with classes,
> objects, pointers, overloading etc. Does this give me an edge?
>
> Any comments are welcome.
>
> Thanks,
>
> Bharath.



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list