




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lecture note from the university of michigan's eecs 483 course on syntax analysis – part i. It covers the basics of parsing, context-free grammars, and constructing derivations. The concept of syntax analysis, the role of context-free grammars in describing syntax, and the difference between parse trees and abstract syntax trees.
Typology: Study Guides, Projects, Research
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















sentence
subject
verb
indirect object
object
gave
him
noun phrase article
nounbook
the
“I gave him the book”
» Terminal symbols = token or
ε
» Non-terminal symbols = syntactic variables » Start symbol S = special non-terminal » Productions of the form LHS
y^
LHS = single non-terminal y^
RHS = string of terminals and non-terminals y^
Specify how non-terminals may be expanded
Y
» L(G) = language generated by grammar G
a S a S^
b T b T
ε y^
1 non-terminal: S y^
2 terminals: “)”, “)” y^
Start symbol: S y^
2 productions
Y
ε
ε
ε)
ε
ε^
? Why is the final S required?
Context free grammar, G
Yes, if s in L(G) No, otherwise
Parser
Token stream, s (from lexer)
Error messages
Syntax analyzers (parsers) = CFG acceptors which also output the corresponding derivation when the token stream is accepted
Various kinds: LL(k), LR(k), SLR, LALR
»^
S^
Æ
E + S | E
»^
E^
Æ
number | (S)
Y^
Derive: (1 + 2 + (3 + 4)) + 5
Parse tree also called “concrete syntax”
AST discards (abstracts) unneeded information – more compact format
Y
Y
» In the string, find the leftmost non-terminal and apply
a production to it » E + S
Y
» Same, but find rightmost non-terminal » E + S
»^
S^
Æ
E + S | E
»^
E^
Æ
number | (S) | -S
Y^
Do the rightmost derivation of : 1 + (2 + -(3 + 4)) + 5