



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
An overview of context free grammars (cfgs), their significance in precisely describing the syntax of programming languages, and their role in the compilation process. It covers the basics of cfgs, their relationship with regular expressions (res), and tips for designing effective grammars.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




CMSC 330 2
CMSC 330 3
CMSC 330 4
CMSC 330 5
CMSC 330 7
CMSC 330 8
No
Yes
?
CMSC 330 9
CMSC 330 10
CMSC 330 11
A → xA | ε // Zero or more x’s A → yA | y // One or more y’s
{ ab } // a’s followed by b’s S → AB A → aA | ε // Zero or more a’s B → bB | ε // Zero or more b’s CMSC 330 12
{a n^ b n^ | n ≥ 0} // N a’s followed by N b’s S → aSb | ε Example derivation: S ⇒ aSb ⇒ aaSbb ⇒ aabb {a n^ b 2n^ | n ≥ 0} // N a’s followed by 2N b’s S → aSbb | ε Example derivation: S ⇒ aSbb ⇒ aaSbbbb ⇒ aabbbb
CMSC 330 19
CMSC 330 20
CMSC 330 21
T → a | b | c | (E)
CMSC 330 22
CMSC 330 23
left recursion (^) right recursion
CMSC 330 24
T → a | b | c | (E)
CMSC 330 25
E → E+T | E-T | T lowest precedence operators T → T*P | P higher precedence P → a | b | c | (E) highest precedence (parentheses)