-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trailing-context is not working #1088
Comments
Can you post a spec file with input that doesn't work for you as expected? The rules above are not in the JFlex syntax. I'd expect the following to work: %%
%public
%class Test
%debug
letters = [a-zA-Z]+
end = "stop"
%%
{letters} / {end} { return 0; }
[^] { return 1; } For input
you should get a single match for |
Sorry for being much too short.
It seems that, as a special case, trailing context regular expressions cannot be used in macro definitions. I think that it would make it simpler to define complex lexical specs if that would be no special case, so I propose that as a new feature for JFlex: Offer support for trailing context rules in macros. Background: The lexer I'm working on can be seen here. This implements the lexical structure for the Scheme programming language v5. So far, it was possible to define all scanning expressions as macros, matching only the terminal tokens in the match section. This is now not longer the case. The requirement for using trailing context came in with the new Scheme v7 feature of nested comments, I added the relevant part of the lexical structure spec (note the comment text rule):
|
That is indeed the case, and error reporting for it is not exactly great. I've opened #1089 for that.
This is going to be tricky, and I'm not sure yet it's worth it. The underlying problem is that the matching algorithm only works for trailing context at the top level (otherwise we're not matching a regular language any more). If we allow trailing contexts in macros, we can now syntactically get trailing context at any nesting level in an expression. I guess we could allow it syntactically and have a semantic pass for checking that it is only used at the top level. |
I tried to use a trailing context rule like:
This always results in a 'syntax error'. Actually, I was not able to successfully define any rule using a trailing context.
According to the JFlex manual, trailing context is supported, so it seems to be not working currently.
The text was updated successfully, but these errors were encountered: