So I looked in to this a bit more. The parser is fine as the C output is 1.5M, but the lexer is terrible and is where all the problems are. I'll try fixing this up...
Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Todor Dimitrov > Sent: Saturday, August 20, 2011 7:39 AM > To: [email protected] > Subject: [antlr-interest] Sparql Grammar & Huge C Files > > Dear *, > > generating the C lexer and parser for the Sparql grammar using the > options below produces huge files: > > options { > language = C; > output = AST; > ASTLabelType = pANTLR3_BASE_TREE; > } > > 2.4K Sparql.tokens > 85M SparqlLexer.c <--- > 30K SparqlLexer.h > 1.5M SparqlParser.c <--- > 69K SparqlParser.h > > In addition, the files cannot be compiled as it seems that the > generators have not been updated to reflect the API changes in the > latest C runtime (or maybe it is the other way round :)). In > particular, I see errors like these: > > SparqlLexer.c:1214276:48: error: member reference type 'pANTLR3_STRING' > (aka 'struct ANTLR3_STRING_struct *') is a > pointer; maybe you meant to use '->'? > setText(LEXER->getText(LEXER).substring(1, LEXER- > >getText(LEXER).length()-1)); > ~~~~~~~~~~~~~~~~~~~~~^ > -> > SparqlLexer.c:1214276:49: error: no member named 'substring' in 'struct > ANTLR3_STRING_struct'; did you mean 'subString'? > setText(LEXER->getText(LEXER).substring(1, LEXER- > >getText(LEXER).length()-1)); > ^~~~~~~~~ > subString > ./antlr3string.h:179:8: note: 'subString' declared here > (*subString) (struct > ANTLR3_STRING_struct * string, ANTLR3_UINT32 ... > ^ > SparqlLexer.c:1214276:83: error: member reference type 'pANTLR3_STRING' > (aka 'struct ANTLR3_STRING_struct *') is a > pointer; maybe you meant to use '->'? > setText(LEXER->getText(LEXER).substring(1, LEXER- > >getText(LEXER).length()-1)); > > ~~~~~~~~~~~~~~~~~~~~~^ > > -> > SparqlLexer.c:1214276:84: error: no member named 'length' in 'struct > ANTLR3_STRING_struct' > setText(LEXER->getText(LEXER).substring(1, LEXER- > >getText(LEXER).length()-1)); > > > I'm using antlr 3.4, but I have also tested this with antlr 3.3. > Generating the Java lexer and parser works as expected and the files > are much smaller: > > 2.4K Sparql.tokens > 582K SparqlLexer.java > 876K SparqlParser.java > > Any suggestions and help are highly appreciated. > > Thanks in advance, > > Todor > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your- > email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
