YACC文法は紛争を減らします/減少させる
-
11-12-2019 - |
質問
XMLファイルの有効性を確認するための次の文法があり、ファイルは要素、次にルートノードで起動します。
program
: terminal_node
root
;
root
: '<' ID attribute_list '>' node_list '<' ID '/''>'
;
node_list
: node
| node node_list
;
node
: terminal_node
: nonterminal_node
;
terminal_node
: '<' ID attribute_list '/''>'
;
nonterminal_node
: '<' ID attribute_list '>' node_list '<' ID '/''>'
;
attribute_list
: attribute
| attribute attribute_list
;
attribute
: ID ASSIGNOP '"' ID '"'
| ID ASSIGNOP '"' NUM '"'
;
.
紛争を減らし/減らすことを取得しています、そして私はそれを見つける方法がわかりません。あらゆる助けが高くなるでしょう。
解決
This looks a bit strange for an XML grammar. Are you sure you don't want empty node_list
s or attribute_list
s?
Anyway, try this:
node_list
: node
| node_list node /* list first, element second, this is the LALR way */
;
node
: terminal_node
| nonterminal_node /* note a typo in your code here */
;
所属していません StackOverflow