[racket] Using lex and yacc

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Oct 12 14:23:28 EDT 2010

The documentation:

http://docs.racket-lang.org/parser-tools/Converting_yacc_or_bison_Grammars.html

says:

"Annotated examples are in the "examples" subdirectory of the
"parser-tools" collection."

That is online here:

http://git.racket-lang.org/plt/tree/HEAD:/collects/parser-tools/examples

Jay

On Tue, Oct 12, 2010 at 12:12 PM, Mark Carter <mcturra2000 at yahoo.co.uk> wrote:
> Are there any examples on using lex and yacc, as I'm having trouble getting
> started. I am trying to write a simple calculator. Here's what I've got so far:
>
> #lang racket/base
>
> (require parser-tools/lex)
>
> (define lex (lexer
>             ((:+ "[0-9]") (values 'int (string->number lexeme)))
>             ((:+ whitespace) null)
>             ((:: "+") (values 'plus 0))
>             ((:: "-") (values 'minus 0))
>             ((:: "*") (values 'mult 0))
>             ((:: "/") (values 'div 0))))
>
> When I try to compile it, I get
>   regular-expression: undefined operator in: (:+ "[0-9]")
> How do I correct this?
>
>
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.