[plt-scheme] parser-tools: recursive lex?
At Fri, 2 Jan 2009 18:40:53 -0800, YC wrote:
> 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?
A lexer can only directly match regular expressions, but you can match
just the beginning of a comment, and then you can use a function call
as the action to parse more.
For an example of this technique,
collects/syntax-color/scheme-lexer.ss
which has a lexer that calls `read-nested-comment' when it matches
"#|".
Matthew