Question

In: Computer Science

Can following BNF convert to CFG (Context Free Grammar) <Boolean_expr> → <Boolean_expr>||<Boolean_term>|<Boolean_term> <Boolean _term> → <Boolean...

Can following BNF convert to CFG (Context Free Grammar)

<Boolean_expr> → <Boolean_expr>||<Boolean_term>|<Boolean_term>
<Boolean _term> → <Boolean _term> && <Boolean _factor>| <Boolean _factor>
<Boolean _factor> →ID | !<Boolean _factor>| (<Boolean _factor>) |<relation_expr>
<relation_expr> → ID==ID | ID !=ID | ID < ID | ID≤ID | ID>ID | ID>=ID

The above BNF is for Boolean Expression and Relational Expression.

Solutions

Expert Solution

I have completed this problem Please give thumbs up if you like it

Step 1 what is CFG

Step 2

Given BNF grammar is

<Boolean_expr> → <Boolean_expr>||<Boolean_term>|<Boolean_term>
<Boolean _term> → <Boolean _term> && <Boolean _factor>| <Boolean _factor>
<Boolean _factor> →ID | !<Boolean _factor>| (<Boolean _factor>) |<relation_expr>
<relation_expr> → ID==ID | ID !=ID | ID < ID | ID≤ID | ID>ID | ID>=ID

The above BNF is for Boolean Expression and Relational Expression.

Step 3

Now convert this BNF into CNF form

This grammar is for both boolean expression and relational expression


Related Solutions

For each of the following grammars, first classify the grammar as Regular, Linear, Context-Free or Context-Sensitive,...
For each of the following grammars, first classify the grammar as Regular, Linear, Context-Free or Context-Sensitive, and then precisely describe the language generated by the grammar. (1) S → aRa R → aR | bR | є (2) S → A | B A → aaaA | є B → Bbb | b (3) S → RbR R → aRb | bRa | RR | bR | є (4)   S → aSbSaS | aSaSbS | bSaSaS | є    (5)...
What makes a deterministic context free grammar deterministic?
What makes a deterministic context free grammar deterministic?
Theory of Computation Problem Let G be an arbitrary CFG (Context-free Grammer), and let DG be...
Theory of Computation Problem Let G be an arbitrary CFG (Context-free Grammer), and let DG be the string-pushing PDA(pushdown automata) for it. Let w be some string of length n in L(G). Suppose you know that the leftmost derivation of w in G consists of m substitutions. How many transitions would be in the corresponding computation of DG for input string w? Justify your answer carefully.
Let G = (AN , AT , S, P) be a context-free grammar in Chomsky normal...
Let G = (AN , AT , S, P) be a context-free grammar in Chomsky normal form. Prove that if there exists a word w ∈ L(G) generated by a derivation that uses more than |P| + |AT | steps, then L(G) is infinite.
Prove that if G is a context-free grammar in which every variable occurs on the left...
Prove that if G is a context-free grammar in which every variable occurs on the left side of at most one production, then G is unambiguous.
Find Consider the following context-free grammar G: S --> T#T T --> C A --> aA...
Find Consider the following context-free grammar G: S --> T#T T --> C A --> aA | epsilon B --> bB | epsilon C --> cC C --> c a) Give the set of unproductive symbols in G? b) Give an equivalent grammar without useless symbols.
For an example BNF grammar, be able to identify the tokens which a lexical analyzer would...
For an example BNF grammar, be able to identify the tokens which a lexical analyzer would be able to produce. For an example BNF grammar, and a list of tokens, construct a state diagram of the language’s lexical analyzer.
Give a context-free grammar for {w ∈ {b, c}∗| #c(w) = #b(w)}.
Give a context-free grammar for {w ∈ {b, c}∗| #c(w) = #b(w)}.
Consider the context-free grammar G = ( {S}, {a, b}, S, P) where P = {...
Consider the context-free grammar G = ( {S}, {a, b}, S, P) where P = { S -> aaSb | aab }. Construct a NPDA M that such that L(M) = L(G). I would like the transition graph for this NPDA please.
Let G be any context-free grammar. Show that the number of strings that have a derivation...
Let G be any context-free grammar. Show that the number of strings that have a derivation in G of length n or less, for any n > 0, is finite. Could you please answer with clear explanation. The question is from Elaine Rich's Automata, Computability and Complexity Chapter 11 Exercise 14.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT