Concepts Of Programming Languages
12th Edition
ISBN: 9780134997186
Author: Sebesta, Robert W.
Publisher: Pearson,
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 6PS
Explanation of Solution
BNF description of the Boolean expressions of Java:
The BNF description for java Boolean expression will be:
<Boolean_expr> -> <Boolean_expression> || <Boolean_term> | <Boolean_term>
<Boolean tee -> <Boolean_term> && <Boolean_factor> | <Boolean_factor>
<Boolean_factor> -> id | ! <Boolean_factor> | ( <Boolean expr> ) ...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Using the following grammar, show a parse tree and a leftmost derivation for the statement A = A * (B + (C * A))
<assign> → <id> = <expr>
<id> → A | B | C
<expr> → <id> + <expr>
| <id> * <expr>
| ( <expr> )
| <id>
Given the following grammar, and right sentential form, draw a parse tree and show the phrases and simple phrases as well as the handle
for the strings a, b, and c below.
Grammar
A->aAb | bBA
A->ab | aAB
B->aB | b
a) aaAbb
b) bBab
c) aaAbBb
Consider the following grammar
E → E + T | T
T → T * F | F
F → ( E ) | id
Show the derivation of the string (3 + 4) * (5 + 6)
Construct labeled Parse Tree for the derivation performed in 1)
Chapter 3 Solutions
Concepts Of Programming Languages
Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - What is the difference between a synthesized and...
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - Prob. 17RQCh. 3 - Prob. 18RQCh. 3 - Prob. 19RQCh. 3 - Prob. 20RQCh. 3 - Prob. 21RQCh. 3 - What does partial correctness mean for a loop...Ch. 3 - Prob. 23RQCh. 3 - Prob. 24RQCh. 3 - Prob. 25RQCh. 3 - Prob. 26RQCh. 3 - Prob. 27RQCh. 3 - Prob. 28RQCh. 3 - Prob. 29RQCh. 3 - The two mathematical models for language...Ch. 3 - Write EBNF descriptions for the following: a. A...Ch. 3 - Prob. 3PSCh. 3 - Prob. 4PSCh. 3 - Prob. 5PSCh. 3 - Prob. 6PSCh. 3 - Prob. 9PSCh. 3 - Prob. 10PSCh. 3 - Prob. 12PSCh. 3 - Prob. 15PSCh. 3 - Prob. 16PSCh. 3 - Prob. 17PSCh. 3 - Prob. 18PSCh. 3 - Compute the weakest precondition for each of the...
Knowledge Booster
Similar questions
- for the grammars below, determine if they're ambiguous; and if a grammar is ambiguous, find a string that demonstrates the ambiguity and also draw two different parse trees for the string: a) S → aSa | bSb | cSc | a | b | c | ε b) S → ε | ab | ba | aSb | bSa c) S → aSb | C C → ε | c | Ccarrow_forwarda) Write a grammar for parsing the string a=b/(c–d)*(x+y).b) Now perform a Left-most derivation for the string.c) Draw a parse tree for the string.d) Is the grammar ambiguous? Motivate your answer.arrow_forwardGive the derivation tree for ((a+b)∗c+d, using the grammar in Example 5.12. EXAMPLE 5.12 To rewrite the grammar in Example 5.11 we introduce new variables, taking V as {E, T, F, I}, and replacing the productions with E→T,T→F,F→I,E→E+T,T→T*F,F→(E),I→a|b|c.E→T,T→F,F→I,E→E+T,T→T*F,F→(E),I→a|b|c. A derivation tree of the sentence a + b ∗ c is shown in Figure 5.6. No other derivation tree is possible for this string: The grammar is unambiguous. It is also equivalent to the grammar in Example 5.11. It is not too hard to justify these claims in this specific instance, but, in general, the questions of whether a given context-free grammar is ambiguous or whether two given context-free grammars are equivalent are very difficult to answer. In fact, we will later show that there are no general algorithms by which these questions can always be resolved.arrow_forward
- Consider the following grammar then answer the questions below: S -> statements S -> repeat statements while condition S -> repeat statements until condition Is the above grammar LL (1) grammar? If not, mention why? And convert it into LL(1).arrow_forwardfor the grammar below, determine if the grammar is ambiguous; and if the grammar is ambiguous, find a string that demonstrates the ambiguity and also draw two different parse trees for the string: S → ε | ab | ba | aSb | bSaarrow_forwardComputer Science Consider the following two grammars with alphabet a and b i. (b*ab*a)*b* ii. (b*ab*a)*b*(b*ab*a)*b* Are there any strings are generated by one of the grammars and cannot be generated by the other? If there are more than one such string, how do you describe them.arrow_forward
- In Example 6.1, show a derivation tree for the string ababbac, using both the original and the modified grammar. EXAMPLE 6.1 Consider G = ({A, B}, {a, b, c}, A, P) with productions A→a|aaA|abBc,B→abbA|b.A→a|aaA|abBc,B→abbA|b. Using the suggested substitution for the variable B, we get the grammar Ĝ with productions A→a|aaA|ababbAc|abbc,B→abbA|b.A→a|aaA|ababbAc|abbc,B→abbA|b. The new grammar Ĝ is equivalent to G. The string aaabbc has the derivation A ⇒ aaA ⇒ aaabBc ⇒ aaabbc in G, and the corresponding derivation A ⇒ aaA ⇒ aaabbc in Ĝ. Notice that, in this case, the variable B and its associated productions are still in the grammar even though they can no longer play a part in any derivation. We will next show how such unnecessary productions can be removed from a grammar.arrow_forwardWhat is the purpose of normalization? Construct the CNF and GNF for the following grammar and explain the steps. S→aAa | bBb |€ A→C|a B→C|b C→CDE | € D→A|B|ab.arrow_forwardConsider the grammar with production → 01|01 and string 000111. (i) Given a leftmost derivation for the string. (ii) Give a rightmost derivation for the string. (iii) Give a parse tree for the strings generated. (iv) Is the grammar ambiguous or unambiguous? Justify your answerarrow_forward
- Some of the following grammars may be ambiguous; for each ambiguous gram- mar, show two different derivation trees for the same input string: (d) 1. S → a S b c S → A B А -> а B -> barrow_forwardPlease Solve the below question as well.1. Given Grammar-S -> 0B | SA A -> 0 | OS | 1AA B -> 1 | 1S | 0BB a)Find the left most Derivation(LMD) and Right most Derivation(RMD) b) Find the Derivation tree for LMD and RMDarrow_forwardGiven the following BNF grammar <go> → <go>@<good> <go> → start | finish <good> → . <good> | up | down Write the derivation and draw the parse trees of the following sentences: start@down@.uparrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education