[antlr-interest] need help in antlr
Anthony Brenelière
abreneliere at telys.com
Mon Jun 23 04:57:41 PDT 2003
You have to know the default class used for tokens is "CommonToken".
In the parser, you can use the CommonToken::getLine() and
CommonToken::getColumn() methods.
As the data is read from a stream, you have to keep the filename in a
variable.
Here is an example:
document_element
: information
| i:CIAO_TEXT
{
char toto[30];
CObject * obj;
wt->addObject( obj );
obj->aP( "Category", "CIAOText" );
obj->aP( "Content", i->getText() );
obj->aP( "PageNumber", pageNum );
obj->aP( "LineNumber", lineNum );
obj->aP( "FileName", fileName );
obj->aP( "BufferColumn", string( itoa(i->getColumn(),
toto, 10) ) );
obj->aP( "BufferLine", string( itoa(i->getLine(), toto,
10) ) );
outF->displayObject( * obj );
}
;
Cordially,
Anthony Brenelière
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list