[antlr-interest] generating code from grammar (CSS) and large code.

Johannes Luber jaluber at gmx.de
Tue May 13 16:05:36 PDT 2008


Loring Craymer schrieb:
> I've switched groups from antlr-dev to antlr-interest; this discussion 
> does not belong in antlr-dev.
> 
> ANTLR 3 tends to generate large files, and you have enough special 
> tokens that an 80K line lexer is not unusual.  This is a transient 
> situation:  one of the later releases will probably focus on minimizing 
> the size of generated code.
> 
> Your error message points to "TERM"; this should be converted to a 
> parser rule as a first step (that should also reduce code gen size), and 
> you will probably need to inline your fragment rules (lexers do not yet 
> use FOLLOW sets--for the moment, avoid using fragment rules).
> 
> --Loring

I'll add that I've managed to fix the other three ambiguities. One was a 
true bug in grammar translation from the W3C page. I'll wait for further 
infos how following Loring's advice worked out.

Johannes
> 
> ----- Original Message ----
> From: Kamal Verma <kverma at yahoo.com>
> To: antlr-dev at antlr.org
> Sent: Tuesday, May 13, 2008 2:38:56 PM
> Subject: [antlr-dev] generating code from grammar (CSS) and large code.
> 
> Problem generating code from grammar.
> 
> CSS.g:203:2: The following alternatives are unreachable: 5,6,7,11,12
> 
> I am having trouble generating the code. Any help is very much 
> appreciated. Also if anybody have a CSS parser created please share :-).
> 
> Somehow it generated the code but size of code is too large. ~80k lines.
> 
> --------------
> $ wc -l *
>     296 CSS.g
>      97 CSS.tokens
>   79701 CSSLexer.cs
>    1925 CSSParser.cs
>     236 CSS__.g
>   82255 total
> --------------
> 
> Attached it the v3 grammar file.
> Original grammar: http://www.antlr.org/share/1126882028006/css2.1.g
> Grammar specs: http://www.w3.org/TR/CSS21/grammar.html
> 
> Any help is greatly appreciated.
> -Kamal
> 
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CSS.g
Type: text/x-gap
Size: 4088 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080514/ff24ec72/attachment.bin 


More information about the antlr-interest mailing list