Grammars Flashcards

1
Q

What is a grammar?

A

A grammar is a set of formal rules that define what a valid sentence looks like

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

How is a grammar rule defined computationally?

A

Each rule describes a pattern against which we match the input string, in terms of literals and other patterns

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

How is a grammar defined formally? (4)

A

G = (N, T, P, N0)
• N = Set of non-terminals
• T = Set of terminals
• P = Set of productions mapping a non-terminal to a sequence of non-terminals and terminals
• N0 = Initial non-terminal (start symbol)

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

What is meant by an ambiguous grammar?

A

When a valid sentence has more than one parse tree, that is you can product a valid sentence using more than one different sequence of productions

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