Newbie question: Scanners?
obrien.and... at gmail.com
Mon May 14 21:40:05 UTC 2007
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 sl-bb24-pen-15-0.sprintlink.net (188.8.131.52) 113.927 ms 110.118
ms 109.133 ms
5 184.108.40.206 (220.127.116.11) 17.557 ms 10.957 ms 11.692 ms
7 18.104.22.168 (22.214.171.124) 2.708 ms 126.96.36.199 (188.8.131.52)
2.751 ms *
Hostnames are easy to extract. Where is gets complicated is on the
last line. It can't be known that 184.108.40.206 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 cs.queensu.ca> 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.
> 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
> > >
More information about the ragel-users