c. (3/-2) +3 =
d. 5++3 =
These two sentences are present in the language generated by this grammer
Proof:
C. (3/-2)+3 =
<calculation> -> <expr> =
<term> + <expr> =
<factor>+<expr>=
(<expr>)+<expr>=
(<term>)+<expr>=
(<factor> / <term>)+<expr>=
(<factor> / <factor>)+<expr>=
(<factor> / <term>)+<term>=
(<factor> / <factor>)+<factor>=
(<value> / <value>)+<value>=
(<unsigned> / [<sign>]<unsigned>)+<unsigned>=
(<digit> / [<sign>]<digit>)+<digit>=
(3 / [<sign>]2)+3=
(3 / -2)+3=
Derived
D. 5++3=
<calculation> -> <expr> =
<term> + <expr> =
<term> + <term> =
<factor> + <factor> =
<value> + <value> =
<unsigned> + <sign><unsigned> =
<digit> + <sign><digit> =
5 + <sign>3 =
5 + +3 =
Derived
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 → 011121314151617189 <sign → + - which of the following sentences is in the language generated by this grammar? Whx.2 a. 3/+2.5 = b. 5- *3/4= c. (3/-2) + 3 = d. 5++3 =
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]...
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 | 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...
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...
(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...
Question 3. (5 points) What is the language recognized by the following grammar? You can either give the set representation of the language or describe the set in English. The starting symbol is S.
The question involves two parts and is for a compiler design course. See the image below for the question. It may help if you have used a tool called ANTLR and know about grammar files. Answer part 1 and part 2 correctly and I will give a positive rating. Thank you. Part 1: In BDL (badly designed language), the equal sign is the assignment operator. The language allows multiple assignments such as i -j k which first assigns the value...
3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...
Question 1 Consider the following BNF grammar: Not complete Marked out of 3.00 p Flag question <letter> ::= "a" | "b" | "C" | "d" | "e" | "F" | "g" | "h" | "1" ";" | "K" | "1" | "m" | "n" | "0" | "p" | "q" | "r" | "S" | "t" || "u" | "V" | "W" | "x" | "y" | "z" <digit> ::= "O" | "1" | "2" | "3" | "4" |...