Do you hear the bus going by in the parking lot?  Hopefully it's invisible to you all.  
	PROFESSOR:  I have to shut my window or I o not be able to here you, but no.  It's distractive.  So, how has the week been?  I had a big event over the weekend that was soaking up time for the week before that.  So, there was I think hour and a half of videos I put up.  How many people watched that video, hour and a half or so?  
	Cool, the raising hand scheme.  I think the idea of doing that is the tiny bit watching that video is not just extra time on top of the time in class, I don't want to go over the same material that Steven has been watching through, I want to take the time to answer questions and then the people will be able to go through videos at their pace and use this time for questions.
	I have one of 3 lectures cued up.  For tonight.  But 2 of the 3 would be the stuff covered on that video.
	For you guys, won't necessarily be on Wednesday, I'm give to go in-class section on Wednesday -- and what I'll do for you all -- I'll have it on D 2 L, ready to take, and instruction are on D 2 L as well.
	When you're ready to take the exam, download it, take it.  It will be open notes and go ahead and use stuff posted from the course web page.  And it will all be clarified on there.  And then, once you start taking it, they'll be a limit.  It will probably make something like, it will be the same class as to having in-class.  Meant to be 50 minutes, but I'll give you guys hour and a half or 2 hours -- should not take that long, I might keep it shorter to hour and a half element.  You do not have to take it Wednesday night, it will be sometime doctor next Monday, if that works okay with you all.
	I know you all have , more tighter schedules than others might.  There will be perhaps more flipped videos to watch or not.  Yeah, so -- okay.  Yeah, exactly.  The project will be weekly homework, and I need to get the next homework out but that won't be until Thursday or Friday.
	Okay.  It's a tough 3 hours in a row is tough format.  It's tough on me, it's definitely tough on you all.  It only works if you're watching the videos in between.  That's the flip-side , I think I'll go ahead and review a little bit, ask, product you some questions.  I do realize would like to get more self study questions or comprehension questions to go with those videos.
	But that's -- takes more effort for me to setup so I'll ask questions now and be able to go over them based on what was in the videos.  
	Okay, the parsing, we can talk about that, sure.  Okay.  So that's, let me go and find the URL that has been posted.  I'm not sharing my screen yet here.  In fact, I might need to get this link post nd a different way.  So, link to the code we're using.
	Look at the link, Q 0 grammar.  Okay, that's not really linked from the page but there, go to same URL and go to that URL that has grammar definition for language Q 0 and review the code for that.  If you want to look at that.  Back off that, if you look inside that directory, you can see you had (Inaudible) including Q 0 dot Racket, look for -- Q 0 dot Racket.
	Directly Q 0 Java.  And then inside that directory, there's actually, if you look there, several different Java files and this is very similar to the code, almost identical to the code that was in that video except it's slightly tailored.  Q 0 is slightly different grammar than what the video was talking about.
	So that's what we'll be looking at -- Q and 0 look similar on my browser font.  Okay.  Close that window -- close -- close FireFox now that this has started up.
	Oh, not recording.  So let's go ahead and go to that link inside there for, first let's look at grammar Q 0 dot HTML.  so Q 0, I should make, one slight change, if you saw that before, the one that, that fourth case had been called something like an IF odd expression and since the keyword, expression had the word parity in it, we decided to call it parity expression in today's class.  So that's new.  From the F odd expression to the parity expression.
	Okay.  So -- this here is a grammar and I think last time we came up with several expression in that grammar, Q 0 expressions, few things drivable from that grammar and thought about what parse trees looked like and so on, that's where we left off last time.
	Now I want to say, great, we're going to go and write an interpreter for this language and so, and seem that rather than try to work with the raw string of the language, the parse tree has all of the structure of the language.  It tells you what expressions are inside and what other expressions in that tree format.  Really, the parse tree is the right way to view the program.
	I know you did a program it's string of text in a file, but right way to view program or think of it is as a parse tree.
	Which is, Java program, this thing is inside that thing, when really just a whole bunch of characters in a row.  This class or field inside this object which is inside this method that sort of thing.
	You have that structure in your head.  That tree like structure.  Okay.
	And we're going to look at this in both, Racket and Java.  We have the this data definition, telling me from the videos, expert data definition, what sort of data definition should we use for expr?  Yeah, exactly.  Union type.  -- numb, paren expr, bin expr and parity.  Union.  Right.
	What is code going to look like in Racket, given union data type.  Con with 4 branches.
	We already start writing in chunks of code even though we don't know what we want to do with these parse trees, we write codes to handle thee parse trees, with 4 branches, each of branches we pull out any sub fields if we have them.  If I have a bin expr, I have 3 sub fields in there.  Just how should we represent a bin expr by itself?  Let's see if I have this -- let me get this -- window better -- we have data definition of expr.  We go ahead and, oops, let's see.  You can see right of the grammar the tree is going to have 5 children total, but some are parentheses, I don't need to keep track of that information, there's 3 interesting sub field, forever bin expr.  The open paren, and close paren in the parse tree not really necessary.
	I mean it's not necessary to keep track of them.  If I'm trying to tell you about a bin expr I don't need to tell you about the tree and open paren and close par ran is, I need to tell you the expr, bin expr and the other one is -- that's an issue.
	We have bin expr with 3 fields, and then go ahead and write, go ahead and extract those 3 fields for parity expr, we have 3 sub fields all expr, paren expr, instruct with only one field.  Really keeping track, just another expr, why do we need object to hold that expr, we want to remember that, that there were the parentheses around this expression in the original parse tree.
	So you want to keep track of that information.
	Need a terminal?  Into not sure what you mean by that?  Terminal for the grammar?  I mean, yeah, I see in the parse tree -- there needs to be one non recursive case otherwise you could not make examples of our data.  Number is going to be the simplest one and go ahead and make examples of the data.  I guess we made examples from the grammar, we can make examples from the grammar, so number is 3, type of expr, make paren of expr, line 2 of definition, make paren expr of 3, how do I know, it's make paren expr of something, that was because of line 22.
	Yeah, I get -- be sure those things.
	Give me a complicated, whole bunch of nested data, first one bin, next paren and another parity expr inside of it, nested deeply but build those up the same way we built of ancestor trees an list from smaller examples.
	The first sample.  If I ask you to write down sample of tree you need number, without that we can't build anything bigger on top of that.  Start with number and start building bigger and bigger ones.
	And everywhere we need expression, look at all expressions we made previously and stick them in here and make a bigger expression.
	Let me -- da-da-da -- 
	Examples of the data -- of, when I say data, expr, 3 is one, make ar paren expr of 31.  Go ahead and everybody give me one other one written out as actual Racket data types.
	Give me one example of the data, Steve got one -- Steve is on to us the sooner you answer, the get the simple examples first, next example may be more involved.  Bin expr is used up, bin expr of 2 numbers.
	Again how do we know that was a bin expr?  You go and look at that data definition, and say, as long as I provide an expr, 3 is expr, and 5 is expr, what is bin OP?  This definition is one of 3 things.  So, that's how I was able to, very phi to myself, this really is an expr, build one out.  Using smaller ones like 3 or something like it, like 5.
	So -- yeah, to be able to type it into Racket would be 3 and string and add 5.  Parity expr of 3, 4, 5, we need any 3 exprs in there.  Who wants to give me another one?  Sean?  Mark?  And the hint is, look at that definition that we have, that's the definition, it's going to lead you to, what is this?  Da-da-da -- okay.  Expr has to be one of these 4 things, exhausted it one.  Made simple bin exprs, made simple paren expr.  Aaron made a   simple one where he had 4, 5, 3, so far everybody is using number when they need an expr, take it up a level.
	Hopefully everyone can come up with example, just following data definition.
	Okay, good.  Make paren expr that has one expr inside it, that expr will be the thing we used up before, pasted in.  If you already have stuff sitting ahead of us, yeah.  Making examples of data, not about making you type a lot but about making us think about what things we have to work with.  Okay.
	2 more people typing that have already given answers that will give more answers, maybe.
	And this exactly mirrors the end of last time, we came up with strings correspond to go more complicated expressions.  Exact sort of thing.  So Sean or Chase want to give a try?  Here is my thinking, we want to use something we haven't before, we go back and saw make paren expr that had a number.  So I make paren expr with bin inside it, how about a paren expr that contains a paren expr?  So Chase or Sean, paren expr that contains paren expr, we have one sighting here -- highlighted -- off on the side, think about the string that will give rise to this parse tree.
	Oops, -- because we already have an example of a making paren expr that has a numb in it.  I want to make with something else in it.  We already seen with one simple bin expr inside it.  I'm trying to lead people to more and more things -- so, this is what I was fishing after, Chase and Sean, and whoever else has not contributed.  Some, make paren expr that contains.
	I can start off with make paren expr as long as this thing is an expr.  If you do that, it is an expr, grab some other expr to put in there and I'll grab this one here -- so that would be another example of a paren expr.  And string that would correspond to that would be something like this -- (typing) -- where the spacing is, any of the spacing would do this.  We're going to be ignoring spaces.
	And so on, take some of the things from last week write them as actual structures, be able to do this.  This is first step of design recipe and reading off this definition, saying, hey, one of these case 4s an write it out, wherever you see expr put in some other particular expr.  And if already made simple ones with just number, make it more complicated, one you previously found and paste it in.  So, okay.
	Those are examples of our data.  By the way what would template look like that handles this data.  I'll do that, we spend a lot of time on the template, so -- function for expr -- structure of this code, decides, Steven Oake, what did does the structure of this code look like?  -- thing that takes in an expr and does something with it, I don't know what type it will return.  Someone besides Steven Oake, how am I going to start this?  -- yeah.  Cond.  Exactly, and 4 branches.
	Okay.  Now.  What do I need to do for the 4 questions.
	What are different questions.
	I need to distinguish, number, bin expr, parity expr, how can I ask if I was given a number?  Well -- fourth ly in Racket there's, predicate called number.  How can I ask was I given a paren expr?  And was seen if we go ahead and do define paren expr -- that gives us paren expr and so on.  Bin expr, and, what was the last time?  Parity expr.  What's the next step of the design recipe.  Now with 4 branches and asked questions to distinguish all 4 different cases, what do we do next?  
	Recipe, memorize if not memorized.  We're down here on the template, union type, include a cond with as many branches per option.
	If handling product type, we talked about doing this inside, oops, where is the, there we are.  Doing this inside each branch.  If I have a, in this branch I have paren expr and compound type.  And I should pull out the different fields.
	What are fields inside paren expr?  We didn't go back and -- go back and look at data definition again.  Paren expr is like that, what's that field called?  Define struct did it.  We call it E.  Okay.  So -- paren expr E, of my expr.  When also called E by coincidence, or is it?  Or it follow with word by E.
	If I have bin expr, go ahead, people that have not told me, what are the names of the fields for bin expr?  Online 34.  See if you go ahead and pull out those fields.
	If I give you bin expr E, how do you pull out of different fields?  Yeah, exactly.  Bin expr, left of E, bin expr, OP of E, bin expr right of E and going off the screen here.
	Try to arrange things a little better, get chat window not obscured by anything.  Okay.
	And again, simile for parity -- parity expr, -- cond, parity expr even, and parity expr odd of E.
	Okay.  What's the next thing we ask for in design recipe?  No, still writing the template, I don't know what the function is suppose to do, I don't know what the test case is, we finished template here, we did 3 B, done 3 A and done 3 B.  I'm guessing 3 C.  Natural recursive call as appropriate and stem from what's in D too.  What type of each of these pieces is.  In the bin expr what is the type of bin expr left of E?  Where do I find out.  Make bin expr, that first one called left, that was something of type expr.  Okay.  
	There's an INV -- not following that.  This thing is an expr and we have function that wants to call expr.  The idea is, that's going to be a place we put recursive call, I don't know what this function does but writing code for it.  Bin expr right, that was an expr so -- pass to some function that wants to be called expr, most likely the recursive call.  
	Bin (Inaudible) off the E what type was that?  There was a list, not quite a list.  Let's see, it was a bin OP and what is bin OP, string in the following list.  So it's one of these 3 strings.  Really, I should have written them more out, it's union type, add, sub or mole.
	In my code nose to have these sitting in a list.  Why?  I mean it's special function called bin OP.  Give me something, tell me bin OP, ask member of list and now easy to change this, this definition is an union of 3 individual strings, 3 singleton sets.
	Yeah, this here is string, so thinking, hey what sort of, this is what the inventory question is, what sort of function call on string, string of pend, maybe substring, maybe equal.  I think we have the same, put in other recursive calls, do some, do that, everywhere we have expr, think about calls the recursive call.
	Okay.  Now we'll finish up with writing a function for this.  What function do we want to do?  Look at eval or 2 string?  So what are these function, that homework page -- oops, Q 0 dot HTML.  Okay.  We have 3 functions parse 2 string and eval.  Eval goes and does, sort of running the program.  Give me expression, tell me what it evaluates to.  2 string, that just does what you think it does.  Takes internal string and gives string representation of it.  And went through, I think, in the video a bit.  And again, how does this, code follow immediately from the code.  From the template.  Let's look at -- anybody any votes.
	I'll take eval if no votes, going one, going twice.  Okay, let's evaluate these expressions.
	And this is, technically I have not told you what 3 add 5 is suppose to evaluate to.  You probably guess it's 8, you'd be right, but technically, all I've really given you is syntax.  Let's look at some examples, what should eval of, and I copy paste, what do you expect eval of 3 to return, I'm glad you said 3 there.  Yeah.  Check-expect eval and take next thing, parentheses 3.  What does that seem to, what should that probably evaluate to?  -- 
	Square brackets, first of all I guess it's good to know what type of eval.  It takes in an expr and returns what sort of -- what type will it return?  To evaluate?  Evaluate means to give it a value and, and turns out, we don't have any Boolean's an strings and all we have for Q 0 are numbers.  I think the answer is always going to be a number.  I'm not sure what bracket 3 is.  I know that, bracket 3, is a string that was 3 in parentheses, I run that, go to computer, 3 in parentheses, what number does that evaluate to you and answer is straight up 3.
	So, I hope.
	So -- the answer is, just always going to be a number.  Check-expect, the next one we had here -- the bin expr with 3, add, 5, that's the one ASH does O did, we expect 8.  Check-expect -- the one I gave was paren expr of paren expr 3, what answer should that give?  Probably evaluate to 3 again.  No matter how many times you throw of answer to 3, it will evaluate to the result of 3 at the end of the day.  Okay.
	So yeah, you think of this as eval as being, little calculate   language and eval is saying solve.  Give me the answer to this.  That's what eval is doing.  Okay.  We have other ones, here is a -- copy and paste from what you all did.
	Becomes another test case, that's the reason we did these before.
	Okay.
	Check-expect, a bin expr with -- containing bin expr.
	And what expression should this be?  2 subtract 4, negative 2.  3 out of 5 is 8.  Multiple of 2, I'm happing the answer is negative 16.  Do one more check-expect.
	For, you're all doing examples of data, did anybody -- Aaron make parity 3, 4, 5, let's do that one.
	What should that evaluate to?  Make parity ox per of 3, 4, 5.  I haven't told you the semantics of what parity expr, you guess you're reading my mind when you say bin expr and have mole and add and sub, you probably means binary expression with addition and subtraction and multiplication and you're exactly right.  What, do I want for make parity expr.  If I try to evaluate, bin expr, 3, 4, 5.
	Evaluate first expression, which is 3, evaluates to 3.  If it's even, take the first branch.  If odd take the second one.
	Okay?  -- so in this case, I want the answer to be 5, this first one is odd.  So it's like an F statement and by the way -- what an odd wacky IF statement, we don't have Boolean in language so can't have anything that evaluates to Boolean in there.  If we add Boolean's for language we have to do more work after that.  So -- okay.
	So I guess up here, I should have had a make parity expr of 3, 4, 5.
	What was the string -- that gave rise to this tree?  -- go back and look at -- make parity expr of 3, 4, 5.  Let's look at, we need grammar not internal representation of the tree.  The grammar it was.  That was on Q 0.
	So, abstract tree, parity expr that that's 3 children, 3, 4, 5, what's the string that gave rise to that?  
	We have the parse tree, make parity expr 3, 4, 5, node with 3 children, each of which is a simple number.
	The question I'm clear, how can I clarify?  You have several things going on.  We have strings in the language.  From the string we turn into parse tree and representing the parse tree inside our program.  And sort of going back and forth between all 3 level there's.  So my question is, if I give you this parse tree in the language, make parity expr 3, 4, 5, what was the string that would have given that parse tree?  
	So, so a numb, go here, turns out numb is not a valid thing -- in this language Q 0.  Nothing starts with the letter N.  I'm either a number or make paren expr or bin expr, or open paren make.  -- so, now you're thinking in particular number 17.  17, will give me the parse tree 17.  Not give parse tree make parity expr 3, 4, 5.
	Human.
	So look at that grammar again.  If I watt want to get a tree that's parity expr.  What's the first character I need to type in.
	Yeah, first character is P, this P here.
	So somebody else wants to give me the rest of it?  Give me a string in the language whose parse tree is a parity expr with children 3, 4, 5.
	Yeah.  Word parity, followed by an expr, followed by the keyword even colon, followed by some other expr followed.
	, here is our examples, say, hey this is the string, if we take this string here, we can turn into parse tree, and then if we parse, represent that parse tree inside our program, we're going to sort of, remember the parse tree, had a bunch of nodes and there are like 5, bunch of children, the parity children were all children of that parse tree.
	Inside our program we only keep track of interesting part, 3, 4, 5.
	Is that clear enough, have you seen the answer?  Or totally baffling.  This is where the difficulty -- distance class are hard, I don't know what you're thinking and I can't read your faces.  So.
	Make sense?  So -- this string in text I will build a parse tree for it that will look like this in Racket.  If you gave me this, string here, this Q 0 program, you send me a file, silly program dot Q 0 and contain those characters exactly.
	Bracket 3 bracket, might parse that make paren 3, in your file contains these characters and parse it, I get paren expr of paren expr of 3.
	And if you have, parity 3, even colon, 4, so on.  My job is to parse, make parse tree and here is representation of parse tree in that program.
	Does that make sense once you've seen the answer?  Or -- remember the whole goal, I'm thinking about Java, you're writing Java compiler, you take   file and turn into parse tree.  And then you start to do, whatever you want to with the program, check all variable are clear and do whatever you want.  The first step is to, create the parse tree that core re responds to that string and represent in your program, and that's what we're doing.
	Are these all blank STARES, let's go the other way,   give you a string, you give me, the parse tree for it.  We'll go back several weeks.  Go to, 3 open paren 3 add, how about this -- add, and copy and paste that --okay.  Go ahead and, sketch on paper if you like, give me a parse tree as you've drown on paper or give internal representation of how that parse tree will look in our program.  That's what I'm eventually after here.
	What will the parse tree look like for that.
	What's sort of statement is this?    -- overall?  Is this big at the same time, paren that size statement?  Paren thee seize statement?  Pull up the m grammar.  Where did my page go.  So is that string open paren something something, what type of expression is that?  -- you can tell it's very first character give as way, must be bin expr, tell me what the 3 fields of that bin expr are, look at first field, I think it's clear the bin OP is going to be the word add inside there.  In between the parenthesis and bin OP, what sort of expression was that in between -- this bin expr is first argument, what sort of expression is it?  What's the text that occurs been the open par ran and the add -- yeah, paren expr, bracket bracket 3 bracket bracket bracket.  So what are we saying here, I have a make-bin-expr, okay. 
