Grammars & Parse Trees
Generator - Let's us generate all strings in a language
Recognize - Let's us recognize all strings in a language (y/n this is a legal string and parsing)
Grammars
Components of a grammar (
- Vocabulary
- Set of terminals (
) - Set of non terminals (
) - Set of productions (
) - Starting state (
)
Datalog Grammar
- Things in all caps are terminals
- Nonterminals are lowercase
- Order matters -> SCHEMES COLON needs to come first in datalog
- Predicates have a name and a list of parameters
- Schemes, Facts, Queries: declares a list of predicates
- Rules: aren't predicates
- head predicate
- a list of body predicates
- a colon-dash separating the two
Prefix Expression Grammar
LL(1) Grammar is type of context-free grammar
- The FIRST sets tell us which production to use