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

What makes a deterministic context free grammar deterministic?
What makes a deterministic context free grammar deterministic?
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.
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.
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.
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.
Consider the following context-free grammar G: E ® T + E ® * T i E...
Consider the following context-free grammar G: E ® T + E ® * T i E ® f i E ® * f + T ® + Questions: (5 points) Compute the Canonical LR(1) Closure set for state I0 for grammar G. (10 points) Compute (draw) the DFA that recognizes the Canonical LR(1) sets of items for grammar G. (5 points) Construct the corresponding Canonical LR(1) parsing table. (10 points) Compute (draw) the DFA for LALR(1). (5 points) Construct LALR(1)...
Q1)   Convert the following set of BNF rules to a single EBNF rule. <E> --> <E>...
Q1)   Convert the following set of BNF rules to a single EBNF rule. <E> --> <E> + <T> | <E> - <T> | <T> Q2)   Briefly explain how the expected type and actual type of <expr>             in the following two BNF rules are determined: <assign> --> <var> = <expr> (Rule 1) <expr> --> <var> + <var> (Rule 2)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT