Scanning, LL Parsing, LR Parsing Flashcards

(40 cards)

1
Q

What do the following mean with regards to regular expressions:

  • Token
  • Alphabet
  • Epsilon
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The arrow in regular expressions means?

A

Can be

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the precedence order for the following in regular expressions:

|

.

*

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a CFG?

A

A CFG is a Context Free Grammar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a CFG derivation?

A

A production from a CFG, what can be replaced in the LHS of a sentence (non-terminals) with RHS non-terminals and terminals as productions.

Note in the following example how expr is replaced

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a parse tree do?

A

Represents a derivation graphically

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between right-most derivation and left-most derivation?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When a grammar can have two parse trees for the same sentence, what is it called?

A

Ambiguous grammar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an ambiguous grammar?

A

When there can be two difference parse trees for the same grammar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is lexical analysis

A

Scanning:

Tokenizing the source code

Removing comments

Saving text of identifiers, numbers, strings

Saving source locations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is ad-hoc

A

Ad-hoc simply means it was created by a human for the specific purpose of what it is being used for

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a DFA? What does it mean? What do they look like?

A

A DFA is a deterministic finite automaton which means each state goes to one other state based on its current state and input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a NFA? What do they look like?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you construct DFA from regular expressions?

A

Build NFA from regular expressions

Convert to DFA

Minimize DFA

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Examine this NFA example:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Examine the following example for minimizing an NFA to DFA, dont move on until you understand

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the “longest-possible token” rule?

A

Return only when the next character cannot continue the current token

18
Q

What is look-ahead?

A

How many characters you need to look forward to deterine the production being used

19
Q

Examine the following table-driven scanner:

20
Q

What is parsing?

21
Q

What is the difference between LL and LR parsing?

22
Q

Is LL parsing top-down or bottom-up?

23
Q

Is LR parsing top-down or bottom-up

24
Q

Top-down parsers are also called ____, the employ _____

A

Top-down parsers are also called LL parsers, the employ recursive descent

25
LL / top-down parsers are ____ \_\_\_\_
Table driven
26
A prediction in L parsing is based on
The current state and the input token
27
With a current state and a given input token, a LL parser can take the following actions:
1. match a terminal 2. predict a production 3. Announce a syntax error
28
Examine the following LL(1) parse table and understand what it means FULLY
29
Review the following LL(1) parse stack and how it works
30
How do you construct First(a) and Follow(A)?
31
What are some common problems with making a grammar LL(1)? What are their fixes?
32
Is there a LL(1) grammar for the dangling-else problem?
NO
33
What is the premise of an LR parser?
Read from input until you find a RHS, continue until you have fully reduced
34
Examine how the dot productions work with LR parsing:
35
Examine the following LR parse table:
36
Examine the following parse table:
37
Examine the following LR parse stack
38
What is a shift/reduce conflict?
39
What are two SLR conflicts?
40
Examine the following for LL Left-recursion elimination: