[antlr-interest] C Parser generated with antlr v3.0b not working

Renjith Varma renjith.varma at gmail.com
Sun Dec 10 12:17:40 PST 2006


Hi,

I am a newbie to antlr. I downloaded antlr3.0b as well as the ANSI C grammar
from the antlr home page. I tried to generate the parser in  C language by
giving
language=C; in options. It gave a lot of errors (a part of which I am
attaching below) but created CParser__.g, CParserLexer.c, CParserLexer.h,
CParserParser.c, CParserParser.h and CParser.tokens.
Now i tried to compile all these .c files into one object file and it is
showing lots of errors. Am i doing something wrong? Please help
Also, my idea is to modify the parser files in C to do tree walking. Is this
already available? If so could you help me in finding it?
The errors during C code generation are:

[root at localhost ansic]# java org.antlr.Tool CParser.g
ANTLR Parser Generator  Version 3.0b5 (November 15, 2006)  1989-2006
error(10):  internal error: group C does not satisfy interface ANTLRCore:
missing templates [lexerRulePropertyRef_text, lexerRulePropertyRef_type,
lexerRulePropertyRef_line, lexerRulePropertyRef_pos,
lexerRulePropertyRef_index, lexerRulePropertyRef_channel]

warning(200): CParser.g:457:38: Decision can match input such as "'else'"
using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
error(10):  internal error: Class java.lang.String has no such attribute:
name in template context [outputFile parser genericParser(...) rule
ruleInitializations ruleInitializations anonymous <invoke scopeTop arg
context>] : java.lang.NoSuchFieldException: name
java.lang.Class.getField(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(
org.antlr.stringtemplate.StringTemplate, java.lang.Object, java.lang.String)
(Unknown Source)
org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(
org.antlr.stringtemplate.StringTemplate, java.lang.Object, java.lang.String)
(Unknown Source)
org.antlr.stringtemplate.language.ActionEvaluator.attribute(
antlr.collections.AST) (Unknown Source)
org.antlr.stringtemplate.language.ActionEvaluator.expr(antlr.collections.AST)
(Unknown Source)
org.antlr.stringtemplate.language.ActionEvaluator.argumentAssignment(
antlr.collections.AST, org.antlr.stringtemplate.StringTemplate,
java.util.Map) (Unknown Source)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061210/a3d279ee/attachment.html 


More information about the antlr-interest mailing list