What are the non-terminals what is the start symbol what


Assignment

Problem 1. Consider the following regular expressions (omitting the dot operator)

Rθ = a | b | c
R1 = a | b | c | d
R2 = (a | b) (a* | b*)
R3 = (a* | b*)R1 (ab) (ab)*
R4 = ab R3* (a | b)*
R5 = R3* aaa R2*

Let getToken() be a function that returns the next token in the input. If we call it repeatedly it will return one token after another. When all the input is consumed, getToken() returns EOF (end of file). Assume that longest prefix-matching rule is used by getToken() and ties are broken in favor of the regular expression listed first.

1. Give an example of input for which getToken() returns Rθ
2. Give an example of input for which getToken() returns R1
3. Give an example of input for which getToken() returns R2
4. Give an example of input for which getToken() returns R3
5. Give an example of input for which getToken() returns R4
6. Give an example of input for which getToken() returns R5
7. If getToken() is called repeatedly on the following input, what is the sequence of tokens and lexemes returned? In your work, show step by step the Matched, Potential (Viable), and Maximal tokens.

aaadbabaadaaadabbbaab

Problem 2. Let R1 and R2 be two regular expressions,

1. Is it alwaysthe case that L(((R1)*)|((R2)*)) = L(((R1)|(R2))*)?
2. Is it alwaysthe case that L(((R1)*).((R2)*)) = L(((R1).(R2))*)?
3. Is it alwaysthe case that L(((R1)*|(R2)*)*) = L(((R1)|(R2))*)?
4. Is it always the case that L((R1*)*) = L((R1)*)?

In each case explain why the statement is true or provide a counter example.

Problem 3. Consider the grammar

S → X Y
X → aX | b
Y → bbY | E

Draw a parse tree for input string aabbb

Problem 4. Consider the grammar

S → X Y
X → YaX | Y b
Y → aXYY | X X Y | E

1. What are the non-terminals?
2. What is the start symbol?
3. What are the terminals?
4. Show that this grammar is ambiguous by constructing two different parse trees for the string abab

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: What are the non-terminals what is the start symbol what
Reference No:- TGS02625617

Expected delivery within 24 Hours