主题:在使用java_cup时候遇到的问题出现移进规约冲突
package wren;
import java_cup.runtime.*;
/* Preliminaries to set up and use the scanner. */
init with {: scanner.init(); :};
scan with {: return scanner.next_token(); :};
/* Terminals (tokens returned by the scanner). */
terminal COLON,ASSIGN,UMINUS,RELATION,LPAREN,RPAREN,COMMA,SEMI,weak_op,strong_op;
terminal numeral,integer,boolean,ident;
terminal program,is,begin,end,var,skip,read,write,while,do,if,then,else,or,and,true,false,not;
/* Non-terminals */
non terminal programs,block,decl_seq,declaration,type,variable_list,command_seq,command,expr,integer_expr,term,element,bool_expr,bool_term,bool_element,comparison,variable;
programs ::=program:kw1
{: System.out.print(kw1); :}
ident:id
{: System.out.print(" "+id); :}
is:kw2
{: System.out.print(" "+kw2+" "); :}
block;
block ::=decl_seq
begin:kw1
{: System.out.print(kw1); :}
command_seq
end
{: System.out.print(" "+kw2); :};
decl_seq ::=
|declaration decl_seq;
declaration ::= var:kw1
{: System.out.print(kw1); :}
variable_list
COLON:c1
{: System.out.print(c1); :}
type
SEMI:s1
{: System.out.print(s1); :};
type ::=integer:kw1
{: System.out.print(kw1); :}
|boolean:kw2
{: System.out.print(kw2); :};
variable_list ::=variable
|variable
COMMA:c1
{: System.out.print(c1); :}
variable_list;
variable ::=ident:id
{: System.out.print(id); :};
command_seq ::=command
|command
SEMI:s1
{: System.out.print(s1); :}
command_seq;
command ::=variable
ASSIGN:a1
{: System.out.print(a1); :}
|skip:kw1
{: System.out.print(kw1); :}
|read:kw2
{: System.out.print(kw2); :}
variable
|write:kw3
{: System.out.print(kw3); :}
integer_expr
|while:kw4
{: System.out.print(kw4); :}
bool_expr
do:kw5
{: System.out.print(" "+kw5); :}
command_seq
end :kw6
{: System.out.print(" "+kw6); :}
while:kw14
{: System.out.print(" "+kw14; :}
|if:kw7
{: System.out.print(kw7); :}
then:kw8
{: System.out.print(" "+kw8+" "); :}
command_seq
end:kw15
{: System.out.print(" "+kw15; :}
if:kw17
{: System.out.print(" "+kw17; ;}
|if:kw10
{: System.out.print(kw10); :}
then:kw11
{: System.out.print(" "+kw11+" "); :}
command_seq
else:kw12
{: System.out.print(" "+kw12+" "); :}
end:kw16
{: System.out.print(" "+kw16; :}
else:kw13
{: System.out.print(kw13); :};
expr ::=integer_expr |bool_expr;
integer_expr ::=term
|integer_expr weak_op term;
term ::=element
|term
strong_op:kw1
{: System.out.print(kw1); :}
element;
element ::=numeral:n1
{: System.out.print(n1); :}
|variable
|LPAREN:s1
{: System.out.print(s1); :}
integer_expr
RPAREN:s2
{: System.out.print(s2); :}
|UMINUS:s3
{: System.out.print(s3); :}
element;
bool_expr ::=bool_term
|bool_expr
or:kw1
{: System.out.print(kw1); :}
bool_term;
bool_term ::=bool_element
|bool_term
and:kw2
{: System.out.print(kw2); :}
bool_element;
bool_element ::=true:kw1
{: System.out.print(kw1); :}
|false:kw2
{: System.out.print(kw2); :}
|variable
|comparison
|not:kw3
{: System.out.print(kw3); :}
LPAREN:s1
{: System.out.print(s1); :}
bool_expr
RPAREN:s2
{: System.out.print(s2); :}
|LPAREN:s3
{: System.out.print(s3); :}
bool_expr
RPAREN:s4
{: System.out.print(s4); :};
comparison ::=integer_expr
RELATION:s1
{: System.out.print(s1); :}
integer_expr;
variable ::=ident;
出现冲突的是
comparison ::=integer_expr
RELATION:s1
{: System.out.print(s1); :}
integer_expr;
请问怎么修改好呢?
import java_cup.runtime.*;
/* Preliminaries to set up and use the scanner. */
init with {: scanner.init(); :};
scan with {: return scanner.next_token(); :};
/* Terminals (tokens returned by the scanner). */
terminal COLON,ASSIGN,UMINUS,RELATION,LPAREN,RPAREN,COMMA,SEMI,weak_op,strong_op;
terminal numeral,integer,boolean,ident;
terminal program,is,begin,end,var,skip,read,write,while,do,if,then,else,or,and,true,false,not;
/* Non-terminals */
non terminal programs,block,decl_seq,declaration,type,variable_list,command_seq,command,expr,integer_expr,term,element,bool_expr,bool_term,bool_element,comparison,variable;
programs ::=program:kw1
{: System.out.print(kw1); :}
ident:id
{: System.out.print(" "+id); :}
is:kw2
{: System.out.print(" "+kw2+" "); :}
block;
block ::=decl_seq
begin:kw1
{: System.out.print(kw1); :}
command_seq
end
{: System.out.print(" "+kw2); :};
decl_seq ::=
|declaration decl_seq;
declaration ::= var:kw1
{: System.out.print(kw1); :}
variable_list
COLON:c1
{: System.out.print(c1); :}
type
SEMI:s1
{: System.out.print(s1); :};
type ::=integer:kw1
{: System.out.print(kw1); :}
|boolean:kw2
{: System.out.print(kw2); :};
variable_list ::=variable
|variable
COMMA:c1
{: System.out.print(c1); :}
variable_list;
variable ::=ident:id
{: System.out.print(id); :};
command_seq ::=command
|command
SEMI:s1
{: System.out.print(s1); :}
command_seq;
command ::=variable
ASSIGN:a1
{: System.out.print(a1); :}
|skip:kw1
{: System.out.print(kw1); :}
|read:kw2
{: System.out.print(kw2); :}
variable
|write:kw3
{: System.out.print(kw3); :}
integer_expr
|while:kw4
{: System.out.print(kw4); :}
bool_expr
do:kw5
{: System.out.print(" "+kw5); :}
command_seq
end :kw6
{: System.out.print(" "+kw6); :}
while:kw14
{: System.out.print(" "+kw14; :}
|if:kw7
{: System.out.print(kw7); :}
then:kw8
{: System.out.print(" "+kw8+" "); :}
command_seq
end:kw15
{: System.out.print(" "+kw15; :}
if:kw17
{: System.out.print(" "+kw17; ;}
|if:kw10
{: System.out.print(kw10); :}
then:kw11
{: System.out.print(" "+kw11+" "); :}
command_seq
else:kw12
{: System.out.print(" "+kw12+" "); :}
end:kw16
{: System.out.print(" "+kw16; :}
else:kw13
{: System.out.print(kw13); :};
expr ::=integer_expr |bool_expr;
integer_expr ::=term
|integer_expr weak_op term;
term ::=element
|term
strong_op:kw1
{: System.out.print(kw1); :}
element;
element ::=numeral:n1
{: System.out.print(n1); :}
|variable
|LPAREN:s1
{: System.out.print(s1); :}
integer_expr
RPAREN:s2
{: System.out.print(s2); :}
|UMINUS:s3
{: System.out.print(s3); :}
element;
bool_expr ::=bool_term
|bool_expr
or:kw1
{: System.out.print(kw1); :}
bool_term;
bool_term ::=bool_element
|bool_term
and:kw2
{: System.out.print(kw2); :}
bool_element;
bool_element ::=true:kw1
{: System.out.print(kw1); :}
|false:kw2
{: System.out.print(kw2); :}
|variable
|comparison
|not:kw3
{: System.out.print(kw3); :}
LPAREN:s1
{: System.out.print(s1); :}
bool_expr
RPAREN:s2
{: System.out.print(s2); :}
|LPAREN:s3
{: System.out.print(s3); :}
bool_expr
RPAREN:s4
{: System.out.print(s4); :};
comparison ::=integer_expr
RELATION:s1
{: System.out.print(s1); :}
integer_expr;
variable ::=ident;
出现冲突的是
comparison ::=integer_expr
RELATION:s1
{: System.out.print(s1); :}
integer_expr;
请问怎么修改好呢?