Concepts of Programming language
Convert the following BNF to EBNF
<STMT_LIST> -> <stmt> | <stmt>; <stmt_list>
<stmt> -> <var> = <expr>
<var> -> A | B | C
<EXPR> -> <var> + <var> | <var> - <var> | <var>
STMT_LIST, '->', stmt, '|', stmt, ';'stmt_list;
stmt, '->', var = expr
var, '->', A, '|', B, '|', C
EXPR, '->', var, '+', var, '|', var, '-', var, '|', var
Concepts of Programming language Convert the following BNF to EBNF <STMT_LIST> -> <stmt> | <stmt>; <stmt_list>...
Concepts of Programming language Convert the following BNF to EBNF <STMT_LIST> -> <stmt> | <stmt>; <stmt_list> <stmt> -> <var> = <expr> <var> -> A | B | C <EXPR> -> <var> + <var> | <var> - <var> | <var>
Q3. Convert the following recursive BNF grammar to EBNF: (20%) <assign>-> <id> = <expr> <expr> -> <d>+ <expr> | <id> * <expr> 1 (<expr>) | <i>
Given a CFG in BNF, (50 points) <stmt_list> → <stmt> | <stmt>; <stmt_list> <stmt> → <var> = <expr> <expr> → <var> + <expr> | <var> * <expr> | <var> <var> →a| b| c| d show a derivation for the given sentence a = b*c - d; b = d - a 2. show a parsing tree for a = b*c - d; b = d - a
P2) Given grammar in BNF, answer the following questions (30 points) <stmt-list>→<stmt> | <stmt»; <stmt-list> (a) Rewrite the given grammar into a EBNF (b) Is the given grammar ambiguous? Support your answer to receive the full credit. (c) Given string A-B C-D: B-C-A-D, draw a parsing tree
P2) Given grammar in BNF, answer the following questions (30 points) → |
(20 pts) To understand the value of recursion in a programming language: implement the binary search algorithm first as a recursive function and again using a conditional loop. Your program should create an array of characters holding the letters ‘A’ – ‘Z’ and find the index in the array where the letter ‘K’ is stored. You may use any programming language that supports recursion. (5pts) Define syntax and semantics and give an example. (5pts) Why is it important for a...
Design a language description for which a BNF/EBNF based grammar cannot be written. Prove that the grammar cannot be written for the description.
Given grammar: <program> --> <stmts> <stmts> --> <stmt> | <stmt> ; <stmts> <stmt> --> <var> = <expr> <var> --> a | b | c | d <expr> --> <term> + <term> | <term> - <term> <term> --> <var> | const Write down the parse tree and left most derivation of: c = a + c
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 =
Augment the following BNF to write an attribute grammar. Assume the only possible variable types are integer and float. The language rules are as follows: 1) The types of variables in an expression do not have to be the same. The type of the expression result is that of the first (or leftmost) variable in the expression. 2) If the type of variable to be assigned is integer, the type of the expression must be integer. 3) If the type...
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...