[antlr-interest] Problem with splitting grammars

Jim Idle jimi at temporal-wave.com
Mon Jul 4 09:04:01 PDT 2011


You have it the wrong way around - if your grammar has not changed, then
your build process should not generate it. However, I think that I may
have decided to take out the date sometime after 3.1.3.

If you need to generate smaller C files, then split the grammar up and use
the import x.g, y.g, a.g; functionality.

You might also try 3.4-beta4.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mu Qiao
> Sent: Monday, July 04, 2011 2:18 AM
> To: antlr-interest Interest
> Subject: [antlr-interest] Problem with splitting grammars
>
> I have one big grammar that needs to be split to reduce compile time(C
> source). For ANTLR 3.1.3 there are two problems:
> 1. The generated source code may change every time I run ANTLR even if
> I don't change the grammar http://paste.pocoo.org/show/428505/ shows
> the difference.
>
> 2. The comment probably shouldn't tell about the date I use sed to
> remove the comment but I don't think it's a good idea.
> ANTLR shouldn't generate different source code if I don't change the
> grammar. The date information should belong to the property of the
> generated files, not the content of these files.
>
> Then I tried ANTLR 3.3 and I got the following error when generating
> the source code:
> error(10):  internal error: bashast/libbashWalker.g :
> java.lang.NullPointerException
> org.antlr.codegen.Target.getTokenTypeAsTargetLabel(Target.java:145)
> org.antlr.codegen.CodeGenerator.getTokenTypeAsTargetLabel(CodeGenerator
> .java:858)
> org.antlr.codegen.ACyclicDFACodeGenerator.walkFixedDFAGeneratingStateMa
> chine(ACyclicDFACodeGenerator.java:119)
> org.antlr.codegen.ACyclicDFACodeGenerator.genFixedLookaheadDecision(ACy
> clicDFACodeGenerator.java:47)
> org.antlr.codegen.CodeGenerator.genLookaheadDecision(CodeGenerator.java
> :646)
> org.antlr.grammar.v2.CodeGenTreeWalker.block(CodeGenTreeWalker.java:101
> 8)
> org.antlr.grammar.v2.CodeGenTreeWalker.ebnf(CodeGenTreeWalker.java:1871
> )
> org.antlr.grammar.v2.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1
> 704)
> org.antlr.grammar.v2.CodeGenTreeWalker.tree(CodeGenTreeWalker.java:2277
> )
> org.antlr.grammar.v2.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1
> 633)
> org.antlr.grammar.v2.CodeGenTreeWalker.alternative(CodeGenTreeWalker.ja
> va:1306)
> org.antlr.grammar.v2.CodeGenTreeWalker.block(CodeGenTreeWalker.java:108
> 1)
> org.antlr.grammar.v2.CodeGenTreeWalker.rule(CodeGenTreeWalker.java:797)
> org.antlr.grammar.v2.CodeGenTreeWalker.rules(CodeGenTreeWalker.java:588
> )
> org.antlr.grammar.v2.CodeGenTreeWalker.grammarSpec(CodeGenTreeWalker.ja
> va:530)
> org.antlr.grammar.v2.CodeGenTreeWalker.grammar(CodeGenTreeWalker.java:3
> 36)
> org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:430)
> org.antlr.Tool.generateRecognizer(Tool.java:642)
> org.antlr.Tool.process(Tool.java:455)
> org.antlr.Tool.main(Tool.java:89)
>
> Here are my grammars:
> https://github.com/qiaomuf/libbash/blob/42193d91c43d12bcc3113336e5e73e7
> 4ca679c82/bashast/libbashWalker.g
> https://github.com/qiaomuf/libbash/blob/42193d91c43d12bcc3113336e5e73e7
> 4ca679c82/bashast/libbashPattern.g
>
> --
> Best wishes,
> Mu Qiao
> GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9
>
> 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