40 likes | 211 Views
Guided Notes Ch. 4 Syntax. Syntax Description methods Parsing Methods Parser generators. Syntax Description Methods. BNF = CFG EBNF = extended BNF: { }, [ ] Syntax Diagrams Related concepts: (for unambiguous grammar, predictive parser) precedence cascade left-recursive (left-associate)
E N D
Guided Notes Ch. 4Syntax Syntax Description methods Parsing Methods Parser generators
Syntax Description Methods • BNF = CFG • EBNF = extended BNF: { }, [ ] • Syntax Diagrams • Related concepts: (for unambiguous grammar, predictive parser) • precedence cascade • left-recursive (left-associate) • first set, follow set
Parsing Methods • Top-down: nonterminals are expanded • Bottom-up: right-hand side is reduced to the nonterminal on the left • Recursive-decent: turning the nonterminals into a group of mutually recursive procedures whose actions are based on the right-hand sides of the BNFs
Review questions • What are the 3 syntax description methods? Explain the main motivations for each method. • What are the 3 parsing techniques we discussed ? Describe the characteristics of each. • Give formal definitions of First set and Follow set. • What are the 2 requirements for a predictive parser to be able to distinguish between choices in grammar rule? • Define an unambiguous grammar for expression with multi-level operators (Sebesta #7 Ch12). • What is a parser generator? Give an example.