Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-08-27 04:01:36


Jonathan Turkaniswrote:
>"Rob Stewart" <stewart_at_[hidden]> wrote in message
>news:200408262114.i7QLEOP14442_at_lawrencewelk.systems.susq.com...
> > From: "Jonathan Turkanis" <technews_at_[hidden]>
> > > - multi_skipper: I'm not sure I see why this is needed; how
> > > often do you need to skip a sequence of repeated characters? Id rather
> >
> > When parsing, it is often useful to ensure that there were
> > exactly 10 spaces between one token and the next, for example.
>
>I'll take your word for it, but an example would help. I am used to just
>worrying about whitespace.

Haskell uses whitespace to associate code on the right of the whitespace
with the code on the left. e.g.

[haskell.hs]
factorial x = fimpl x
   where
      fimpl 0 = 1
      fimpl x = fimpl ( x - 1 ) * x

power (x:xs) = power xs * x
power [] = 1
[end]

where [] is an empty list and (x:xs) is a list with x as the head and xs as
the tail.

In this example, fimpl is associated with factorial and is only visible in
its scope. factorial and power (both patterns) are in global scope.

When writing a Haskell lexer, you need to be aware of the number of space
characters after a given new-line. Therefore, something like multi_skipper
would be useful, but it would need to:
[1] reset an internal nspace variable on recieving a new-line character,
allowing read access to it by the lexer;
[2] incrementing by n (where n=3,4 or 8) upon recieving a tab character;
[3] incrementing by 1 when recieving a space character

I am not sure how the above could be implemented using multi_skipper, but
this is an example where the number of spaces is important.

Another example would be in padding. For example, the TAR file format
ensures that each file fills a number of blocks of 256 bytes, so you need to
skip the remaining bytes at the end of each file.

Regards,
Reece

_________________________________________________________________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!
http://toolbar.msn.co.uk/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk