Patches to ANTLR 3.0Edit

This page contains patches to ANTLR 3 that address some issues in version 3.0 for which there seem to be no other viable workarounds, or for which the difficulty of applying the patch is less than the inconvenience of applying a workaround.

Pending patches

Bug in C runtime column handling

This patch should be applied to antlr3inputstream.c:

166c166
<     input->charPositionInLine = -1;
---
>     input->charPositionInLine = 0;

Filter mode

301c301,302
<                                                         grammar.getOption("filter").equals("true");
---
>                                                         grammar.getOption("filter").equals("true") &&
>                                                         ( grammar.type==Grammar.LEXER );

Accepted patches

Missing parentheses around predicates

This patch should be applied to the C.stg output template:

2274c2283
< andPredicates(left,right) ::= "( <left> && <right> )"
---
> andPredicates(left,right) ::= "( (<left>) && (<right>) )"

Not sure when this one was applied but it made it into ANTLR 3.0.1.

GCC lexer warnings C target

714c714
< <rules:{r | static <headerReturnType(ruleDescriptor=r.ruleDescriptor)>        <if(!r.ruleDescriptor.isSynPred)>m<endif><r.ruleDescriptor.name>    (p<name> ctx<if(r.ruleDescriptor.parameterScope)>, <endif><r.ruleDescriptor.parameterScope:parameterScope(scope=it)>);}; separator="\n";>
---
> <rules:{r | static <if(!r.ruleDescriptor.isSynPred)>ANTLR3_INLINE<endif> <headerReturnType(ruleDescriptor=r.ruleDescriptor)>  <if(!r.ruleDescriptor.isSynPred)>m<endif><r.ruleDescriptor.name>    (p<name> ctx<if(r.ruleDescriptor.parameterScope)>, <endif><r.ruleDescriptor.parameterScope:parameterScope(scope=it)>);}; separator="\n";>

Rejected patches

  • None so far.

See also