Antlr4:词法分析规则失败,解析器规则成功了吗?

时间:2017-01-04 04:03:50

标签: parsing antlr antlr4

我有一个规则,当它是一个解析器(小写)规则时匹配字符串,但不是当它是一个词法分析器(大写)规则时。这是代码:



not_combat
    : (ownership|'the') PHASES
    ;

ownership
    : SELECTIVES (player_opponent'\'s'?)? // this needs to be a parser rule, fails on lexer rule... dunno why.
    ;

SELECTIVES
    : 'your'|'each'|'that'
    ;

player_opponent
    : 'player'|'opponent'
    ;




我在IntelliJ Idea中运行Antlr4插件,使用内置规则测试器和解析树。我的测试字符串是each player's upkeep,其中player_opponent解析器规则将起作用,但词法分析器Player_opponent规则将失败,字符串为player,但不会出现字符串opponent ,这对我来说真的很混乱。

0 个答案:

没有答案