Syntax Analysis Flashcards

1
Q

What is top down parsing?

A

This is when we begin with the starting symbol of a grammar and always extend the left-most non-terminal symbol until we achieve a string that matches the input.

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

What is an ambiguous grammar?

A

This is a grammar that can generate the same string using multiple parse trees.

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

What is a left recursive grammar?

A

A grammar is left-recursive if it contains a non-terminal symbol A, which is replaced by Ax…

That is it is replaced by itself and some other symbols. This means we can generate an infinitely long parse tree, where we accumulate As on the left hand side.

E.g. A => Ab

A
Ab
Abb
Abbb ….

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

How can i eliminate the left recursion of the following grammar:

Sum => Sum + number | number

A

Sum => number Sum”

Sum” => +number Sum” | empty_symbol

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

What is the LL(1) property?

A

This is when all for all substitutions for a particular non-terminal symbol begin with different first terminal symbols.

For example:

A => aZ
A => bZ

They both start with different symbols, this allows us to look ahead one symbol in the input and make an informed choice about which rule to use.

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

How would we transform the following grammar so that it has the LL(1) property?

A => ax | ay | az

A

Factor out the a,

A => aF
F => x | y | z

Now all substitutions begin with a different symbol

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

What is bottom up parsing?

A

This is where we begin with the sentence, and try to come up with sequence of production rules that created it.

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

What is a handle in a string S?

A

A => b — rule to use
k — position

where b is a substring in S, and k is the position of b’s rightmost symbol in S.

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

What can cause a Top Down Parser to go into an infinite loop?

A

A Left Recursive Grammar

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