开发者

ANTLR - The following alternatives can never be matched

I am unable to understand why this simple grammar -

grammar Test;
file    :   ID;
ID  :   .*;

leads to this error -

Test.g:3:6: The follo开发者_开发问答wing alternatives can never be matched: 1

Why is this happening?


Using .* and .+ at the end of a lexer rule is illegal in ANTLR:

ID : .*;       // illegal
ID : 'bar' .*; // illegal
ID : .* 'bar'; // legal

In parser rules, this is not the case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