[antlr-interest] Syntactic predicates

Bharath Sundararaman bharath at starthis.com
Fri Jul 30 13:36:16 PDT 2004


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.
 
-----Original Message-----
From: Monty Zukowski [mailto:monty at codetransform.com] 
Sent: Friday, July 30, 2004 1:01 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] Synchronizing error messages from filter


No, there is not a standard way to queue up that message.

You might make a custom token object that had a field for an error 
message.  Then override consume() in the parser to print your error 
before actually consuming the token passed it.

I'd need more details on how you want to handle that message to give 
you more specifics.

Monty

On Jul 30, 2004, at 10:36 AM, dotlessbraille wrote:

> I am using a custom filter rule when the lexer finds an unexpected 
> item.  This rule simply skips ahead to the next statement and outputs 
> a warning message to the user.
>
> There is a problem if a parser rule has caused the lexer to look ahead 
> several tokens.  In this case, the warning message will appear out of 
> order to the user because it will show up as soon as the lexer 
> encounters it, before the parser has generated its output from correct 
> tokens immediately preceding the unexpected item.
>
> Is there any standard way to queue up this message?
>
> Thanks,
> SusanJ
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>



 
Yahoo! Groups Links



 




 
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