Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

Consider the simple arithmetic grammer below:

    exp -> exp OPA term | term
   term -> term OPM factor | sfactor  <-- NOTE: "sfactor" stands for "signed-factor", it handles unary "-"
sfactor -> OPA factor | factor
 factor -> NUM | LP exp RP

where OPA = +|-, OPM = *|/, LP = (, RP = ), and NUM = digit+.

Problem 1

Draw a parse tree for -34*(16-27/2), and next to it what you think the abstract syntax tree should be (I realize this has not been precisely defined, so there's lattitude here).

Problem 2

Life is more interesting when we add features outside of those found in C/C++ and Java. Suppose we wanted to make dates "built-in" types in our system, so that an expresion like 11:23:2007 would be a date. Moreover, we want to mix dates with numbers in arithmetic, like this:
	    (11:23:2019-10:14:2019)/2 + 10:14:2007
... make sense. Try to extend/modify the grammar at the top of the page to make this happen. Show me the modified grammar as well as a parse tree for 11:23:2019+6 using your extended grammar. Would it be a problem to use / instead of : for delimiting dates? why?