-
Notifications
You must be signed in to change notification settings - Fork 116
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
Unexpected exception encountered in JFlex: Not normalised type = STAR #888
Comments
Thanks for the report. Could you share a minimal flex spec that reproduces the issue? |
Hello! I think this can be closed. I think it was an error on my part but I
am not sure what it was. I was able to redo the code and it worked fine. My
apologies and thank you so much for the prompt response because this is for
an assignment due on Tuesday. But I was able to resolve.
|
In particular, it's a bit surprising to see an empty interval |
Would you still like me to send you my code?
|
This is the original file. It was an attempt of constructing a lexical
analyzer for the regular expressions of the Scheme language syntax.
It has multiple errors that were fixed later.
|
Yes, it would be helpful. Unfortunately, the attachment by email was not handled. I think you can attach a file in the web UI simply by dragging in the comment section. |
Ok, I will do that. Thanks!
|
Again this file has multiple errors. |
This does still look like a potential bug, because even for strange specs JFlex shouldn't just throw an exception. For easier discussion later, here the file again: package grammar;
import java.io.*;
%class SchemeLexicalAnalyzer
%%
Letter = [A-Za-z]
Digit = [0-9]
Initial = [ {Letter} | "!" | "$" | "%" | "&" | "*" | "/" | ":" | "<" | "=" | ">" | "?" | "~" | "_" | "^" ]
Subsequent = [ {Initial} | {Digit} | "." | "+" | "-" ]
Identifier = {Initial} [{Subsequent}* | "+" | "-" | "..."]
Boolean = [ #t | #f ]
/*
Num2 = [0-1]["#b"]
Num8
Num10 = {Digit}*
Num16
Number = [ {Num2} | {Num8} | {Num10} | {Num16} ]
*/
Number = [{Digit}]
StringChar = "\"" | ("\\") | [^"\\]
String = {StringChar}*
Whitespace = [\ |\n|\t]
Character = [{Whitespace} | {StringChar}]
Constant = [ {Boolean} | {Number} | {Character} | {String} ]
Keyword = [ "and" | "begin" | "case" | "cond" | "define" | "delay" | "if" | "lambda" | "let" | "let*" | "let-syntax" | "letrec-syntax" | "or" | "quasiquote" | "quote" | "set!" ]
%%
{Identifier} { return System.out.printf("IDENTIFIER %s", yytext()); }
{Boolean} { return System.out.printf("BOOLEAN %s", yytext()); }
{Number} { return System.out.printf("NUMBER %s", yytext()); }
{String} { return System.out.printf("STRING %s", yytext()); }
{Whitespace} { } // do nothing
{Character} { return System.out.printf("CHARACTER %s", yytext()); }
{Constant} { return System.out.printf("CONSTANT %s", yytext()); }
{Keyword} { return System.out.printf("KEYWORD %s", yytext()); }
"(" { return System.out.printf("LEFTPARENTHESIS %s", yytext()); }
")" { return System.out.printf("RIGHTPARETHESIS %s", yytext()); }
"." { return System.out.printf("DOT %s", yytext()); }
"#(" { return System.out.printf("OPENVECTOR %s", yytext()); }
"'" { return System.out.printf("QUOTE %s", yytext()); }
"`" { return System.out.printf("QUOTATION %s", yytext()); } |
While there are some other problems in the spec, we should at least get a useful error message, and in fact most of the variations here would actually make sense. Here are some minimised specs that lead to an exception that could/should produce valid code: %%
M = a
%%
[ {M} ] { } %%
M = "a"
%%
[ {M} ] { } %%
M = [a] | [b]
%%
[ {M} ] { } |
Signed-off-by: Gerwin Klein <lsf@jflex.de>
Because we allow macros in the syntax for char class contents, we can get arbitrary regular expressions inside, not just char class content expressions. This commit turns the previous "cannot happen" check for such a case into proper error reporting. Fixes #888 and #939 Signed-off-by: Gerwin Klein <lsf@jflex.de>
I received this exception while trying to run JFlex to create a Scheme lexical analyzer for my Programming Languages course. I have never done this before, and I had never used JFlex before so this is probably a mistake I made. I am still following the instructions to try to get some help. Any help would be highly appreciated. Thanks in advance!
"Reading "Scheme.jflex"
Unexpected exception encountered. This indicates a bug in JFlex.
Please consider filing an issue at http://github.com/jflex-de/jflex/issues/new
Not normalised type = STAR
content :
type = PRIMCLASS
content :
{ [' ']['"']['('-')']['']['^']['|'] }
jflex.exceptions.CharClassException: Not normalised type = STAR
content :
type = PRIMCLASS
content :
{ [' ']['"']['('-')']['']['^']['|'] }
at jflex.core.RegExp.checkPrimClass(RegExp.java:242)
at jflex.core.RegExp.normalise(RegExp.java:323)
at jflex.core.RegExp.normalise(RegExp.java:353)
at jflex.core.RegExps.normalise(RegExps.java:293)
at jflex.core.LexParse$CUP$LexParse$actions.CUP$LexParse$do_action_part00000000(LexParse.java:1029)
at jflex.core.LexParse$CUP$LexParse$actions.CUP$LexParse$do_action(LexParse.java:2257)
at jflex.core.LexParse.do_action(LexParse.java:598)
at java_cup.runtime.lr_parser.parse(lr_parser.java:699)
at jflex.generator.LexGenerator.generate(LexGenerator.java:74)
at jflex.Main.generate(Main.java:320)
at jflex.Main.main(Main.java:336)"
The text was updated successfully, but these errors were encountered: