Eric,
[...]
> To simplify list rule generation, perhaps something like this would
> be good:
>
> (define-lex-block-analyzer semantic-lex-blah-blah-list
> '( ( "{" "}" brace )
> ( "(" ")" paren ) )
> )
>
> It would auto-generate brace-open, brace-close, and brace-list.
> (Sorry, I'm a fan of lower case, but am open to suggestions)
In fact, I use upper case for terminal symbols to follow the
recommendation from the Bison's manual:
"The Bison representation for a terminal symbol is also called a
"token type". Token types as well can be represented as C-like
identifiers. By convention, these identifiers should be upper case to
distinguish them from nonterminals: for example, `INTEGER',
`IDENTIFIER', `IF' or `RETURN'. A terminal symbol that stands for a
particular keyword in the language should be named after that keyword
converted to upper case."
Maybe if the prefix is given in upper case the symbol names could be
generated in upper case too? So both you and me will be happy ;-)
IMO, a more general design would be to specify the open, close and
list symbols. Thus the programmer will be free to choose what
terminal symbol names he wants, and more probably [important!] he will
be able to keep those that already exist in grammars. This could
simplify things when porting existing grammars ;-)
Perhaps something like this:
(define-lex-block-analyzer semantic-lex-blah-blah-list
'(BLOCK_BRACE
("{" . LBRACE)
("}" . RBRACE)
)
'(semantic-list
("(" . open-paren)
(")" . close-paren)
)
...
)
> This is because it is faster (I suspect) to do this:
>
> (cond ...
> ((looking-at "\\s(")
> (let ((text (...)))
> (cond ((string= "(" text) ...)
> (string= "{" text) ...))))))
> ...
> )
>
> than several looking-at regexps. (Only one regexp to compile).
This is a good point!
> It might be nice to pre-name many of them, such as {, [, (, <. Such
> naming will help keep language files looking the same. While
> compiling the macro, it could search the syntax table for which ones
> are available. Hmm, the syntax table may not be available. Perhaps
> we can specify what the syntax table is somewhere since we already
> offer syntax table deltaas. Then only languages with really strange
> characters would need to worry about the specific macro you have
> proposed.
This could be good idea! But, as I already said above, we should take
care of not making more difficult to port existing grammars, because
of hard-coded terminal symbol names.
> Of course, this then begs the macro that detects "BEGIN", and finds
> the matching "END" keyword for languages like Ada, pascal, and
> OCTAVE. What fun.
;-)
David
|