Consider the following regular grammar with start symbol S and terminals {x, y}.
S → xS
S → yX
S → yY
X → xX
X → yS
Y → xY
Y → λ
List four strings, each of length less than 4, accepted by this
grammar. (Include ε if it is accepted.)
List four strings, each of length less than 4, not accepted by this grammar. (Include ε if it is not accepted.)
In English, describe the language represented by this grammar.
Consider the following regular grammar with start symbol S and terminals {x, y}. S → xS...
Consider the following context-free grammar with terminals {a, b, c, d} and start symbol S. S → W | X | Y | Z W → AW D | X | Y | Z X → BXD | Z Y → AY C | Z Z → BZC | ε A → a B → b C → c D → d (a) Give a derivation tree with input string: aaaabccddd (b) What language does this CFG recognize? Give a...
10 pt) Consider the following grammar where S is the start variable » terminals: x, y, z,t,,* non-terminals: El T, F, V * start symbol: E production rules (a) (4 pt) What is the associativity of the operators+,, * and/ explain why. (b) (3 pt) What is the precedence of , and / explain why (c) (3 pt) Given a parse tree F * T 2 2 Explain how the value of the string is generated
What language is generated by the grammar given S→ XY X → aXbb | ε Y → bXcc | b
Consider the following grammar for a language, where a and b are called terminals while <S>, <A> and <B> are called non-terminals, where <S> is the starting entity, i.e., from which we generate strings. The goal is to generate a sequence of as
Consider the following BNF grammar: S ::= A x | B y A ::= B y | C w B ::= x | B w C ::= y Which of the following regular expressions describes the same set of strings as the grammar? 1. xwxy + xww∗y + ywx 2. xwx + xww∗y + yw 3. xw∗y + xwxyx + ywx 4. xwy + xw∗xyx + ywx 5. xw∗y + xw∗yx + ywx 6. none of the above 7. all...
How many strings can this grammar generate? X -> YY Y -> ZZ ZZ -> 0 | 1 | ε Is there a shortcut to solving this rather than making all of the possible combinations?
Consider the following LL(1) grammar with terminals (, ), +, id,
num, and starting symbol S.
Compute the first and follow set of all the nonterminals.
S → (ST) F→id
Problem 1. Consider the grammar S → Y X Y X → a Y | Y Y → b b Y | X | ε where a and b are tokens. Remember that ε represents the empty string. Y → ε means that Y does not have to match any tokens. 1. Give a leftmost derivation for the string (sequence of tokens): bbabbabb 2. Give a rightmost derivation for the string (sequence of tokens): bbabbabb
Given z = 2(x,y),X = x(s,t),y = y(s,t), and zx(-1,1)= 3, zy(-1,1)= 2, xs(-1,1)= -1, x,(-1,1)= 3, ys(-1,1)= 1, z (1,2)=5, z (1,2)=3, x(1,2)= -1, y(1,2)= 1, y,(-1,1)= 4, xs(1,2)=3, xx(1,2)= -2, x(-1,1)= 1, y(- 1,1)=2, 7(1,2)=7, vs(1,2)=2, a. compute ( cas ? )ats = 1,t =2, b. if we plot the surface Z as a function of 5 and t, then at the point (1,2) in the st-plane, how fast is Z changing in the direction (-1,1) in the...
Give a context-free grammar to generate each of the following: (a) {x#y | x, y ∈{0,1}* and |x| ≠ |y|} (b) The complement of the language {an bn | n ≥ 0}. (c) The set of boolean and arithmetic expressions. A boolean expression consists of a comparison of two arithmetic expressions using either of the two comparison operators < and ==. An arithmetic expression may involve numbers, identifiers, parentheses, and any of the four operators +, -, *, and /, with...