When writing a lexer for JFlex input files for use with Pygments
(http://pygments.org), a generic syntax highlighter, some questions
arose.
1. The token '|' used as a regex operator for union, and as an action
makes the grammar for the syntax of lexical rules (session 4.3.1 of
the manual) ambiguous.
For instance, how should the following lexical rules be interpreted?
re1 |
re2 { action }
a) as one lexical rule:
(re1|re2) { action }
b) as two lexical rules with the action '|' for the first one.
2. In macro definitions, how does one know where one regular expression
finishes?
For instance, the following snippet in the second session of the
specification
a = re1
b = re2
could mean one single macro definition
a = (re1 b = re2)
as well as two macro definitoins: 'a' and 'b'
3. Can a JFlex comment appear anywhere a space is allowed?
For instance, are the following allowed?
%% // end of section 1
%{ // the following will be inserted into the generated class
some java code goes here
%}
macro1 /* this is a macro */ = /* definition */ regex
%%
< /*comment1*/ YYINITIAL, /*comment2*/ STR > re { action1 }
(a /*comment3*/ b | c) d { action2 }
regex1 / /*comment3*/ regex2 { action3 }
Romildo
|