[Hat] spend a lot of time with alex generated module
ivan gomez rodriguez
kguento at gmail.com
Wed Aug 16 12:45:53 EDT 2006
Skipped content of type multipart/alternative-------------- next part --------------
{
module Lexer (Token(..), alexScanTokens) where
}
%wrapper "basic"
$digit = 0-9 -- digits
$alpha = [a-zA-Z] -- alphabetic characters
tokens :-
$white+ ;
"--".* ;
\. { \s -> TPUNTO }
\) { \s -> TPARDER }
\( { \s -> TPARIZQ }
\[ { \s -> TCORIZQ }
\] { \s -> TCORDER }
\| { \s -> TPIPE }
= { \s -> TIGUAL }
!= { \s -> TDISTINTO }
"->" { \s -> TFLECHA }
> { \s -> TMAYOR }
>= { \s -> TMAYORIGUAL }
\< { \s -> TMENOR }
\<= { \s -> TMENORIGUAL }
\+ { \s -> TMAS }
\- { \s -> TMENOS }
\* { \s -> TPOR }
\/ { \s -> TBARRA }
& { \s -> TAND }
\^ { \s -> TTILDE }
\, { \s -> TCOMA }
\; { \s -> TPUNTOCOMA }
:= { \s -> TDOSIGUAL }
:: { \s -> TCUATROPUNTOS }
\;\; { \s -> TDOSPUNTOCOMA }
: { \s -> TDOSPUNTOS }
[] { \s -> TCORCHETES }
null { \s -> TNULL }
Int { \s -> TINT }
String { \s -> TSTRING }
in { \s -> TIN }
let { \s -> TLET }
rec { \s -> TISREC }
case { \s -> TCASE }
of { \s -> TOF }
if { \s -> TIF }
then { \s -> TTHEN }
else { \s -> TELSE }
"\""['A'-'Z''a'-'z''0'-'9''_'' ']* "\""
{ \s -> TCADENA s }
$digit+ { \s -> TENTERO (read s) }
$alpha [$alpha $digit \_ \']*
{ \s -> TVAR s }
eof { \s -> TEOF }
{
data Token
= TBLANCO
| TCOMMENT
| TPUNTO
| TPARIZQ
| TPARDER
| TCORIZQ
| TCORDER
| TPIPE
| TAMBER
| TIGUAL
| TDISTINTO
| TFLECHA
| TMAYOR
| TMAYORIGUAL
| TMENOR
| TMENORIGUAL
| TMAS
| TMENOS
| TPOR
| TBARRA
| TTILDE
| TCOMA
| TPUNTOCOMA
| TDOSIGUAL
| TCUATROPUNTOS
| TDOSPUNTOCOMA
| TDOSPUNTOS
| TCORCHETES
| TNULL
| TAND
| TINT
| TSTRING
| TIN
| TLET
| TISREC
| TCASE
| TOF
| TIF
| TTHEN
| TELSE
| TCADENA String
| TENTERO Int
| TVAR String
| TEOF
deriving (Eq,Show)
}
More information about the Hat
mailing list