jflex-de/jflex

NPE occurs when generating dot file of an NFA

Mivik opened this issue · 2 comments

Mivik commented

I chose exactly the lexer in examples/simple and appended "-dot" argument. Then the following NPE occurred:

../../bin/jflex -d out/genfiles -dot src/main/jflex/simple.flex
Reading "src/main/jflex/simple.flex"
Constructing NFA : 
Unexpected exception encountered. This indicates a bug in JFlex.
Please consider filing an issue at http://github.com/jflex-de/jflex/issues/new

java.lang.NullPointerException
	at jflex.core.NFA.dotFormat(NFA.java:502)
	at jflex.core.NFA.writeDot(NFA.java:478)
	at jflex.generator.LexGenerator.generate(LexGenerator.java:80)
	at jflex.Main.generate(Main.java:320)
	at jflex.Main.main(Main.java:336)

It seems that you didn't notice that the StateSet in table can be null while generating the graph.

lsf37 commented

Thanks for the report. Yes, you're right, it can be null and will in fact often be null. At least it should be easy to fix.

This issue should be easy to fix, either with a null-check, or using Optional.