Bison specification and precedence order

大兔子大兔子 提交于 2019-12-23 20:38:29

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/26458080/bison-specification-and-precedence-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!