[plt-scheme] Learning Scheme Lexer

From: Scott Owens (sowens at cs.utah.edu)
Date: Mon Dec 9 21:46:05 EST 2002

(lexer
   (letter (display "It's a letter")))
matches the string of characters l e t t e r.
((letter) (display "It's a letter"))
matches whatever letter is defined to be.

-Scott

On Monday, December 9, 2002, at 07:16  PM, Paulo Jorge O. C. Matos 
wrote:

>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Hi all,
>
> I'm trying to use the Scheme parser tools.
> I've tried:
> (require (lib "lex.ss" "parser-tools"))
>
> (define-lex-abbrevs [letter (: (- "a" "z") (- "A" "Z"))]
>                     [digit (- "0" "9")]
>                     [number (@ (- "0" "9") (+ (- "0" "9")))]
>                     [float (@ (number) "." (number))])
>
>
> (define mylexer (lexer (letter (display "It's a letter"))
>                        (float (display "It's a float"))
>                        (number (display "It's a number"))
>                        (digit (display "It's a digit"))))
>
> Then I did in interactions:
> Welcome to DrScheme, version 202.6-cvs25nov2002.
> Language: Pretty Big (includes MrEd and Advanced).
> > (mylexer (current-input-port))
> 23
>
> . lexer: No match found in input starting with: 2
> > (mylexer (current-input-port))
> a
>
> . lexer: No match found in input starting with: a
> >
>
> Any ideas on what might be my error?
>
> Best regards,
>
> -- 
> Paulo J. Matos : pocm(_at_)mega.ist.utl.pt
> Instituto Superior Tecnico - Lisbon
> Software & Computer Engineering - A.I.
>  - > http://mega.ist.utl.pt/~pocm
>  ---	
> 	Yes, God had a deadline...
> 		So, He wrote it all in Lisp!



Posted on the users mailing list.