[antlr-interest] Help with semantic actions commit

Terence Parr parrt at cs.usfca.edu
Fri Mar 19 10:00:57 PDT 2010


hi. antlr shouldn't see past actions to sem preds.  are you sure that  
the define sym action is in every path?  Do you get an error about  
insufficiently uncovered alts?

Ter
On Mar 18, 2010, at 4:54 PM, swalton wrote:

> I derived my grammar from Terry's C grammar.  I have added a lot of
> semantic actions and kept the typedef symbol definition.  I have run  
> into a
> problem and need help.  Consider the following:
>
> typedef int uint32_t;
> typedef uint32_t result_t;
>
> I can have any number of these typedefs, but this case is sufficient  
> to
> illustrate the problem I am encountering.  The grammar looks ahead  
> beyond
> the first semicolon before committing the 'uint32_t' in the scope  
> table.
> Needless to say, the second line always fails.  I watched step-by- 
> step,
> placing System.err.print()'s along the way to find out when the
> '$Symbols::types.add(name);' is called.  The test (boolean
> isTypeName(String name)) always occurs *before* 'uint32_t' is  
> stored.  I
> added a { addName(name) }? test (which always returns true) to see  
> if I
> could force an execution of the semantic action without success.
>
> How do I get the symbol committed?
> How do I keep ANTLR from looking so far ahead?
>
> Any help is appreciated.  This is a major roadblock.
>
> -Sean Walton
> PhD Student, SoC, U of U
>
> 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