leex newbie question

Robert Virding robert.virding@REDACTED
Wed Jan 14 08:55:28 CET 2004


SEUNG BONG HAN wrote:
> Hi.
> 
> I just started to learn leex and  I have a hard time figure out how to 
> write the scanner.
> 
> Here is my simple test lex grammar :
> 
> test1.xrl :
> 
> Definitions. 
> D = [0-9]
> H = [0-9a-fA-F]
> WS = [\000-\040]
> A = [a-zA-Z@REDACTED]
> 
> Rules.
> {D}+\.{D}+((E|e)(\+|\-)?{D}+)? : {token,{float,YYline,YYtext}}.
> {D}+  : {token, {integer, YYline, YYtext}}.
> 0[xX]{H}+ : {token, {hex, YYline, YYtext}}.
> ([a-z]({A}*)) : {token, {word, YYline, YYtext}}.
> [!?/;:,.*+#()[\]|<>={}-] : {token,{list_to_atom(YYtext),YYline}}.
> {WS}+ : .
> 
> ** 
> 
> After generate the scanner and execute the function test1:string("hello")
> 
> I expected to see {ok, [{word, 1, "hello"}],1}.
> However, I got {error, {1,test1, {illegal, "hello"}.

The reply I wrote to you earlier was wrong, I missed the \ in the 
character list. I found no errors in the scanner and it seemed to work 
as expected. However, I have a slightly old version of Erlang, R9B, so I 
don't know if anything has changed since then in the regexps.

Robert




More information about the erlang-questions mailing list