this bison parser code.
statement : compound_statement | expression_statement ; expression_statement : ';' | expression ';' {cout<<"expr found\n";} ; expression : number_expression {cout << "number expression\n";} ; number_expression : number_arith_expression {cout << "arith expression\n";} ; number_arith_expression : number_idenfiers | number_constants | number_arith_expression number_arith_expression '+' { cout<<"found\n";} | number_arith_expression number_arith_expression '-' {} ; number_idenfiers : ppnumvar {} | ppsysnumvar {} ; number_constants : ppfloat {} ;
i gave expression
23 23 +;
my result :
found
arith expression
number expression
line number : 1 .. parse error
why doesn't parse @ expression_statment ? doesn't parse semicolon. should change work semicolon?
according grammar valid addition expression 2 expressions followed +
, input has +
in middle.
Comments
Post a Comment