[ragel-users] Help with extracting a list of numbers
Adrian Thurston
thurs... at cs.queensu.ca
Tue Mar 25 22:36:47 UTC 2008
Hi Manoj,
Are you sure the null is being sent to the parser? If it is then
printNumber should be executed on the last character.
Adrian
Manoj Rajagopalan wrote:
> 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