[antlr-interest] error : 'CharScanner.hpp:114: undefined reference' ... ???
Oliver Haines
xlrg2002 at yahoo.de
Tue Apr 27 08:03:07 PDT 2004
Hi,
I try to test antlr for c++. If I compile my simple app I get this errors:
cd "/home/graemer/Projekte/antlr/debug" && WANT_AUTOCONF_2_5="1"
WANT_AUTOMAKE_1_6="1" make -k -j1
*make all-recursive
*Making all in src
*g++ -DHAVE_CONFIG_H -I. -I/home/graemer/Projekte/antlr/src -I..
-I/usr/local/include -O0 -g3 -c
/home/graemer/Projekte/antlr/src/antlr.cpp
*/bin/sh ../libtool --mode=link g++ -O0 -g3 -L/usr/local/lib -lantlr
-o antlr antlr.o
*g++ -O0 -g3 -o antlr antlr.o -L/usr/local/lib -lantlr
*antlr.o(.text+0x24): In function `main':
*/usr/local/include/antlr/CharScanner.hpp:114: undefined reference to
`CalcLexer::CalcLexer[in-charge](std::basic_istream<char,
std::char_traits<char> >&)'
*antlr.o(.text+0x36):/usr/local/include/antlr/CharScanner.hpp:233:
undefined reference to
`CalcParser::CalcParser[in-charge](antlr::TokenStream&)'
*antlr.o(.text+0x41):/usr/local/include/antlr/CharScanner.hpp:309:
undefined reference to `CalcParser::expr()'
*antlr.o(.gnu.linkonce.t._ZN9CalcLexerD1Ev+0xb): In function
`CalcLexer::~CalcLexer [in-charge]()':
*/usr/local/include/antlr/CharScanner.hpp:241: undefined reference to
`vtable for CalcLexer'
*antlr.o(.gnu.linkonce.t._ZNK10CalcParser12getTokenNameEi+0x2c): In
function `CalcParser::getTokenName(int) const':
*/usr/local/include/antlr/CharScanner.hpp:163: undefined reference to
`CalcParser::tokenNames'
*antlr.o(.gnu.linkonce.t._ZNK10CalcParser13getTokenNamesEv+0x4): In
function `CalcParser::getTokenNames() const':
*/usr/local/include/antlr/CharScanner.hpp:240: undefined reference to
`CalcParser::tokenNames'
*collect2: ld returned 1 exit status
*make[2]: *** [antlr] Error 1
*make[2]: Target `all' not remade because of errors.
*make[1]: *** [all-recursive] Error 1
*make: *** [all-recursive-am] Error 2
*make: Target `all' not remade because of errors.
**** Exited with status: 2 ***
I'm using kdevelop 3 and linux.
the simple grammar:
options
{
language="Cpp";
}
// Lexer
class CalcLexer extends Lexer;
options {
k=2; // needed for newline junk
charVocabulary='\u0000'..'\u007F'; // allow ascii
}
LPAREN: '(' ;
RPAREN: ')' ;
PLUS : '+' ;
MINUS : '-' ;
STAR : '*' ;
INT : ('0'..'9')+ ;
WS : ( ' '
| '\r' '\n'
| '\n'
| '\t'
)
{$setType(antlr::Token.SKIP);}
;
// Parser
class CalcParser extends Parser;
options {
buildAST=true;
}
expr: mexpr ((PLUS^|MINUS^) mexpr)*
;
mexpr
: atom (STAR^ atom)*
;
atom: INT
| LPAREN! expr RPAREN!
;
// AST-Walker
class CalcTreeWalker extends TreeParser;
options {
importVocab=CalcLexer;
}
expr returns [int r=0]
{ int a,b; }
: #(PLUS a=expr b=expr) {r = a+b;}
| #(MINUS a=expr b=expr) {r = a-b;}
| #(STAR a=expr b=expr) {r = a*b;}
| i:INT {r = atof(i->getText().c_str());}
;
Please help!
thx,
Oliver
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list