[Haskell-cafe] Alex character sets

Omari Norman omari at smileystation.com
Sat Mar 24 23:52:19 CET 2012


OK, it turns out that having [^\x00] as a character range gives me the
error with pred. [\x00] works fine; [^\x00] gives the error message.

On Sat, Mar 24, 2012 at 6:33 PM, Omari Norman <omari at smileystation.com>wrote:

> I'm wrinting (or at least, trying to write) an Alex lexer. Say I want to
> group character ranges together and specify that I want a character that is
> *not* in any of those ranges. Example
>
> ---
>
>  {
> module Main where
> }
>
> %wrapper "posn-bytestring"
>
> $lowAscii = \x00-\x1f -- unprintable stuff
> $lowSymbol = \x21-\x2f -- exclamation point to solidus
> $space = \x20
>
> $special = [^$lowAscii $lowSymbol]
>
> lex :-
>
> $special { Word }
>
> {
> data Token = Word AlexPosn ByteString.ByteString
> }
>
> When I run this through Alex, I get "Prelude.Enum.Char.pred: bad argument".
>
> What am I doing wrong? How would I accomplish this sort of thing? Thanks.
> --Omari
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120324/b04ba3f5/attachment.htm>


More information about the Haskell-Cafe mailing list