And we decided that, the first part, or OP was going to be add.
	And this is first thing was itself, that was the thing that core re responded 3 in brackets, which is paren expr of 3, copy and paste this from up here -- copy and paste it right in.
	We have a bin expr, we know the first child of the bin expr, we know second child of bin expr, the second interesting child, and then what's the third one?  Open paren is bin expr.  Oh, if you look at syntax for square brackets, why isn't R isn't that double paren expr.  Look at syntax.  One paren expr that's 2 square brackets, you can't have single square brackets no, way to make this string square bracket 7 square bracket.  Yeah.
	And yes, wacky grammar, I totally agree.  I did it partly to Emma size how we get to makeup the syntax entire ly.  Emphasize.
	What's the last part?  Parity 3, even, 4, odd 5.  We already figured out parse tree for that.
	So -- this, you should be able to do this, this is examples from making the parse tree.  It's a tree 2 levels deep.  So bin expr has 3 children, first child self paren expr and next one is parity expr.  So -- and again, my mind I have a tree that goes with this, what's easiest way for me to draw -- drawing pod -- not sure it's worth for me trying to draw this -- pods , share, add a new share, that's not what I want.
	How do I get rid of that share?  Hide?  That's not really getting rid of it.  I know I'll grab a marker and holdup to a piece of paper -- to the screen.  I'll have bin expr, first child is paren expr.  Containing 3.  Then, yeah, probably much faster to draw this.  3, 4, 5.
	Okay.  That's the tree, and how do we represent this tree internally, the same way for the tree, for the we made structures, for the Simpson's that corresponded to exactly.  I'll make a bin expr struct that has 3 fields, first one is paren expr, paren expr have only one field.
	The third field of the bin expr will be parity expr, and that parity expr has 3 sub fields which should be accesses more the Java thing.  Yeah, what's inside those different fields is just 3, 4, 5, you're right in the full parse tree, parity expr had many more notes.
	Before the first expr there was a, the word -- parity.  And expr, went to numb and numb went to 3.  But the fact that -- the first node was, the terminal parity, again, every struct, every parity expr truck, if we include that had field for the first child in the tree we draw, we were drawing before by the grammar, that would always be the word parity.  If you have structure that always has the same, if you make one hundred different parity expr structs an first field is always the word parity, why ever make that a field, you refer that just knowing it's parity expr.
	We tend to draw it, like this is my drawing of the struct and how do I represent that struct internally -- right here.
	Does that make sense ? connect thing we've been talking about and learned before?  Or is that?  -- sound totally new?  Exact same thing we did with the caveman grammar and exact same thing we did with ancestor trees, putting together those 2, representing tree in Racket and parse tree itself, putting those together to get this here.
	Okay.  So -- gosh.  -- taking longer than I expected and I'm not sure -- we're getting some answers here, this is the template, this is what eval, and idea of, parity expr, valuate parity expr, see if first number is even or odd, if -- take a break in 3 minutes after we write eval.
	We're almost there, eval of 3, if my, expression E was a number, what is my answer going to go be?  Number.  If my expression was a parentheses expression, make paren expr with something inside it.  What do I want to do, template gives me, thing inside it, 3.  
	Whatever expression that was, no matter how complicated it was, it takes thing nd parentheses and fully evaluated it.  That's what this is, the template gives to us.  What should the answer be?  Just be that.  Whatever was inside the parentheses, put out the part inside parentheses, evaluate and we get that.
	Actually, let me -- yeah.  I was going to do that, copy that template there.  And I'll call this eval.
	Takes an expression, returns a number.
	Rename it eval.  Oops -- okay.  So eval parentheses expression is just exactly, the thing inside there evaluate it.  How do we do a bin OP?  That's first interesting one.
	Okay --we don't do bin expr OP because that's a string.  When looking at types we didn't say oh, that's expr, we look at something that wants to be called expr.  So that's just sitting there.  It's something along the lines of if, that string, I'm going to rearrange template has, if that string, if that bin OP after mole what should my answer be.  Evaluate the left, no matter how deeply nested or convoluted it s, evaluate the right and multiply those 2 results.
	And should have a more involved example to make sense of that -- more involved test case.
	Yeah.  So, we say left and right, not just the fields, thing R things inside the fields were entire trees an we don't know how to multiply trees.  Take that whole tree could be huge sub expression on left side of multiplication, evaluate, take that tree, get one number out of it, that's what recursive call does, and that's where our thinking starts.
	I have, result of evaluating left and right hand sides of the tree, I'll multiply them.
	That is if the string (Inaudible) what if -- if string equal add of that thing -- well, now it's going to be a lot like that, except, instead of multiplying it ourselves, we're going to call Rackets add on the 2 numbers.  Okay.
	And if it want mole and it wasn't add, what's the answer going to be, had to be subtraction so I had to go ahead and do something like this.
	That's kind of, looks a little gross doesn't it.
	But, hopefully it just follow from the template.  There's a lost code there, what should we do if something more than 3 lines of code, probably move to helper function.  Exactly.  If you look at implementation we have, that's exactly what's done.
	Go back to -- the Q 0 file you're given and look at the code for eval, return number, paren expr do that, otherwise I have helper function called eval bin expr and that was, hey go ahead and see if it's add, mulls, sub, and if not, give a very crafted error message, and notice, this is the fun part, I don't know if it's the fun part.  We're doing implementing this language here.  Somebody else wrote a program and they included a bin OP that was not add, mull, or sub, maybe they misspelled something.  
	We're ones generating error message that programmer is going to have to figure out.  Maybe they misspelled add.  Maybe they thought DIV was one of operators and wasn't.  This is exactly where, now for this project, you don't need to, you only need to handle valid programs.  
	You don't need to worry about if somebody gives invalid program. 
