Question

Question 9 (10 points) Consider the following EBNF grammar for a Calculator Language: <calculation> <expr> = <expr> > <term
0 0
Add a comment Improve this question Transcribed image text
Answer #1

c) (31-2) +3= wlanation: parse tree com be for generated (31-2) + 3 = <calculation> Lexprs - <terms & (expos factor Storms (f

Add a comment
Know the answer?
Add Answer to:
Question 9 (10 points) Consider the following EBNF grammar for a "Calculator Language": <calculation> <expr> =...
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
  • Question 9 (10 points) Consider the following EBNF grammar for a “Calculator Language": <calculation> → <expr>=...

    Question 9 (10 points) Consider the following EBNF grammar for a “Calculator Language": <calculation> → <expr>= <expr> <term> (+1-) <expr> <term> <term> <factor> (* ) <term> <factor> <factor> → (<expr>) <value> <value> → [<sign> ] <unsigned> [. <unsigned> ] <unsigned> <digit> { <digit> } <digit> → 01|2|3|4|567| 8 | 9 <sign> → +|- which of the following sentences is in the language generated by this grammar ? Why? a. 3/+2.5 = b. 5-*3/4= c. (3/-2) + 3 = d. 5...

  • Q3. Convert the following recursive BNF grammar to EBNF: (20%) <assign>-> <id> = <expr> <expr> ->...

    Q3. Convert the following recursive BNF grammar to EBNF: (20%) <assign>-> <id> = <expr> <expr> -> <d>+ <expr> | <id> * <expr> 1 (<expr>) | <i>

  • Question 3: Given the following grammar: assign → id := expr expr → expr + term \ term term -term *factor lfactor factor-(expr) id Using the above grammar, show a leftmost derivation (first five step...

    Question 3: Given the following grammar: assign → id := expr expr → expr + term \ term term -term *factor lfactor factor-(expr) id Using the above grammar, show a leftmost derivation (first five steps) for the following assignment statement: A ((A B)+ C) a. [3 marks] b. Using the above grammar, show a rightmost derivation (first five steps) for the following assignment statement: A:-A+B+C)+A [3 marks] Draw the abstract syntax tree for each of the above statements [4 marks]...

  • Considering the following BNF grammar, answer the questions. <prog> - <assign> | <expr> <assign> = <id>...

    Considering the following BNF grammar, answer the questions. <prog> - <assign> | <expr> <assign> = <id> = <expr> <expr> := <expr> + <term> | <expr> - <term> | <term> <term> := <factor> | <factor> * <term> <factor> ::= ( <expr> ) | <id> | <num> <id>::= ABC <num> := 0|1|2|3 2a - What is the associativity of the * operator? (5 points) 2b - For the * and + operators, do they have the same precedence, does the * operator...

  • 1.a    Consider  the following Grammar,                               

    1.a    Consider  the following Grammar,                                                                  <assign> à   <id> = <expr>     <id> à A | B |C    <expr> à < expr> + <expr>         | <expr> * <expr>                   | ( <expr> )                   | <id> Derive the following statement using leftmost derivation.   A = A * (B*(C+ A)) b. 2 a}.    Consider the following grammar that expresses parenthesized expressions of digits, including both addition and multiplication. <expr> := <expr> + <expr> | <expr> * <expr> | (expr>) | <digit> <digit> :=   0 | 1 | 2 |...

  • Consider the following BNF grammar that we saw in class:        EXP    ::= EXP + TERM  ...

    Consider the following BNF grammar that we saw in class:        EXP    ::= EXP + TERM   | EXP - TERM    | TERM        TERM   ::= TERM * FACTOR | TERM / FACTOR | FACTOR        FACTOR ::= ( EXP ) | DIGIT        DIGIT ::= 0 | 1 | 2 | 3    (a) Translate into EBNF.    (b) Draw syntax diagrams.    (c) What are the two requirements on a grammar for a predictive parser to be able to...

  • Consider the following grammar expr- term term_tail term_tail -add_op term term_tail | term - factor factor_tail...

    Consider the following grammar expr- term term_tail term_tail -add_op term term_tail | term - factor factor_tail factor_tail-mult_op factor factor _tail | factor -(expr) |id|literal add_op -+|- mult_op-*|/ Draw syntax tree for parsing each of cdf+(a25+84),(a25+84)*cdf,84*cdf+a25,a25+84*cdf,a25*84*cdf.Note that a25 and cdf are identifiers and 84 is a literal.You are not asked to do the tedious parsing process with stack snapshots.Instead you only need to draw sysntax trees,but you do need to do lexical analysis N.B: I need only lexical analysis for this...

  • 3. Consider the following grammar: expr term term tail term-tail-) add-op term term-ail 1 ε term ...

    3. Consider the following grammar: expr term term tail term-tail-) add-op term term-ail 1 ε term → factor factor-tail factor. tain ε factor (expr) id literal add-op → +1 Draw a syntax tree for parsing each of cdf + (a25 + 84), (a25 + 84)*cdf, 84*cdf+ a25, a25+84 cdf a25*84*cdf. Note that a25 and cdf are identifiers and 84 is a literal You are not asked to do the tedious parsing process with stack snapshots. Instead you only need to...

  • 1. Consider the following BNF definition of arithmetic expressions: <expression> <expression>+ <term> | <expression>-<term> <term> <term>...

    1. Consider the following BNF definition of arithmetic expressions: <expression> <expression>+ <term> | <expression>-<term> <term> <term> ::= <term>*<factor> <term>/<factor> | <factor> <factor> :: <digit>«<exponent> | <didgit>^«<exponent> <digit>(<expression> <digit>:= 01|2|3|4151617181910. <exponent> :: <sign> <val> <sign>=+1 - <val 1121314 Draw the expression trees of the following expressions, parsed according to the BNF above. a) 46 - 6/4-243. b) 4*6 -(6/4 - 243) c) 31-2-3*2 + 3/2 d) 3^2*5. e) ((3^2)).

  • (8) (3 marks) Write BNF grammar rules for a language that is comprised only of sentences described as follows: symbol,...

    (8) (3 marks) Write BNF grammar rules for a language that is comprised only of sentences described as follows: symbol, fol symbols orjust onéx symbol, A sequence of one or more occurrences of an a lowed by either zero or morez followed by a sequence of one or more b symbols. (9) (1 mark) The following fragment of grammar describes the syntax of the exponentiation operator. What is the associativity ot the operator as detined here? factor | expr factor...

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