Force CL-Lex to read whole word

Posted by Flávio Cruz on Stack Overflow See other posts from Stack Overflow or by Flávio Cruz
Published on 2012-03-28T04:01:28Z Indexed on 2012/11/21 5:00 UTC
Read the original article Hit count: 281

Filed under:
|

I'm using CL-Lex to implement a lexer (as input for CL-YACC) and my language has several keywords such as "let" and "in". However, while the lexer recognizes such keywords, it does too much. When it finds words such as "init", it returns the first token as IN, while it should return a "CONST" token for the "init" word.

This is a simple version of the lexer:

(define-string-lexer lexer
     (...)
     ("in"   (return (values :in $@)))
     ("[a-z]([a-z]|[A-Z]|\_)"  (return (values :const $@))))

How do I force the lexer to fully read the whole word until some whitespace appears?

© Stack Overflow or respective owner

Related posts about lisp

Related posts about lexer