You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parser for .x files will now generate warnings for rules whose
regular expression is nullable, i.e., matches the empty input.
Exceptions are:
1. The user wrote regular expression ().
In this case they probably meant to match the empty input.
2. Startcodes are involved.
Then, matching the empty input might still change the lexer
state, thus, the lexer might not continue to match the empty input.
Warnings are kept as a stack in the state of the parse monad, and
printed upon successful completion of the parser in Main.
Example (excerpt of `issue_71.x`):
```
$whitespace = [\ \n\t]
@whitespaces = $whitespace*
:-
@whitespaces { \ _ _ -> Whitespaces }
^ Warning here!
Warning: issue_71.x:24:14: Regular expression [..]* matches the empty string.
```
Since the parser does not generate abstract syntax with position
information, it is hard to give the exact warning location, i.e., the
location of the offending regular expression. To keep the changes
minimal, we record the location of the token _after_ the regular
expression, i.e., the location where the code part begins. This
approximate location should be good enough to jump to the regex in
question.
Another problem is that the exact text of the regular expression is not
printed in the warning, only what `Show RExp` gives us. This could be
fixed if we had the exact location information of the regular
expression; we could then cut the regular expression out of the input
string. Alternatively, the parser could be modified to return a
_concrete_ syntax for the regular expression from which its original
text could be recovered. The abstract reg.ex. would then be built from
the concrete one in a second step.
At this point, I abstain from such invasive changes to Alex for the sake
of improving this rare warning.
0 commit comments