Convert the CFG(s) in the following problems into equivalent PDAs:
a.
E → E + T | T
T → T x F | F
F → (E) | a
b.
R → XRX | S
S → aT b | bT a
T → XT X | X | ε
X → a | b
c.
A → BAB | B | ε
B → 00 | ε
Convert the CFG(s) in the following problems into equivalent PDAs: a. E → E + T...
Exercise 3. Convert the following CFG into an equivalent CFG in Chomsky normal form using the procedure seen in class.
Problem 2. Consider the following CFG G-(V. Σ' R, S) where V-(S, U, W), Σ- {a, b), the start variable is S, and the rules R are: Convert G to an equivalent PDA using the construction described in Lemma 2.21
For the following problems assume y = Χβ + ε and assume E(e) 0 and var(e) σ21. 3. Show that έ (1-X (XTX)-XT) ε. (Hint: Use the assumption that y + ε)
12. Use the following SDT to convert an infix expression (9*3+2) to it post-fix equivalent. Semantic rules Production (print(")) ) (priot ()) () (print (num.lval)) E E+T T TP- [5 marks F num 13. Briefly explain the relevance of DAG and TAC at the Intermediate code generation phase. Give an example of DAG(Directed Acyclic Graph) with its equivalent TAC(Three-Address Code). [6 marks 14. Parser table is very important in predictive parsing; construct a parser table for the following CFG: S...
The following context-free grammar (CFG) generates palindromes. This CFG has the following rules: S → ε, S → a, S → b, ..., S → z, S → aSa, S → bSb, ..., S → zSz. On an example of a palindrome cattac, show, step-by-step, how this palindrome will be generated by this grammar.
Theory of Computation - Push Down Automata (PDA) and Context
Free Grammars (CFG)
Problem 1. From a language description to a PDA Show state diagrams of PDAs for the following languages: a. The set of strings over the alphabet fa, b) with twice as many a's as b's. Hint: in class, we showed a PDA when the number of as is the same as the number of bs, based on the idea of a counter. + Can we use a...
Consider the context-free grammar with the rules (E is start variable) E → E + T | T T → T × F | F F → ( E ) | a Convert CFG to an equivalent PDA using the procedure given in Theorem 2.20.
Conversions to CNF: Textbook problems: 7.1.1 - 7.1.4 (p. 275) 7.1.1) Find a grammar equivalent to the following, but with no useless symbols: S → AB | CA A → a B → BC | AB C → aB | b 7.1.2) Begin with the following grammar, then eliminate ε-productions, eliminate unit productions, eliminate useless symbols, then put the grammar into CNF. S → ASB | ε A → aAS | a B → SbS | A | bb 7.1.3)...
For the following problems assume y = Χβ + ε and assume E(e) 0 and var(e) σ21. 2. The vector of predicted values is defined as У-Xß. Show var(y) = σ2X(XTX)-XT.
help
3. Answer each part for the following CFG G (The * symbom in the derivation means with any number of steps): R + XRXS S + aTb | b Ta T→ XTX | x | 6 X + ab (a) What are the variables of G? (b) What are the terminals of G? (c) Which is the start variable of G? (d) Give three strings in L(G) (e) Give three strings not in L(G) (f) True or False: T...