<html>
<body>
<font size=3>Hi all,<br><br>
I am playing with the parser tools in Racket. I would like to be
able pass a separately defined list of symbols to define-empty-tokens
(which is a syntax macro defined in
parser-tools/private-lex/token.rkt). Unfortunately passing a list
to define-empty-tokens doesn't work because the macro is expecting to
find the token symbols coded in-line.<br><br>
My lexer uses a hash table to distinguish the reserved words in my
language from other identifiers. The object is to initialize the
parser and the hash table from the same list of symbols ... I don't want
to have to maintain 2 identical lists.<br><br>
Currently I'm doing the following:<br><br>
=============================================<br><br>
(define *reserved-words* '(word1 word2 ...))<br><br>
(define *reserved-word-hash* <br>
(for/hash ((sym *reserved-words*))<br>
(values (string-downcase (symbol->string
sym)) sym)<br>
))<br><br>
(eval `(define-empty-tokens RESERVED ,*reserved-words*))<br><br>
=============================================<br><br>
This works, but using eval seems like a hack and the code fails syntax
checking in DrRacket (the parser generator code complains that the
RESERVED token group is undefined).<br><br>
<br>
I probably could modify the macro to return the symbols passed into it
(I'm sure I don't know how to make it accept a separate list). But
I'm not sure it is a good idea to mess with the macro anyway ... there is
enough black magic in the yacc/lex implementation already.<br><br>
Any thoughts?<br>
George<br>
</font></body>
</html>