[antlr-interest] beginner help - Mac OSX trouble?
kurtschwehr
kurtschwehr at yahoo.com
Mon Jul 28 11:43:38 PDT 2003
Hey All,
Could someone please tell me what I'm doing wrong in this C++ simple
parser? Is it
something I did or trouble with Mac OSX 10.2.6. I'm also using gcc
3.1.
Thanks!
-kurt
from gdb:
(1+1)
Program received signal EXC_BAD_ACCESS, Could not access memory.
antlr::ASTFactory::create(antlr::RefCount<antlr::Token>) (this=0x0,
tok={ref = 0x2e6960}) at
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_iterator.h:584
(gdb) bt
#0 antlr::ASTFactory::create(antlr::RefCount<antlr::Token>)
(this=0x0, tok={ref = 0x2e6960}) at
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_iterator.h:584
#1 0x00004770 in CalcParser::expr() (this=0xbffff9a0) at
CalcParser.cpp:40
#2 0x00005128 in main (argc=1, argv=0xbffffab4) at main.C:16
#3 0x00002940 in _start (argc=1, argv=0xbffffab4, envp=0xbffffabc) at
/SourceCache/Csu/Csu-45/crt.c:267
#4 0x000027c0 in start ()
from CalcParser::expr():
tmp1_AST = astFactory->create(LT(1));
And here is the code:
main.C:
int main(int argc, char **argv)
{
try {
CalcLexer lexer(cin);
CalcParser parser(lexer);
parser.expr();
RefAST t = parser.getAST();
cout << t->toStringList() << endl;
} catch(exception& e) {
cerr << "exception: " << e.what() << endl;
}
}
calc.g:
options
{
language="Cpp";
}
class CalcLexer extends Lexer;
public
INTEGER: (DIGIT)+;
LPAREN: '(';
RPAREN: ')';
PLUS: '+';
protected
DIGIT: '0'..'9';
class CalcParser extends Parser;
options
{
buildAST=true;
}
expr: LPAREN INTEGER (PLUS INTEGER)* RPAREN;
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list