簡體   English   中英

當ParseKit嘗試識別我的語法時,它將進入無限循環。 怎么了?

[英]When ParseKit tries to recognize my Grammar, it enters an infinite loop. What's wrong?

嗨,我正在為使用遞歸的某些公式創建語法。 該公式要復雜得多,但是現在我只測試其中的一部分。 調用parse方法后,它在allMatchesFor方法上崩潰。 堆棧跟蹤充滿了allMatchesFor調用,因此看起來好像處於無限循環中。問題出在哪里。 是在我的語法構造邏輯中嗎? 我如何完成類似的事情來避免此崩潰

我的語法像:

@start = formula;
formula = valueTypeResult;
valueTypeResult = (value | concept | arithmeticStatement);
arithmeticStatement = valueTypeResult (arithmeticOperator valueTypeResult)+;
value = 'V';
concept = 'C';
arithmeticOperator = 'A';

您能告訴我如何創建使用遞歸的語法嗎?

謝謝

這里是ParseKit的開發人員。

ParseKit的遞歸沒有問題,但是您的語法不正確。 這比ParseKit問題更多是BNF語法問題。

這是我認為上面的語法嘗試的正確版本:

@start = formula;
formula = arithmeticStatement;
arithmeticStatement = valueTypeResult (arithmeticOperator valueTypeResult)+;
valueTypeResult = (value | concept);
value = 'V';
concept = 'C';
arithmeticOperator = 'A';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM