[racket] Using lex and yacc

From: Mark Carter (mcturra2000 at yahoo.co.uk)
Date: Tue Oct 12 14:12:23 EDT 2010

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?



      


Posted on the users mailing list.