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
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
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)
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