Design a language description for which a BNF/EBNF based grammar cannot be written. Prove that the grammar cannot be written for the description.
The EBNF is the most commonly used formalism to describe the structure of languages.
What is the EBNF?
The EBNF is a way to specify a formal language grammar. It can be
considered a metalanguage because it is a language to describe
other languages.
A formal language is a language with a precise structure, like
programming languages, data languages, or Domain Specific Languages
(DSLs). Java, XML, and CSS are all examples of formal
languages.
A grammar can be used to define two opposite things:
how to recognize the different portions in a piece of code written
in the formal language
the possible ways to build a valid piece of code in the formal
language
For example, a simple grammar could tell us that a document in our
language is composed by a list of declarations, and declarations
are defined by the sequence of a keyword Xyz and a a name.
Based on this we could:
recognize in the code sequences of the keyword Xyz and a name as
instances of these declarations we have considered
we could generate valid documents in our language by writing a list
of declarations, each time inserting a keyword Xyz and a name
While there are two possible usages for a grammar, we are typically
interested only in the first one: recognizing if a piece of code is
valid for a given language and identifying the different structures
typical of the language (like functions, methods, classes,
etc.).
Design a language description for which a BNF/EBNF based grammar cannot be written. Prove that the...
Please answer the questions below: 7. Rewrite the following BNF grammar using the form of EBNF described on the bottom half of page 127 in Sebesta. <import_decl> → import <import_list> ; <import_list> → <package_list> | <package_list> . * <package_list> → <identifier> | <package_list> . <identifier> <identifier> → a | b | c Make the resulting grammar as simple as possible, but keep all four of the original nonterminals, which will now be named ImportDecl, ImportList, PackageList, and Identifier. (Note: There...
Q3. Convert the following recursive BNF grammar to EBNF: (20%) <assign>-> <id> = <expr> <expr> -> <d>+ <expr> | <id> * <expr> 1 (<expr>) | <i>
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) → |
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>
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 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...
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...
2. Prove that the following grammar is ambiguous: S → SS(S) la 3. Convert the following EBNF rule taken from Pascal standard to ordinary BNF. Na.. nad h an .le and ond bitd.. ..
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> →
16. A grammar can be expressed in BNF notation. There are two types of symbols in BNF expressions. Non-terminal symbols are typically A. Abstract concepts that need to be further defined B. The symbols that would appear in a grammar file C. The symbols that would appear in a source code file D. Metasymbols that are used by BNF grammar types to help describe rules 17. Which of the following scripting languages is a pure object-oriented language: A.. Ruby B....