Skip to content
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

NPE occurs when generating dot file of an NFA #769

Closed
Mivik opened this issue Jul 11, 2020 · 2 comments
Closed

NPE occurs when generating dot file of an NFA #769

Mivik opened this issue Jul 11, 2020 · 2 comments
Assignees
Labels
bug Not working as intended help wanted Good first issues
Milestone

Comments

@Mivik
Copy link
Contributor

Mivik commented Jul 11, 2020

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.

@Mivik Mivik changed the title NPE occurs when generating dot file of a NFA NPE occurs when generating dot file of an NFA Jul 11, 2020
@lsf37
Copy link
Member

lsf37 commented Jul 12, 2020

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.

@lsf37 lsf37 added the bug Not working as intended label Jul 12, 2020
@lsf37 lsf37 self-assigned this Jul 12, 2020
@lsf37 lsf37 added this to the 1.9.0 milestone Jul 12, 2020
@regisd regisd added the help wanted Good first issues label Dec 13, 2020
@regisd
Copy link
Member

regisd commented Dec 13, 2020

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

regisd pushed a commit that referenced this issue Dec 16, 2020
commit 5544d56
Author:     mivik <mivik@qq.com>
AuthorDate: Wed Dec 16 13:07:32 2020 +0800
Commit:     Gerwin Klein <gerwin@doclsf.de>
CommitDate: Wed Dec 16 18:31:34 2020 +1100

    Fix an NPE when generating dot files (#769)

Updated from target/jflex-parent-1.9.0-SNAPSHOT-sources.jar
@Mivik Mivik closed this as completed Dec 17, 2020
lsf37 added a commit that referenced this issue Jan 1, 2023
lsf37 added a commit that referenced this issue Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended help wanted Good first issues
Projects
None yet
Development

No branches or pull requests

3 participants