[plt-scheme] parser-tools: recursive lex?

From: YC (yinso.chen at gmail.com)
Date: Fri Jan 2 21:40:53 EST 2009

Hi,

I am trying to parse internet messages, which is mostly regular besides for
comment (which can nest), and I am not sure how to handle comment correctly
with lex.

The code below (lexing internet message comment syntax) results in an
infinite loop, so I assume lex can only handle regular expressions, but want
to check to see if it can be done (or how the problem can be solved), or if
I need to use yacc?

Thanks,
yc

(require parser-tools/lex
         (prefix-in : parser-tools/lex-sre))

;; below defines a simpled internet message
comment

(define-lex-abbrevs
  (ctext (:- any-char (:or #\( #\))))
  (ccontent (:or ctext comment))
  (comment (:: #\( (:* ccontent) #\))))

(define comment-lexer
  (lexer (comment lexeme)))
;; inf
loop

(comment-lexer (open-input-string "(this is a internet message comment)"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090102/906a12fe/attachment.html>

Posted on the users mailing list.