
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

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
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
participants (1)
-
Omari Norman