COMP 302 Lecture Notes - Lecture 23: Parsing, Lexical Analysis, Symbol Table
Document Summary
March 9, 2017 ( lecture 23 // week 9, lecture 2 ) Grammars don"t just generate strings; they generate tree structures called parse trees . The structure of the tree tells you something about the grouping. In fact, many of the inadequacies in our standard linear languages is that the linear structure doesn"t reveal grouping. That"s why we use parentheses to manifest grouping. The tree we looked at yesterday was ambiguous. When a grammar produces 2 or more parse trees for a sequence, it is call ambiguous . We need to design unambiguous grammars; but sometimes this is impossible. Here is how we do it for our expressions with generation of numbers thrown in as well: E = generates expressions (last time we only had expressions). The idea is that factors are things that can be multiplied and terms are things that are added. = {+, *, (, ), 0, 1, 2, 3, 4, 9 }