質問

A fragment of my grammar is:

potentialAttribute: DATA EQUAL LEFTPARENTH (data+ | REAL+) RIGHTPARENTH SEMICOLON; 

Then, in visitor, I should ask potentialAttribute if text read was data+ or REAL+. Since both of them have + symbol, both must be arrays. Nevertheless, only REAL() is a List<TerminalNode>, while data() remains as TerminalNode.

BUT if I change choice order, like:

potentialAttribute: DATA EQUAL LEFTPARENTH (REAL+ | data+) RIGHTPARENTH SEMICOLON; 

It is REAL the one which does not work.

What can cause this?

(I can post the whole compilable code if needed)

役に立ちましたか?

解決

This would be a bug in ANTLR 4. You can report issues to the project issue tracker on GitHub:

https://github.com/antlr/antlr4/issues

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top