1

这是我要解析的文档:

Tha Dhi Thom Num ThaKaThaRiKiTaThaKa 
ThaKaThaRiKiTaThaKa = Ta Tha Chap Tha Ki Ta Tha Ka

我已经将语法定义如下:

@start = expr;

expr = singleExpr+ phraseDictionary*;

singleExpr = aksharaGroup;

phraseDictionary = phrase '='! aksharaGroup;

phrase = Word;

aksharaGroup = akshara+ ('/'! noteDuration)?;

akshara = tha | dhi | thom | num | ki | ta | ka | chap | phrase;

noteDuration = Number;

tha = 'Tha';
dhi = 'Dhi';
thom = 'Thom';
num = 'Num';
ki = 'Ki';
ta = 'Ta';
ka = 'Ka';
chap = 'Chap';

我遇到问题的部分是短语字典 - 第二个 ThaKaThaRiKiTaThaKa 被解析为短语,akshara 和 aksharaGroup,正如预期的那样,但是我得到了我希望它匹配它的异常短语字典

Expected : /
Line : 2
Near : = Ta 
Found : =

Expected : Uppercase Word
Line : 2
Near : = Ta 
Found : =

Expected : «EOF»
Line : 2
Near : = Ta 
Found : =

使用 ParseKit 的无限前瞻,它不应该继续并匹配短语字典语法吗?

我错过了什么?

谢谢, 斯里达尔

4

1 回答 1

0

ParseKit的开发者在这里。

你的语法对我有用,ParseKit 负责谷歌代码的主干。

这是解析的 PKAssembly 输出:

[Tha, Dhi, Thom, Num, ThaKaThaRiKiTaThaKa, ThaKaThaRiKiTaThaKa, Ta, Tha, Chap, Tha, Ki, Ta, Tha, Ka]Tha/Dhi/Thom/Num/ThaKaThaRiKiTaThaKa/ThaKaThaRiKiTaThaKa/=/Ta/Tha/Chap/Tha/Ki/Ta/Tha/Ka^

堆栈(在方括号内)和末尾的插入符号表明从您的语法生成的解析器能够成功地识别您的输入直到最后。

于 2013-10-24T04:39:45.740 回答