[antlr-interest] ANTLR code too large
Jan Nielsen
jan.sture.nielsen at gmail.com
Tue Jan 29 17:56:43 PST 2008
My ANTLR grammar sippit below generates code that is "too large" from
a compiler/class-file perspective; if I use the lexer rule DAY_OF_WEEK
everything is fine but it doesn't parse correctly because of the lack
of return values. I can use "noinlinedfa" [1] to address the lexer
rule size* problem, but I'm wondering if there's a better way. In my
grammar [2], I define a dayOfWeek parser rule (I suppose could pass
the result back through the parser in a lexer rule action?). Is there
a better way to do this sort of thing?
Thanks,
-Jan
(*) Does anyone know how to tell the Maven 2 antlr-maven-plugin [3] to
use -Xnoinlinedfa during the code-generation phase?
[1] http://www.antlr.org/pipermail/antlr-interest/2007-December/025360.html
[2] http://www.antlr.org/pipermail/antlr-interest/2008-January/026019.html
[3] http://mojo.codehaus.org/antlr-maven-plugin/
dayOfWeek returns [adc.util.Day value]
/*
: DAY_OF_WEEK { $value = adc.util.Day.MONDAY; }
;
*/
: 'Monday' { $value = adc.util.Day.MONDAY; }
| 'Tuesday' { $value = adc.util.Day.TUESDAY; }
| 'Wednesday' { $value = adc.util.Day.WEDNESDAY; }
| 'Thursday' { $value = adc.util.Day.THURSDAY; }
| 'Friday' { $value = adc.util.Day.FRIDAY; }
| 'Saturday' { $value = adc.util.Day.SATURDAY; }
| 'Sunday' { $value = adc.util.Day.SUNDAY; }
;
DAY_OF_WEEK returns [adc.util.Day value]
: 'Monday' { $value = adc.util.Day.MONDAY; }
| 'Tuesday' { $value = adc.util.Day.TUESDAY; }
| 'Wednesday' { $value = adc.util.Day.WEDNESDAY; }
| 'Thursday' { $value = adc.util.Day.THURSDAY; }
| 'Friday' { $value = adc.util.Day.FRIDAY; }
| 'Saturday' { $value = adc.util.Day.SATURDAY; }
| 'Sunday' { $value = adc.util.Day.SUNDAY; }
;
More information about the antlr-interest
mailing list