Help with extracting a list of numbers
Manoj Rajagopalan
ma... at nanorex.com
Tue Mar 25 22:01:35 UTC 2008
Hi all,
I'm trying to write a pattern to extract a list of numbers following
the keyword bond and I'm not able to figure out why my pattern below
always skips the last number
My input is of the form:
bond <number> <number> ...
%%{
machine bond_parser;
whole_number = digit+ >to{intVal=0;} ${intVal = intVal*10 +
(fc-'0');} ;
main :=
space* 'bond'
(space+ whole_number %printNumber)+
space* 0;
}%%
where printNumber is an action to print the number just updated into the
integer variable intVal.
The 0 at the end of the pattern is the NULL character that cin.getline()
adds when reading upto the newline character from the console.
I realize this may be due to the leaving action for the last number that
never gets called but could someone tell me a way around this?
Thanks,
Manoj
More information about the ragel-users
mailing list