[antlr-interest] C target, C grammar + AST = missing *_SymbolsPop()
Gary R. Van Sickle
g.r.vansickle at att.net
Tue Jan 20 20:18:50 PST 2009
> From: Jim Idle
> Sent: Tuesday, January 20, 2009 11:26 AM
> Cc: 'antlr-interest Interest'
> Subject: Re: [antlr-interest] C target,C grammar + AST =
> missing *_SymbolsPop()
>
> Gary R. Van Sickle wrote:
> > Hi guys,
> >
> > I'm trying to make the C grammar in examples-v3 generate an
> AST, but
> > for some reason it appears to not be generating
> ScopePop()'s for the
> > dynamic scopes; for every dynamic scope, I get an error
> like the following:
> >
> > "ss9_combined_lexer_parserParser.cpp: In function
> > `ss9_combined_lexer_parserParser_translation_unit_return
> > translation_unit(ss9_combined_lexer_parserParser_Ctx_struct*)':
> > ss9_combined_lexer_parserParser.cpp:12842: error:
> > `ptranslation_unit_SymbolsPop' undeclared (first use this function)"
> >
> > Sure enough, no such function exists. Things work fine if I don't
> > declare "output=AST"; in that case, the only SymbolsPop() function
> > generated or called appears to be
> > pss9_combined_lexer_parserParser_SymbolsPop(), i.e. all
> dynamic scope
> > code calls the same ScopePop(). Does this ring any bells
> for anybody?
> >
> Doesn't for me. Can you submit your grammar or is this
> completely unchanged from the example?
>
The above was from marginally changed grammar, but I can replicate it by
simply adding
" output = AST;
ASTLabelType = pANTLR3_BASE_TREE;"
to the options of the bog-standard example. Untar the attached into a
folder somewhere and do a:
$ antlr C.g ## or however you invoke ANTLR, this is my shell script that
does "java org.antlr.Tool C.g"
$ gcc -I. CParser.c CLexer.c main.c -lantlr3c
I get this:
"/cygdrive/c/DOCUME~1/GaryV/LOCALS~1/Temp/ccwDPkR8.o:CParser.c:(.text+0xbc2c
): undefined reference to `_ptranslation_unit_SymbolsPop'
/cygdrive/c/DOCUME~1/GaryV/LOCALS~1/Temp/ccwDPkR8.o:CParser.c:(.text+0xc6a2)
: undefined reference to `_pfunction_definition_SymbolsPop'
/cygdrive/c/DOCUME~1/GaryV/LOCALS~1/Temp/ccwDPkR8.o:CParser.c:(.text+0xd189)
: undefined reference to `_pdeclaration_declarationPop'
/cygdrive/c/DOCUME~1/GaryV/LOCALS~1/Temp/ccwDPkR8.o:CParser.c:(.text+0x107df
): undefined reference to `_pstruct_or_union_specifier_SymbolsPop'
/cygdrive/c/DOCUME~1/GaryV/LOCALS~1/Temp/ccwDPkR8.o:CParser.c:(.text+0x27dc1
): undefined reference to `_pcompound_statement_SymbolsPop'
collect2: ld returned 1 exit status"
Comment out the AST lines and it builds fine.
???
> Jim
>
--
Gary R. Van Sickle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-antlr.tar.gz
Type: application/x-gzip
Size: 8395 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090120/b8261e2e/attachment.gz
More information about the antlr-interest
mailing list