If you want to, go ahead and handle that and you get to make the error messages.
	We found in that example we did.  Using left-hand side and right-hand side all of the time so I go ahead and pulling up left field and evaluating that, give it a name since we use it so many times.
	So I used let star forgive ourselves a name.  Let us use those local names.
	Okay.  So that's, what we just wrote is better served in helper function.  Parity, expr, well great, pull out that first expression, which could be a huge hairy expression, but evaluate it, give it a single number.
	Ask if it's even.  -- if that number is even -- then hey, again we have this example we did down here.  Evaluate this whole thing, even if big huge expression, evaluate it, if comes back and even, the answer should be this, otherwise it should be that.  Sounds like IF statement to me, ask if even, after evaluating, if so, that first expression evaluated, otherwise it's third expression evaluated.
	Okay.  So, go ahead and take a break, that's writing the entire function eval there, follows from the template.  Fact we have to worry about mul and options, that was a pain, but otherwise it's a code that follows directly from the template.
	And again, we look in Q 30 for that and sigh the -- template when you look at the code for eval.
	So --back at 18:55 p.m., see you momentarily.
	[Break Time] 
	[Break Time] 
	PROFESSOR:  Questions?  Thoughts, we have internal representation of, the grammar defines the language, the grammar, we'll represent the parse trees, the grammar defines inside our program.  So we have data definition for that and applying template for that data definition, and written evaluator for this function eval, think of this as calculator function.  Program.  Except it handles things arbitrarily, nested arbitrarily deep.
	And we go ahead and run check-expects in here -- and, the full, the student language doesn't allow that template syntax problem.
	And these are data definition from different files, I'm not going to run those.  I'm going to give one more expression here.  I want one where the tree is nested kind of deep.  Just to sort of, we can really appreciate what's going on.  And how that recursion is working on there.  
	Let's go ahead and I'm going to, I'll give a tree, writing this down here and I'll finish it.
	Okay.  So looking at this tree here, now I can't see what I'm -- there we are.
	So, what is this?  We have bin expr, that is something multiplied by something, that parentheses expression, happens to be a parity expression and it's 3 followed by, oops, I have miss stage 3 followed by, well, 4 add 5 and third child.  Parity expression need a third branch, right.  Parity have 3 exprs inside them.  So can I write down one more.
	There we are, here is challenge, write down the string ta corresponds to this, string of the language that corresponds to this string.
	Hold it up so visible.  Tell you what, take a guided tour.  Start writing a string that looks like this, bin expr, with something mul and 7.
	You can do it -- I'll give you 7 seconds.
	We -- bin expr is something multiplied by 7.
	If it's been expr what's the first character?  Yeah.  Exactly.  So -- thanks mark.  We have that.  Now let's look at that first...., zoom in, given it's a paren expr, can somebody expand on what Mark has, replace that.... with something that's paren expr.
	A paren expr has to start with bracket, bracket.
	Some expr in bracket, bracket.
	Take that, and paste it into, ..., yeah.  This too easy?  -- paren expr has bracket then something and bracket, bracket.  What's that one thing inside bracket, it's parity expr, that's going to be parity something even colon something odd colon, how do I know this?  I'm reading off grammar Q 0.  That's what I plugged in for the -- for the dot, dot, dot.
	That parity expr.
	We have bin expr involving something of mul of 7, and that something is paren expr and paren expr is a parity expr.
	Okay.
	Parity, first child that parity expr was just 3.  And the next one was a bin expr, 4 add 5.
	So I'm going to copy and paste, replace that first dot, dot, dot, with 3, the second dot, dot, dot, with the expression that corresponds to 4 add 5.  Open paren, add 4, 5, close paren, the grammar tells me that's how I get the bin expr for 4 plus 5.  And I have keyword odd and something, semicolon and bracket, bracket etc... carrying that along.
	We don't have this last here, this was a whole other parity expression, okay, take that last copy and paste whatever I had before and I'll putting in for last dot, dot, dot, is parity expression, from the grammar starts with the word parity, this is parity 3, the keyword even colon then 4, and keyword odd colon and then a 5 and then semicolon -- and if you look closely, after semicolon, they're then, that's all replace that parity 3, even 4, add 5 semicolon, that got replaced for that last dot, dot, dot -- there was another semicolon, I leave that there, dot, dot, dot, expanded to semicolon.
	If you gave me this -- abstract syntax tree, how would I figure out what string gave rise to it, that's what I would say.  Where did my mul 7 go.  Sorry the lost the 7.
	7 and close paren -- okay.
	So -- this whole thing is a string and one minor knit pick what you did Mark, this whole thing is a string I would put in text editor, Q 0, go to Q 0.org or whatever and download ellipse plug in, and people start up eclipse and type in this, they would not put quotes around mul in source program.  
	This is the source code.  That source code, when you parse it, turns into tree, when we represent tree internally this is the tree we get.
	So --s and, I probably should have those quotes.
	Because in my tree there are strings and I want to be clear about that quote marks around the mul and add.
	How would I type this into Racket?  This tree?  -- I'll go ahead and -- if you want to do that, that's great.  I'm going to do this, it was a make bin expr of something and mole -- there we are.
	Something and mole and 7.  That first something was a make paren expr.  Okay.  And, what is make paren expr of?  Of something mole mul and 7, okay.  And that first thing was paren expr, of a parity expr -- make parity expr of something .  Okay.  Looking at that, that was a make parity expr, the first thing was 3 -- no problem -- the next part was a make bin expr of 4 add 5.
	Okay.  And very last thing down there was parity expr the 3, last child to the parity expr was another parity expr.  The parity expr 3, 4, 5, I can copy, paste that from line 13.
	Okay.  So that's the, I guess indented a bit more to the fully reflect the tree structure.  So I was making a more complicated expression to understand, I want to make sure we understand these trees.  All nest and so on.  Absolutely, it makes sure that string you typed in conforms to the grammar and how does it do that?  It builds the parse tree.  Absolutely.  Yeah.  And that's exactly what we're doing.  Actually I have not shown you how to parse yet, see if we get to that.
	Okay.  Yes,  so, the other thing I want to point out about this, is this was a make bin expr, something mul 7, now go and look at our code for -- for eval, and the bin expr.  Okay?  In particular, what if we're doing, if we had a mul or add or whatever, it's this thing here, okay?  -- and want to point out, E is the this entire tree here, okay, bin expr with 3 fields.  Eval of the left was already, let's see -- oops, I grabbed the wrong sheet, sorry.  Probably confusing.  Here is big bin expr.  Eval of the left is already the result of evaluating this whole thing.  Okay.  And so again that recursive call we get from the design recipe.  We started with the result of this whole tree and recursion is what goes going to -- follow recipe, we have code that correctly all of this, passes the test case -- no problem.
	I guess, we didn't say what expected value was, what is expected value of this?  Of this thing?  So the same one typed in the window, as a string, or the thing we have here in Racket as the Racket tree representation.  When you evaluate that, what should the answer be?  Something times 7.  What times 7?  Here is make parity expr.  3, that's not even so it's odd, use in one, and oh, it's another make parity expr, 3, next even, use 5.
	This evaluates to 5, this one evaluates to 5 and so -- 5 times 7 is 35.
	And so I may a well, oops, check-expect -- this is my examples of data, let me copy and paste it.
	Yeah.  Okay.  So auto again, more involved example and our code handled that correctly.  Okay.  How and again, don't, look at it and say this is going to make recursive call and make it do stuff.  verify were code for make parity 3, 4, 5, really does return 5.  And that's one of check-expect we did.  We checked that.  Make sure that you know this evaluates to whatever it does.  Turns out not to matter, make sure then say, given that I know this evaluates correctly, and this evaluates correctly, make sure, will my code for make parity expr evaluate correctly, because we're using this rural and this result, and putting this together by this code here.
	Evaluate the first one, 3, if even, well we don't do that.  We go ahead and look at the third one, third child evaluated and we decided yeah, that one works correctly, that's why this part works correctly.
	Okay.  Gosh, did make paren expr work correctly?  Yeah.  Make paren expr, if I know this part is giving right answer then I'm sure my code for eval will work correctly, for this part, make paren evaluates that one internal field.  If this whole thing correctly evaluates as 5, I know make bin expr of 5 mul and 7 will give me 35.  Don't try to unravel recursion from the top down, do it the same way, (Inaudible) look at small expression and make sure it works for that and then it will work for bigger expression and then it will work for bigger expression.  That's the way to think about it.  That was the code for eval in Racket.
	What's our next question?  -- what is the code for eval in Java.  There's nothing, we can implement this language, interpreter whatever language you like and let's go ahead and look at this, from the videos did this make more sense, wait, Steve watched the videos -- others have not.
	How do we do an union type in Java?  I think about how we did for ancestor tree and talked about that.  expr is one of 4 things.  Okay, that's what this picture here is giving us, and expr, abstract class expr, and then have 4 things.
	Each of those we tell Java, bin expr is type of expr, parity expr is type of expr.  How do we tell Java that.  We have class bin expr extends expr.
	That's how we tell Java, in Racket that was comment in the code, expr is one of following 4 things.
	In Java it's part of the code.  That's how it knows one type of expr is bin expr.  And class expr, class expr was that correct class -- with no fields, and -- think of it being just one line here.  Abstract class expr with nothing in it.  To say this is a type expr and exprs themselves don't have any fields all subclasses have their fields and so on.  Okay.
	Yeah, so that's how we go ahead and, rats -- blue Jay gets excited sometimes and tries to add line that's should not be there.
	Making the diagram look for complicated than it really is.
	Okay.
	So -- yeah, we have class expr and all of these 4 subclasses, don't worry about this pair, T, U, separate things used for the project, you don't need to worry about that.  What is the green stuff?  -- we have these other classes, bin expr test, parity expr test, this particular understands those and put test class next to where they're testing.
	In Java everything in separate class, taken exact same code but shattered among 8 files, 10 files.
	So -- okay.  The one other things that interesting, really we said a number, our data definition, expr can be bin expr or bin expr or plain number.  In Racket we used number, in Racket data definition, for Q 0, we said okay, how do we do this in Racket, say a number, we'll consider a number as expr.
	Okay, in Java I need to actually satisfy the type system.  I need to say numbers are exprs.  I can't say class double expends expr.  Class double has been finished, locked down and can't access it any more.  Probably a good thing.  What do we need to do?  Jump through a little hoop here, hoop that's only required because we have to satisfy the b object system in Java and tell it the relation.
	I'll make a class numb, all it does is contain a double.  It's a stupid class, contain a double and say class numb.  If you look at it, class numb extends, extend value but come back to that.
	Class num expend stends expr.  A num is an expression.  Because I am psychic and foresight, I inserted this extra class value between number and expr, the reason is, we're going to add one other type of value to this language.  Now we only have numbers.  But we'll add one more type of value to the language, so we'll want to hook that in as a subclass of values, some operations that are common to all values.  So we want to represent that.
	Okay.  Let's look at bin expr, we said, in Racket we had a struct bin expr with 3 fields, in Java, class bin expr extends expr.
	And has 3 field, expr left, right, string OP.
	And doing the same thing we saw in ancestor trees how we saw those translated to Java, same thing here.  There's other stuff, the constructor, Racket made construct tore for us that did what we wanted.  Java doesn't.  I need to make my own constructor here and take in the -- take in as many parameters an stuff into fields and so on.
	Okay.
	By the way can I make examples of Java in -- Java version.
	How do I make the number 3, internal representation of parse tree for 3 in Java.  What do I do for that?  I can't say, 3, I'd like to say 3, or 3.0 or something like that.  But that doesn't type check.  Java looks at that and says that's not expr.  I want 3, but as expr, new num of 3 -- okay.
	And, remember, class numb had one field I wrote constructor that took in one double and stuff it into that field.  We can even go, blue Jay double click on red object and shows interior of that object.
	I have double X and one that seems to be private -- we won't worry about that.
	Write me Java code, we seen Racket make a bin expr tree, give me, what tree did we use?  We used 3 plus 5.  Go ahead and make me the Java corresponding to that parse tree 3 plus 5.
	Bin expr, right, how do you make new bin expr object in Java?  Yeah, close up the P store that got opened up accidentally.  Because you're computing it running very slowly.
	Come on, quick, there's object called (Inaudible) we need to say it, new bin expr, do you want to make bin expr object, call contractor, what do we call contractor, left, right, OP, the constructor takes them, left, string OP and right.  I want to make 3 plus 5, so what are the 3 things that I passed?  -- I don't pass 3 here, why not -- exactly, type check, I need to give expr, that's the whole reason we do that.  Here the 5 will be similar, then there's type for OP, string, so give it internally the string add.  
	Okay.  So this here we can hit enter and turn off, call constructor, and look at it, it has 3 fields, left, right, OP and look at right expr and see there's 5, I can double click on this arrow here, there's the left object, so -- okay.
	You can actually see tree, bin expr with 2 children and string add.
	Great.
	Go ahead, take one of other things we did in Racket and make Java version for it.
	Make parity expr of 3, 4, 5.
	Give me the Java code for that.
	I'll give you 30 seconds.
	Do this on your own computer.
	Parity ox per, 3, 4, 5, same thing.  I want to make an object of type parity expr.
	And has 3 fields.  The condition, the even answer, the odd answer, okay.  Yeah, those were, gosh this new number.  3 -- 4 -- 5.  Okay, will the Java be for this one here?  A paren expr of 3 added to parity expr of 3, 4, 5.
	That's a, this one here, how do we make this, tree in Java?  That would go ahead and make new bin expr.
	Okay.
	The first thing is going to be a paren expr object.  That's, go ahead and say something, something, something, that first par -- is paren object and paren expr, just one field, and contractor takes one thing, expression and stuffs into the field.
	We wanted a paren expr of just 3, okay, new numb of 3 --okay, so we have 3, 3 add, and then another parity expr.  So this is getting long enough, break into multiple lines here, no problem.  Oops.
	Bin expr of that, and -- add, and a new parity expr.
	In fact, new parity expr of 3, 4, 5, copy and paste it -- why do extra typing, save the wrists.  And, that closes off parity expr and closed off bin expr.  I get back this object here.  It's bin expr, look at left and right fields -- left, and right.  Okay.  And the right was this, and that had 3 parts, a 3, 4, and 5 -- and now if you tilt your head to the left, what do you see?  You see this -- you see that exact tree.
	With the exception that this adhere looks like sitting in tree, really strings are other objects.  Actually is pointing off to another string object -- but -- okay.
	Anyway, so, how do people feel about that?  -- the representations of the tree -- the parse tree inside there?  No comment.  Again, I guess you'll, be here and then go back and watch the video we didn't watch before.  Maybe that will make it click.  And I'm not sure why I'm flipping things if you're still spending whole time talking about it -- okay.
	So, we have those things.  How do we write the code for say eval?  How does the code for eval work in Java?  Where do we put the code?  Do you remember back, how we did the trees in the ancestor trees when we did them in Java?  Yeah, the code for bin expr eval is inside bin expr and code for parity eval is inside parity.  Let's look at say the bin expr -- I don't know if that's bin expr, go ahead and look at eval -- okay.
	This is still -- that's some hole there.  Okay.
	I go ahead and use left star, go ahead and again template says, hey, go ahead and write this as -- eval, get given any inputs.  We sort of have one.  We got the bin expr named this.  And again, template said go ahead and take this, and go to the left side, and call eval on it.  Go to right and look at field called right and eval that, that's exactly in the Racket code as well.  We did it inside let star we setup 2 local variables called left value and right value.
	Let's forget o this double value for a second, and come back to that.
	Let's see if I keep Racket code to the background for bin expr, for eval --s okay.  This code here.
	Yeah, we have left value and right value like we did in the other code, we get those by calling eval on the other 2 sides.
	There we are.
	Okay.  And then we go through, if I use if else if, if add, go ahead and return, call the built in, scale Java's plus function, here we call it Racket plus function.
	If multiplying, if word is mul, call Java's multiplication like we did down here.  Okay.  So that same thing here, we throw in exception, either way.  Unknown binary operator, do that exact same thing in Java, unknown, make it look the same, binary operator.  Okay.  Yeah.  So everything is pretty much the same, few things that are different.  What are the things different between the Racket and this small things but why are they there and why do they need to be there.  If someone assigned to left value, what's different about the code in Racket and Java?  Racket we say, hey pull out the field left and call eval.
	Okay, we did.  So -- pull out the field left and call eval.  We had to do   more on that, turns out we want to be multiplying this, in Racket, whenever you call eval you get back a number -- and we're going to extend that in the future, going to return some value object.  We need to return a numb object or internal representation of the number.  I need to take this and I need to take, not going to be a raw double, it's a number object, our own class to wrap the double.  I made a method called double value and takes the object and grabs double out of it.  You call that method, we need to tell Racket, tell Java that thing really was a number.  
	If it wasn't a number, if it wasn't a number object and try to cast it, what does Java do if you put a cast to something and not actually that object at run time?  You get a class cast, it compressed compile time warning but run time check it's and gives narrative if this is one.
	We, add this extra stuff, called double value to extract it, we wrap our doubles in that extra class, but we extract appease type checker, I look at this, it becomes clearer to me after using un-typed system.  These are barriers being thrown up to that I can makes code complicated.  It's actually working to circumvent the type system.  This is the place where type system is just getting in my way and not helping.
	Usually with type system gives benefit for that investment.  Here it doesn't.  The other thing we do, take left value times right value, that's primitive double, we need to wrap that in our type that represents doubles, since it needs to be something that extends expr.  So that's extra step to the sort of making the types all check out.
	But, it's the same code.  Eval for bin expr, if you look at Java, eval for parity expr, paren expr, they're all similar.  What's the one other place I have to mention eval besides the 4 subclasses?  Up in the abstract class.  Why?  Java needs to know that, the, if you give me any expr, it's guaranteed I can call eval on it.  Just put anything all subclasses, Java would not know, maybe bar Linn will come tomorrow and add new subclass of expr and won't provide me val function, so, you can't call eval on an expr.
	But if I go to expr and tell it, every expr does have a method called eval.  -- returns a number, a value.
	Have to put once you have in abstract class and implement it.  If I come in tomorrow and make new type of expr and forget to supply code for eval.  That would be compile time error, you're making expr and every expr should have eval and you didn't provide an E veil.  Okay.
	So that should be pretty good.  Those are, that's the code for how we -- make internal trees.  How we write the code that handles these things.
	You'll be given that code, this code is on that web page, I LinkedIn the beginning and we'll go and add things to it.  But you'll have this as starting point if nothing else.
	But do you need this as starting point?  This is straight from following the design recipe.  It looks more complicated in Java but know how to build from the ground up in Racket without that.  So -- okay.
	Questions or thoughts on representing the tree   internally and writing code that's process the trees like eval?  -- so I provide 2 thing functions, eval and I also give you a 2 string.
	Follow straight from the design recipe, it works own all of the trees.
	Let's take a break and come back, the one last thing we talk about is parse, this is new topic, parsing, how do I take a string of characters and from that string of characters build that parse tree.  We were typing in the parse tree as a programmer, here is what that structure will look like -- we'll get our program to contract that tree from a plat input screen and let's take a break.
	Back at 19:44 p.m. -- 
	[Break Time] how are we doing, Steven how has your investment on watching the videos, how does it feel, does it make more sense seeing the videos or was it too slow going through it again.
	Okay, yeah -- hopefully it sunk in solidly.  And at the end we'll talk about what to do for this next week.
	Okay, so -- I want to finish up with talking about, parsing, so --
	You can think, we know the function, say this class for this thing here, it takes in a tree, and expr and returns a flat string, takes all that nice structure and collapses down and, just, it has a stream of individual characters, which is great if your trying to center over wire and print it.  You lose all the information, you lose what is a sub part of what.
	Parsing is the opposite, parsing is inverse operation.  Parsing means given a string, string with no hierarchal structure to it, build the hierarchy and see what's there.  -- and this is the same way that linguists use the term, they say parsing is taking the language, the sounds an symbols an figuring out the meaning behind them and that's what we're doing here, figuring out that.
	That structure, the organization of the language.
	Okay.  So, for us, parsing as a function, parsing as a string, give me the tree.
	How to do that?  Look at example.
	Not recording thank you.
	PROFESSOR:  Okay, so, parsing, parsing is, taking a string, oops did I say parsing string of string, it's late for me, too.
	Parsing means taking a string and get getting a tree back, which in this case we call expr, expr.
	So get back parse tree.
	And let's look at the code that does it.  First of all parsing takes in scanner object and returns an expr.
	Here, look at the code, do you want to look at Java code or Racket code for this?  I'll take I vote.  Same code, we'll look at them both, when do you want to look at first?  Parsing in Racket?  Parsing in Java, one vote Racket, another vote Racket, I guess.
	One vote for, switching to a different window, that would be too difficult.
	Okay, look at Racket version here, here is function parse, takes in scanner and returns something of type expr this data definition we gave here, either number, paren, bin, or parity expr.
	So -- this does not follow the template per se, why?  Because we're not processing an expr, we're processing a flat string but this problem ask so intertwined the the grammar it will still related to grammar in definition, I'm not going to start with template, I don't have different cases, I don't have fields to extract, I just have a string.
	So, what's the first thing I'm going to do?  Take the scanner and peak at the first token, think of this is what the Java function next does except I'm not reading off input.  I'm saying look at first word of input.  Group it together as a word.  Look at it, if that thing is, a number, okay?  -- then go ahead and, pop it off the input stream and return it.  Pop it off the input stream because that's what the function pop does, it takes scanner and returns, consumes first word off input stream.
	And return, fair enough.
	If on the other hand, now, it's a little more interesting, if I look at the first word of input and it happens to be the word -- parity.  Then, gosh, looking at grammar and, looking at grammar, if I see something that starts with PARITY, I know it looks like this, I need to, from the input stream, assume that word parity.  I know it's there then I can grab entire expression, how do I grab a whole expression off the input.  Remember this expression might be 3 but could be open paren 3 mul 5, or could be bracket, bracket, bracket, bracket, open paren, 3, mul another hole nested parity expression.
	That whole big expression would be the first expression in the thing we're trying to parse.  This is the cool part, what we call recursive parsing.
	Look at the code -- looking to, if I start with the word -- parity.  What do I do?  I call it open par writ.  I go and pop that off, and put in variable called open parity and never use that parity again, here is the cool part.
	Hey I now have a scanner, and front of scanner is some expression, read off one expression for the front of that scanner -- oh, okay.  Do I have a function, if you give scanner will it parse off one expression for the front of scanner, yeah, that's exactly what parse is.  This is recursive call here, this is the cool trick, hey, so I get a whole can ner that starts with parity, pull off parity, and then say make recursive call that pulls off entire next expression on scanner, builds a tree out of it, and gives back the tree so I call it sub expr one.
	What comes after that, that key world even -- okay.  Go ahead and, so pop, takes single word off the front of scanner, pop off ha one single word.  I'm not even going to check it was the word -- even.  I probably should check it.  But I'm going to assume it was the word -- even.
	And then I have another whole expr to read, another recursive call, that might consume a whole bunch of stuff off the front of my scanner or just the number 3 or return 3.  Why?  The recursive call might come up here and return just 3.
	Okay.  Yeah, so grab that second expression, after that second expression was another keyword, pull that one off, there's another sub expression, and then finally there was a semicolon so pop that off.  -- so, interesting thing, recursive calls to parse, those are the one that's returned a whole big tree and saved them in some variable, I'm going to let star here, and here is my answer -- make parity expr, -- have to remain in a structure.
	Pop is like, in Java it is, pop is, next.
	Calling the next method.  Consume the next token of input.  And, peak is -- not in Java, no equivalent --s.  It's a little bit like have, next you provide it.
	Some word.  And -- I don't know if you used -- sorry -- has next.
	If you provide -- has next to string, is the next word the string you gave me?/Did -- okay.  That's what we want here, that's how we do it.  We'll look at Java version in a second.
	So -- yeah, so pop is just, a grab the next thing from the input stream.  I'm thinking of input as big huge, not really a tack, it's more like a queue and give me next thing on the cue, except I never entered them, maybe DQ is a better word, you're right.
	Okay.
	I wrote pop myself and it's going to helper file you can go and look at the document if you want to see how it works.
	They calls lower level read functions for -- in Racket.
	So yeah, would he pulled off 3 sub expression, I have scanner, saw first word is parity, go ahead read, get a whole tree of interesting sub expression and throwaway, read off the filler keywords in in between those.
	And what is answer?  Make a parity expression and give it those 3 sub trees.  The 3 sub trees, that I got (Inaudible) if you see the subject express was (Inaudible) this called parse if 3 goes up here it would see that, you know, I have scanner here, starts with number, number 3, go ahead and pop off 3 and return it.  That's how 3 would get returned from this call here, if it was the 3.
	What if the thing here were parity expression, I have parity followed by some expression, if that expression itself was another parity expression, I would do this one, make recursive call come back and start going through and do the same thick again, read off that word parity of the netted one and grab the 3 and L even and then 4, and odd, and then 5, and semicolon.  
	Return a make parity 3, 4, 5, come back to top level call that I was making, return here the parity 3, 4, 5, it can go on top level parity.  Continue on working.
	So/-- this all works out and comes out easily.
	You can look at it, here is the the, what if I go and look and the first thing in the scanner, first token in scanner is square bracket, what do I do?  Let's look at grammar.  If I look at input screen and fairs thing is square bracket, read off square bracket, read off second square bracket that I know has to be there, since I never reuse these variables I'm kind of throwing it away.
	And then read the in exponential expression, after that, through recursive call, go ahead and read off 2 closing square brackets an here is my answer, make paren expression that contains just that one tree that I got recursively.
	So, what else.
	When, so I have, look back at grammar, have I handled all cases, need to handle with first thing is number, or square bracket, round bracket or word parity, and those are 4 types of expr, what do I do if it standards with rond bracket, that's what this code does.  If you have round bracket here, call, pop off at open paren and we have this expr of bin OP and expr.
	Here is expr, make recursive call, bin open is not huge long recursive call, it's one word, so I call pop and save it here, so I remember it.  Then the second one, read off closing paren, and, down here -- is my answer.  Make bin expr of thing that I sort nd sub expr one and the thing I saw in operator, this one word and saw in you remember expr 2.
	So.
	Okay, here for fun, I didn't do it before.  Yeah, it turns out we can use let for all of these as well.  I'm come back to that.  Just for fun I went ahead and said this thing that I popped off at the end and called it closing pair ran, the previous ones here I called pop off 2 square closing brackets, I didn't very phi they're square bracket, I should, but again, for this class, you can assume you're valid programs and you have to to parse and work with valid programs.
	And real world, what we do.  Something like this.  Check off, that thing that was closing, if not really closing paren, the thing that I popped at the end, then go ahead and throw an error.  Hey I ox expected closed paren.  Make sure that operator I pulled off is valid binary operators.
	If not, I throw an error.  Turns out this is in full Racket.  Full Racket has this operator called when, it's one armed (Inaudible) lost sound.
	Full Racket you go ahead and have side effects and have if's without else's.
	I have let star with 3 answers inside it, and what does full Racket do?  Evaluates this, no answer that comes back, evaluates this, and no value comes back from it, and then evaluate the third one, and return that.  So -- the difference between let star and let -- just the scope of each identifier, let star, this opened paren I can use in right hand, any of the following right-hand sides.
	I don't, since I don't I could have used let here.  Yeah, you could have used instead of the when's and so on, that would be fine as well.
	And could I used straight of let, because I'm not using previous local variables inside the right-hand side of other local variables.
	Let star is nested lets.
	Remember.  And by the way, if looking at this and it's not a number and first word is not parity and first token is not parity, and first token not square bracket, first token not pair remember that sis then I come down here and go unrecognized expression.
	And give one token I did not recognize.
	So -- that's how the recursive decent parsing works -- decent works.
	-- descent works.
	Let's look at it in Java.  Which class is parsing code in?  I remember asked that for eval, eval for bin expr want here and so on.
	Not there.  So on, remember we're not following the design recipe, I'm given a string, I'm not given any of these objects Annie inside these sub objects.
	I just have best plain string and best place to parse expression is up inside expr.
	So I have things here -- here is function expr and it's almost word-for-word the same as this Racket code we just looked at.
	Let's look at it.
	Well more verbose, hey, Java, verbose, I want to say if the next thing is a double, so I want to say, here is what I want to say, I want to say, again this is going to be a function that takes in a scanner object and returns an expr tree.  Expression tree.
	So -- here is what I want to say.  If S dot has next double -- -- here is what I want to say, return S dot next double else.
	That's what I want to say, if the first thing on in pult string is double, number, then go ahead and return it.  Now, actually though -- this would be a type error, because, spelling error, but after spelling error, it would be type error, we need to return expr, this returns double, we had that whole reason, that whole class in Java that we wrapped double inside (Inaudible) type checker.
	So new numb of next double.
	And now this looks awful any similar to Racket code.
	That's the part here.
	First thing is number, grab that number offer input and return it.  Okay.  If the next thing is number, grab that off input and return it.  Okay.  Here is the issue though.
	Has next double says, look at the next word of input and see if it looks like it, could be interpreted as double.  If so, you go ahead and read it off as a double.  But, unfortunately, we could have things like, if, sorry, what's that -- yeah, 3, plus, 4, okay.  If I look at this, here as input, okay.  And I say, hey, have a scanner read off the string, how many words in the string according to Java scanner, 2.  Open paren 3 is one word and there's space that separates words an plus 4 close paren, is second word.  If I did this, it would not recognize the 3 as double.  And certainly not recognize this as a double.  It would say, no there's par ran that sis in that word and doubles only have digits.
	If everything had been spaced out and required us to have spaces, this code would be okay.  This is a little, know anything about scanner now, I want to go ahead and say use scanner, but I want -- to, have word breaks not just be spaces but also want punctuation to count as the end of the word.
	No easy way to do that with scanner, I have a function I wrote, has next double, splitting by and it takes in bunch of punctuation, punctuation is constant string that has all things that count as punctuation.
	So that's what we had to do.  I wanted to do this, but, the moment that the actual input didn't have spaces around everything single double, that's a pain, well, I'm make this my own function, has next double splitting by, punctuation, passing string, everything you want to spit by.  That's why we have this code.
	Has next double, splitting that punctuation.
	Then return new num, splitting by that.  Else, and a Racket code was look for the word parity, see what the Java code does.  It does the same thing, else if has next splitting by, okay, if we have, well parity expr dot token, that's parity expr and name constant for the word parity, it comes up in several places in yav jav, I decided to give it as name constant.  I could have just sort of had, string right here -- if has next splitting by, if this scanner contains this, splitting by this punctuation, then what do we do.  Okay, we're going to do that, let me undo that.
	Put that name constant back.
	Okay, what do I do?  Go ahead and consume the word parity.  Call next.  Again, wherever you see, next splitting by and has next splitting by, think of has next double.
	They're all analogs.
	They're all inside the class utilitarian -- 	go ahead and consume parity and I called next, so-called S dot next and didn't do anything with the result.  Didn't store in variable or anything.  Here is recursive call, now that's done, go ahead and, hey for this input scanner here, parse off the front of this.  Okay.  And now that's kind of cool.  That's what goes an we'll read one expression off the front of this no matter how long or short it is.  Read entire sub expression, save in variable.  Get over this extra filler word, read entire expression, save in variable.  Get over the next filler word, read entire expression.  Save in variable.
	-- and that's, oops should be semicolon there.  Okay.  And remember that, we entered with semicolon and go ahead, this is assert, to the next character was a semicolon and then go ahead and consume it, get it off input stream.
	And then a return, this new parity expression and give it 3 big sub tree that's come back from recursive calls.
	This is exactly the same as Racket code, line for line, word-for-word just about.
	With a few differences because libraries are different and the type system has a few extra requirements.
	-- okay.
	So, questions about, about that recursive decent parsing?  -- you can go through and look at other cases there, and what happened, each one follows along the code, and let me go, back and give one more, few salient points about it, and look at description I gave in here.
	Parse, takes in scanner returns expression, returns parse tree representation of first (Inaudible), okay.
	So, great give me a scanner object, read stuff off the front of it, give me the parse tree for that.  And as side effect, it's important we do this, it consumes the stuff off the front of scanner, corresponding exactly to the expression we build.  The scanner can have a whole lot of stuff on it.  We'll read one expr and stop.  And might be more stuff in the scanner, that's fine.  Our job is to read exactly one expression off the front of it and no more.
	That's really important for the way this recursive parsing works.
	Why?  Because, I come along here, I'm coming along, I say this part here, read off exactly one expression.  Inside of, the word parity followed by some expression, followed by the keyword even.  I want recursive call to read off that one expression and then stop, my job to do the whole parity expression and keywords even and odd.  My recursive call should not read too much off the front.  It better not read only part of expression on the front and leave a little crust there.  Important that it cleans off one expression off the front.
	In particular that code we barely looked at in Java -- go ahead, after the parity pop off semicolon, it's important you grap that last semicolon, even though we don't use in the answer, it's important for the side effect, we consume exactly one expr in the front of scanner, that's the purpose of this function.  So -- get exactly one expr off the front of it.
	So -- okay.
	Kind of make sense?  Is that totally lost, especially for the first 2 hours.  I get the feeling the first couple of hours people were mostly vegging out.  Is that true?  -- VEGGING out, is that true?  -- maybe, maybe not.  -- yeah.  Do we want to try flipping?  Should I give you lectures that will, assume that you watched by the time we start next team.
	Here I went over everything again -- so -- it wasn't flipped at all.  It's only going to work if people actually do it.
	Maybe I should give quizzes if we say we're going to flip.
	Yeah, every year I do this, I spend different time on things, depending how much feedback I get.  If getting no feedback, I slow down.  Okay, how do other people feel.
	Should we try giving flip lectures, talking about prologue in the next bit, so, should give one or 2 hours that are flipped and review and not, cover new material?  -- Steven prefers them, -- mark, so -- 2 to 0, but many people not voting -- and so we'll say, you rather not do it.
	But, I guess here is the flip-side, if we flip I want to start with a, some quizzes, a little quiz question, that sort of, if you had watched them you o would get it, otherwise you would not.
	It may not be 3 hours worth ever video, but maybe hour and a half worth of video and then get into it.
	Yeah, -- I can't stop the class because some people are catching up, unfortunately.  You can vote no on the flipping and I'll go by the majority choice here.
	Feel free to say no if you don't want to do flip.  I'm not vested either way.
	I'm apt to go.
	Need to hear from Steve Tanner and Aaron and I can send e-mail, too.
	So -- we only have 3 more classes, crap only 3 more classes?  Is that true?  I guess it is.
	Yeah.
	Okay.
	Okay.  Yeah, they'll be a final, at the end as well.  It will be similar, take home, open book, based on -- stuff on the class page and so on.
	So -- yeah, flip but not have a quiz -- again, that's whole incentive to make sure people are doing it.  Without that people don't do it.  But, we'll see.  Maybe, few minutes into it, a quick review.  Okay.
	The time limit will be, what you'll do, I'll have instructions on this, when I post on D 2 L.  Look at D 2 L, instructions are there.  Don't download the exam until your ready to take it.  Once you download, submit to Dropbox in whatever 2 hours, or whatever the time limit is going to be.  So study, look at the practice exam.  
	Anybody have questions on the practice exam by the way?  -- there's practice exam, solution goes with it, it follows exactly from the design recipe, that's the goal of that problem, follow the designer recipe, applying to made up data type, but hey, union type, certain number of branches, 2 of branches have sub field, pull them out, think about what type they are, if needs recursion, make that recursive call there.
	Yeah, if you think about it, it's a list -- if you think about data type it's similar to a list, not the same but close.  List with within a list, within a list, within a list.  Yeah, it's a list, you don't need to think about it, designer recipe guides you through it.  That was the intent on that problem.  So -- okay, if there's no questions I can stay around, but no questions, on practice exam we're free to break early tonight.
	That was the exam from last year, so it will be similar.  Similar to the practice, yes.  I'll have to come up with similar questions tomorrow.
	And again, my goal is there's no surprises, if you can do the things we've been doing in class and homework's, hopefully the exam should be routine.
	Sometimes I don't hit that mark, sometimes student are not ready for that even if I were so we'll see how it goes.  Okay, sounds good, I'll see you next week and I'll hang around for questions as well.
	Okay, good night.
	See you.
	You will may you all have restful weeks.
	Yeah, sounds good.