Newbie question: Scanners?

AndrewO obrien.and... at
Mon May 14 21:40:05 UTC 2007

Hi Adrian,

Thanks for the response.   I think I understand the part about
backtracking, but I guess I'm still wondering about the first part.
It might help if I describe my situation a little more: I'm trying to
write something to parse the output from the traceroute utility more
quickly than a standard regex based solution written in Perl or Ruby.
The thing that's tripped me up in the past is that there's some
possible ambiguity which I think would have to be solved with
backtracking.  For example, you can have lines like the following:

6 (  113.927 ms  110.118
ms  109.133 ms

5 (  17.557 ms  10.957 ms  11.692 ms

7 (  2.708 ms (
2.751 ms *

Hostnames are easy to extract.  Where is gets complicated is on the
last line.  It can't be known that is an IP address and
not a delay until the second period.

So does this situation fit into criteria of being able to be "broken
down into a list of items taken from a pool of possibilities"?

Sorry if this is a little remedial and thanks for the help.


On May 11, 3:49 pm, Adrian Thurston <thurs... at> wrote:
> Hi Andrew,
> Scanners are suitable for processing streams of tokens. Generally this
> is any input that can be broken down into a list of items taken from a
> pool of possibilities.
> You can also use a scanner for its backtracking features. They are
> useful in cases where you want to attempt one pattern and should that
> fail you would like to match some other pattern against a shorter string.
> Regards,
>  Adrian
> AndrewO wrote:
> > Hi,
> > I'm pretty new to FSMs, so this is probably an obvious question: when
> > would you use a scanner over a standard machine?  Is it just for being
> > able to backtrack if you're going to have ambiguity?  Or is it deeper
> > than that?
> > Sorry if this has been covered elsewere.
> > Thanks,
> > Andrew O'Brien
> > >
>  signature.asc
> 1KDownload

More information about the ragel-users mailing list