[antlr-interest] hollerith string
marcschellens
m_schellens at hotmail.com
Fri Aug 15 00:04:10 PDT 2003
How to parse a hollerith string
the format is nHccccc
where n is a number H a 'H' and cccc n characters
eg:
5Habcde is 'abcde'
I did the following (using antlr c++ mode) in the lexer:
NUMBER
: (DIGIT)+
(H!
{
string text=$getText;
int len=atoi(text.c_str());
$setText("");
for( int i=0; i<len; i++)
{
consume(); // appends char
}
_ttype=STRING;
}
)?
;
I think it should work, but generally I prefer not to call
internals like 'consume()' directly. So is there a way of avoiding
it?
thanks,
marc
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list