Dear list, 

 

I am trying to make a compiler and we are having a hard time getting Alex to 
work. We have succeded to work out Alex using older version, but with the the 
2.2 version we keep getting this error and we havent been able to figure it out.

 

So this is our tokens definition:

 

{

   module Lexico where

    import Alex

}

 

%wrapper "posn"

 

$digit = 0-9 -- digits

$alpha = [a-zA-Z] -- alphabetic characters

 

tokens :-

 

$white+ ;                            --Los espacios en blanco los omito

\/\/.* ;                               --Lo que venga después de dos barras 
omito

\/\*.*\*\/ ;                         --Lo que está entre las barras de 
comentario omito

$digit+                                 { \p s -> TokenEntero p (read s) }

\' [$alpha $digit \_]* \'            { \p s -> TokenString p (read s)}

[$digit]+\.[$digit]+                 { \p s -> TokenDouble p (read s) }

$alpha [$alpha $digit \_]*        { \p s -> TokenVar p (read s) }

 

 

And when we call the alexScanTokens "hello" we get this error:

 

[TokenVar (AlexPn 0 1 1) "*** Exception: Prelude.read: no parse

 

So we are concerned about the "TokenVar p (read s)" . Would that be the way to 
read a string? 

 

We just get this error with TokenVar and TokenString, whenever we call the 
function like: alexScanTokens 19   , for instance we dont get any problems and 
the token 19 is recognized ok.

 

Please, any ideas on what am i doing wrong????????

regards, 

 

L

 


 
                                          
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to