这是我要解析的文档:
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的无限前瞻,它不应该继续并匹配phraseDictionary语法吗?
我错过了什么?
谢谢, 斯里达尔
答案 0 :(得分: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^
堆栈(方括号内)和末尾的插入符号表示从语法生成的解析器能够成功识别您的输入一直到最后。