Question

4. Assume the following rules of associativity and precedence for expressions: Precedence Highest *, /, not...

4. Assume the following rules of associativity and precedence for expressions:

Precedence

Highest

*, /, not

+,-,&, mod

- (unary)

=,/=,<,<=,>=,>

and

or, xor

Lowest

Associativity Left to right

Show the order of evaluation of the following expressions by parenthesizing all sub expressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression

a+b*c+d

the order of evaluation would be represented as

((a+(b*c)1)2 +d)3

  1. a * b - 1 + c

  2. a * (b - 1) / c mod d

  3. (a - b) / c & (d * e / a - 3)

  4. -a or c = d and e

  5. a > b xor c or d <= 17

  6. -a + b

5. Write a BNF description of the precedence and associativity rule defined for the expressions in Problem 4. Assume the only operands are the names a, b, c, d, and e.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution

(((a * b)1– 1)2 + c)3

---

(((a*(b – 1)1)2/c)3mod d)4

---

(((a – b)1/c)2& (((d * e)3/a )4– 3)5)6

----

(((a – b)1/c)2& (((d * e)3/a )4– 3)5)6

---

((a > b)1xor (c or (d <= 17)2)3)4

---

(– (a + b)1)2

---

Answered first part of the question completely

really sorry couldnt able to answer the remaining

all the best

Add a comment
Know the answer?
Add Answer to:
4. Assume the following rules of associativity and precedence for expressions: Precedence Highest *, /, not...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assume the following rules of associativity and precedence for expressions: Precedence   Highest   *, /, not   +,...

    Assume the following rules of associativity and precedence for expressions: Precedence   Highest   *, /, not   +, -, &, mod   - (unary)   =, /=, <, <=, >=, >   and   Lowest   or, xor Associativity   Left to right Show the order of evaluation of the following expressions by parenthesizing all subexpressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression a + b * c + d the order of evaluation would be represented as ((a...

  • 1. Write a BNF description of the logical expressions and the relational expressions in C++. Make...

    1. Write a BNF description of the logical expressions and the relational expressions in C++. Make sure that the BNF reflects the order of precedence of the operators, as well as, the associativity rules. 2. Using the BNF rules in 1., give a rightmost derivation and show a parse tree for the expression below. 3. Prove that the following grammar is ambiguous and rewrite the grammar to remove ambiguity «newexp> → «newexp> @ <newexp> ulvl w I <other> <other> →

  • Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the...

    Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.

  • Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the...

    Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.

  • This BNF grammar defines expressions with three operations, *, -, and +, and the variables “a”, “b”, “c”, and “d”. <e...

    This BNF grammar defines expressions with three operations, *, -, and +, and the variables “a”, “b”, “c”, and “d”. <expr> ::= <thing> | <thing> * <expr> <object> ::= <element> | <element> – <object> <thing> ::= <object> | <thing> + <object> <element> ::= a|b|c|d|(<object>) a) Give the order of precedence among the three operations. b) Give the order (left-to-right or right-to-left) of execution for each operation. c) Explain how the parentheses defined for the nonterminal <element> may be used in...

  • Q#2 (6 points) Assume following precedence levels 1. parentheses 2. unary operators 3. **(exponentiation: if the...

    Q#2 (6 points) Assume following precedence levels 1. parentheses 2. unary operators 3. **(exponentiation: if the language supports it) 6. Relational operators 7. Conditional operators 8. Boolean operators Determine the value of the following expressions, assuming a 5, b 2, c 4 and d-5. a. a5 Answer: Answer: Answer: c. b* a-b*c)

  • EVALUATING GENERAL INFIX EXPRESSIONS INTRODUCTION The notation in which we usually write arithmetic expressions is called infix notation;...

    EVALUATING GENERAL INFIX EXPRESSIONS INTRODUCTION The notation in which we usually write arithmetic expressions is called infix notation; in it, operators are written between their operands: X + Y. Such expressions can be ambiguous; do we add or multiply first in the expression 5 + 3 * 2? Parentheses and rules of precedence and association clarify such ambiguities: multiplication and division take precedence over addition and subtraction, and operators associate from left to right. This project implements and exercises a stack-based algorithm that evaluates...

  • 1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming...

    1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta? a. Increased capacity to express ideas. b. Improved background for choosing appropriate languages. c. Increased ability to design new languages. d. Increased ability to learn new languages. 2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years? a. FORTRAN b. ALGOL c. SNOBOL d. PL/I 3. (p. 6.) What programming language has dominated artificial intelligence...

  • Stacks are used by compilers to help in the process of evaluating expressions and generating machine...

    Stacks are used by compilers to help in the process of evaluating expressions and generating machine language code.In this exercise, we investigate how compilers evaluate arithmetic expressions consisting only of constants, operators and parentheses. Humans generally write expressions like 3 + 4and 7 / 9in which the operator (+ or / here) is written between its operands—this is called infix notation. Computers “prefer” postfix notation in which the operator is written to the right of its two operands. The preceding...

  • Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instru...

    Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instructions of the program: java code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * */ import java.util.Random; public class Rand_Z3_Exp { /** * @param args the command line arguments */ public static void main(String[] args) {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT