question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Why is the ATN of the following lexer rules different from the javadoc of ATNState

See original GitHub issue

I have the following toy lexer

fragment DIGIT
    : [0-9]
    ;

NaturalNumber
    : DIGIT+
    ;

According to the javadoc of ATNState, the ATN of NaturalNumber should start with RuleStartState --> PlusBlockStartState.

But In fact, a path in the ATN looks similar to

RuleStartState -> BasicState -> SetTransition[0-9] ->RuleStopState -> BlockEndState 
          ^                                                               |
          |                                                               |
  BasicState <----------------------  PlusBlockStartState <- ... <- PlusLoopbackState

Could someone advise why the ATN is changed in this way, and is it possible to get a canonical ATN as described in the javadoc of ATNState?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sharwellcommented, Oct 7, 2021

It seems like it would be better to convert this to a GitHub discussion instead of moving it to a completely different medium.

image

image

0reactions
chengniansuncommented, Oct 8, 2021

tate tran

So, for the lexer rule NaturalNumber, there will be no RuleStopState which has no outgoing transitions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the ATN of the following lexer rules different from the ...
Could someone advise why the ATN is changed in this way, and is it possible to get a `canonical` ATN as described in...
Read more >
LexerATNSimulator (ANTLR 4 Runtime 4.7 API) - Javadoc.io
When we hit an accept state in either the DFA or the ATN, we have to notify the character stream to start buffering...
Read more >
Package org.antlr.v4.runtime.atn
Represents a single action which can be executed following the successful match of a lexer rule. Class Summary. Class, Description. AbstractPredicateTransition.
Read more >
Lexical Analysis with ANTLR
Lexical Analysis with ANTLR. A lexer (often called a scanner) breaks up an input stream of characters into vocabulary symbols for a parser,...
Read more >
Initialising my Lexer throws an error in Antlr4 - Stack Overflow
It sounds like there might be a version issue. ANTLR generates serialized ATN (augmented transition networks) that have a special format ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found