Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following regular expressions: R 1 = b+c+d+e+f R 2 ? = a+b+c+d+e+f

ID: 3664003 • Letter: C

Question

Consider the following regular expressions:

R1 = b+c+d+e+f

R2? = a+b+c+d+e+f

R3 = (a* +b* )(a+b)

R4 = (a+b)* R1 (a+b)

R5 = a.a R0 * (a+b)*

R6? = R3 * R2 * a.a.a

part (I)

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

- Give an example of input for which getToken() returns R0

- Give an example of input for which getToken() returns R1

- Give an example of input for which getToken() returns R2

- Give an example of input for which getToken() returns R3

- Give an example of input for which getToken() returns R4

- Give an example of input for which getToken() returns R5

part(II)

If getToken() is called repeatedly on the following input, what is the sequence of tokens returned?

ffaabbabcdebaaabababcdefaaba

*Here is an example of how the problem should be set up*

Given these tokens:
ID = letter . (letter | digit | _ )*
DOT = .
NUM = pdigit . (digit)* | 0
DECIMAL = NUM . DOT . digit . digit*

What token does getToken() return on this string:
1.1abc1.2

Please explain answers I am not fully grasping this concept while looking at my notes.

String Matching Potential All DECIMAL, NUM DECIMAL DECIMAL Longest Match 1.1abc1.2 1.1abc1.2 NUM DECIMAL DECIMAL NUM, 1 NUM, 1 DECIMAL, 3 1,1abc1.2 1 1abc1.2 1.1gbc1.2 1.1abc1.2 bc1.2 ID ID ID ID All ID ID ID ID abc1.2 ab1.2 abc.2 abc1.2 ID, 4 abc.2 2 All DOT DOT, 1 2 All NUM NUM 2 NUM, 1

Explanation / Answer

Example of input for which getToken() returns R0

1.1abc1.2

Explanation:

Example of input for which getToken() returns R1

1.1bc1.2

Explanation:

Example of input for which getToken() returns R2

1.1ac1

Explanation:

Example of input for which getToken() returns R3

1.1abc2

Explanation:

Example of input for which getToken() returns R4

2.1abc2

Explanation:

Example of input for which getToken() returns R5

2.1abc2.1

Explanation:

String Matching Potential Longest Match 1.1abc1.2 NUM DECIMAL NUM DECIMAL 3 1.1^abc1.2 DECIMAL NUM DECIMAL