正在加载图片...
Operator Associativity and Precedence To resolve some of the ambiguity with grammars that have operators we use: -Operator associativity:-in most programming languages arithmetic operators have left associativity. -E.g.9+5-2=(9+5)-2 However has right associativity,i.e.a=b=c is equivalent to a=(b=c) - Operator Precedence:-if an operator has higher precedence,then it will bind to it's operands first. eg.has higher precedence then +therefore 9+5*2 is equivalent to 9+(5*2) CS308 Compiler TheoryOperator Associativity and Precedence • To resolve some of the ambiguity with grammars that have operators we use: – Operator associativity :- in most programming languages arithmetic operators have left associativit y. – E.g. 9+5-2 = (9+5)-2 – However = has right associativity, i.e. a=b=c is equivalent to a=(b=c) – Operator Precedence :- if an operator has higher precedence, then it will bind to it’s operand fi t srs t. – eg. * has higher precedence then +, therefore 9+5*2 is equivalent to 9+(5*2) CS308 Compiler Theory 13
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有