Bison specification and precedence order

2019-07-03 22:08发布

Given Bison Specification: %right TOK_ADD TOK_MUL

I was wondering what would be the precedence order of TOK_ADD and TOK_MUL.

Also in case i had Bison specification

%left TOKMUL TOKADD
%left TOKDIV
%left TOKSUB

I was wondering what would the precedence order of TOKMUL TOKADD TOKDIV and TOKSUB be

标签: c bison
1条回答
Explosion°爆炸
2楼-- · 2019-07-03 22:28

bison/yacc precedence order is lowest to highest -- the tokens on the first line listed have the lowest precedence while those on the last have the highest. Multiple tokens on the same line (TOKMUL and TOKADD in your case) have the same precedence

查看更多
登录 后发表回答