1/16/2020 Final Exam: Principles of Programming Languages
https://asuce.instructure.com/courses/1344/quizzes/17553?module_item_id=119038 1/20
Final Exam
Due No due date Points 40 Questions 40 Available Jan 13 at 12am
...
1/16/2020 Final Exam: Principles of Programming Languages
https://asuce.instructure.com/courses/1344/quizzes/17553?module_item_id=119038 1/20
Final Exam
Due No due date Points 40 Questions 40 Available Jan 13 at 12am - Dec 31, 2023 at 11:59pm almost 4 years
Time Limit None
Attempt History
Attempt Time Score
LATEST Attempt 1 97 minutes 27.57 out of 40
Score for this quiz: 27.57 out of 40
Submitted Jan 16 at 12:19pm
This attempt took 97 minutes.
Ques 1 / 1 pts tion 1
Consider the following code:
Token LexicalAnalyzer::GetToken()
{
input.GetChar(c);
switch (c) {
case '=':
input.GetChar(c);
if (c == ’=') {
tmp.token_type = EQEQ;
} else if (c == ’<') {
tmp.token_type = EQLT;
} else if (c == ’>') {
tmp.token_type = EQGT;
} else
tmp.token_type = ERROR;
return tmp;
default:
tmp.token_type = ERROR;
return tmp;
}
}
In the code, input.GetChar() gets the next character from standard input. If GetToken() is called four times on input <==<==,
how many times is ERROR returned
0
1
2 Correct!
3
Q 1 / 1 pts uestion 2
letter = a | b | c | d
LETTER = A | B | C | D
1/16/2020 Final Exam: Principles of Programming Languages
https://asuce.instructure.com/courses/1344/quizzes/17553?module_item_id=119038 2/20
digit = 4 | 5 | 6 | 7 | 9
Consider the regular expression R = (LETTER | digit | !) • (letter • digit) • (letter | digit). Which of the following is correct
(more than one choice or no choice can be correct)?
1
*
!5aA ∈ L(R1)
?55aA ∈ L(R1 ) 555aA ∈ L(R1 )
None of the above Correct!
Ques 1 / 1 pts tion 3
Consider the regular expressions:
R = ( a | b )* ( 0*1* ) ( a | b )*
R = ( a | b ) ( 0*1* )* ( a | b )
Which of the following is true?
1
2
a0a ∈ L(R1) and ab01a ∈ L(R2)
a0a ∈ L(R1) and ab01a ∉ L(R2) Correct!
a0a ∉ L(R1) and ab01a ∈ L(R2) a0a ∉ L(R1) and ab01a ∉ L(R2)
[Show More]