antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.22k stars 3.29k forks source link

When I use -atn param, an java.lang.IllegalArgumentException occur here. #2659

Open hagen666 opened 5 years ago

hagen666 commented 5 years ago

Code line : https://github.com/antlr/antlr4/blob/7982187134a6776d13cf8b1f9725f137d08adaec/tool/src/org/antlr/v4/tool/DOTGenerator.java#L262

Stacktrace:

Exception in thread "main" java.lang.IllegalArgumentException
        at java.lang.AbstractStringBuilder.appendCodePoint(AbstractStringBuilder.java:800)
        at java.lang.StringBuilder.appendCodePoint(StringBuilder.java:235)
        at org.antlr.v4.tool.DOTGenerator.getDOT(DOTGenerator.java:262)
        at org.antlr.v4.tool.DOTGenerator.getDOT(DOTGenerator.java:174)
        at org.antlr.v4.Tool.generateATNs(Tool.java:693)
        at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:398)
        at org.antlr.v4.Tool.process(Tool.java:361)
        at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:328)
        at org.antlr.v4.Tool.main(Tool.java:172)
hagen666 commented 5 years ago

The antlr version is 4.7.2.

ericvergnaud commented 5 years ago

Hi, thanks but without a simple way to reproduce, this is unlikely to raise any attention.

hagen666 commented 5 years ago

A running example is here: https://s3.amazonaws.com/artifacts.opencypher.org/Cypher.g4 it is the openCypher grammar.

The command line is:

java -jar antlr-4.7.2-complete.jar -atn Cypher.g4 -o atn
ericvergnaud commented 5 years ago

Seems that grammar accepts bytes that are not valid Java code points? Suggest you track which exact node names trigger the exception.

Le 29 sept. 2019 à 18:07, hagen666 notifications@github.com a écrit :

A running example is here: https://s3.amazonaws.com/artifacts.opencypher.org/Cypher.g4 https://s3.amazonaws.com/artifacts.opencypher.org/Cypher.g4 it is the openCypher grammar.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4/issues/2659?email_source=notifications&email_token=AAZNQJAKW46UEBZJQ3ABZOLQMB467A5CNFSM4I3RLHKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD73PIXY#issuecomment-536278111, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZNQJCNN3Q4GNY3BLQRYTLQMB467ANCNFSM4I3RLHKA.

hagen666 commented 5 years ago

Is it means that i need to clone the antlr repo and debug it in Eclipse?

hagen666 commented 5 years ago

But it runs well when using antlr to parse the grammar.

ericvergnaud commented 5 years ago

Is it means that i need to clone the antlr repo and debug it in Eclipse?

No just launch the cmd line with a java debugger

ericvergnaud commented 5 years ago

But it runs well when using antlr to parse the grammar.

The exception occurs as a result of using -atn option, which is used to generate a diagram, and I believe happens after the parser is generated

sharwell commented 5 years ago

I'm guessing atom.label is evaluating to -1, but this would occur for any negative value or for any value greater than 0x10FFFF.