Grammars How does the parser process the tokens from the following code? How does the parser know if the input is valid code? What notation is commonly used to specify syntax? void quote() { print( "To err is human, but to really foul things up you need a computer." + " - Paul Ehrlich" ); } Here's a Grammar for simple expressions. E -> (E + E) E -> (E * E) E -> 1 E -> x E -> y Show the steps that generate the expression. (x * (1 + y)) Classwork You may work with a partner. Use the Grammar to show the steps that generate the expression. x * 1 + y E -> E + T | T T -> T * F | F F -> 1 | x | y Classwork You may work with a partner. Use the Grammar to show the steps that generate the sentence. the tree eats loudly sentence -> noun-phrase verb-phrase noun-phrase -> article noun verb-phrase -> verb adverb article -> a article -> the noun -> tree noun -> monkey verb -> eats verb -> talks adverb -> wildly adverb -> loudly Grammar Terminology What's a Production (Rule)? What's a Terminal? What's a Nonterminal (Variable)? What's the Start Symbol? What's the form of a valid production or rewriting rule? Head or Left-Hand-Side (Always a Nonterminal) -> Body or Right-Hand-Side (0 or more Terminals and Nonterminals)