1
這已經是在互聯網上某個着名的例子之一,但我似乎無法找到它。xtext:expression/factor/term grammar
我想學習XText,我覺得計算器表達式解析器會是一個好的開始。但我發現了語法錯誤在我的語法:
Expression:
Term (('+'|'-') Term)*;
Term:
Factor (('*'|'/') Factor)*;
Factor:
number=Number | variable=ID | ('(' expression=Expression ')');
我在表達和期限線得到這個錯誤:
Multiple markers at this line
- Cannot change type twice within a rule
- An unassigned rule call is not allowed, when the 'current'
was already created.
是怎麼回事?我怎樣才能解決這個問題?我什麼時候在文法中有instanceName=Rule
與Rule
條目?
這非常有幫助!你能否指引我參考一下描述這個'{Plus.left = current}'語法的含義? – 2012-02-25 17:11:51
我真的不知道,我以前從未真正嘗試過xtext。但它在我看來它生成一個名爲'Plus'的接口,它構建了分析樹。 .left將當前令牌與顯然分配的操作的左側部分相關聯:http://www.eclipse.org/Xtext/documentation/2_0_0/020-grammar-language.php#syntax – Dervall 2012-02-25 17:19:56