 Cool. So now let's talk about how to approach project three and Think about how we want to do that. So you already mentioned like okay I want to read in the input, right? And I want to think about how to design But I want to use like a 2d vector vector of vectors, right? So you think about kind of like a list right like two-dimensional thing, right you're gonna have Rows right and every row is gonna have so it's gonna be the first element in each of the Having it like that That's the first test case Like is that valid or is that just I don't know what's the first test case? As goes to little a big a As goes to z or a z a a Big a And then a goes to little b big b little c big b Okay, so then how's that gonna look when you finally so it's like do some backwards Right working just kind of really doing think about like what's the data structures that we want to have So I'm thinking of trying to do it that way. I don't know if that's just okay It's not bad. So this would be like vector zero is this list of the non terminals and then The first column Okay, yeah, so you have So this is gonna be expanding based on how many rules you have and this will never expand column-wise this way Yeah, right, okay, so one problem here in this section something I've never had talked about it yet But I realized I should have because some people had this problem They got to a problem like the last week of the project realized that it's crazy So part of the problem is so what are you storing in here? So what's inside each of these squares? so at first I was gonna be a string, but otherwise it'd be a node from the struct that has a string I don't know the word for it field I guess and then Other information like how many So part of what you have to do is think about how does this relate to this? Right because this is the context remember this is the abstract data that you're actually reading in and then the question is Does this accurately represent this and can you easily? Access elements in here that you're gonna want to do when you access certain things in here That's what I'm saying. So like for instance When you're calculating first sense, right? You want to know? What's the first? symbol here Right, so the first of the first of Z is on add to the first of the past year, right? so Can I easily? Can I do that? That was another thing that I wasn't sure about like if it's stored as a string in here Can you re-access that and determine exactly you have to essentially reparse it every time? Okay, so Will it work? Yeah, I suggest you do it like that. No, here's another way There's actually think about it. There's multiple concepts that you're putting in here I kind of have all of the non-terminals here at your first row And each of these represents One rule, right? So it's good that you have the structure here What about can you design it differently in like a 2d array that resembles more like this? Yeah in some sense switching the order, but Rip them apart Strings You can't go from here to here because in the string it goes the SAP and then it does the Ash and then it goes to this the production will so you can't really go from one to the other So you have to do it that way first and then here and you just kind of So Remember the nice thing about vectors and vectors is that you don't have to have Doesn't have to be a square right each of the lines can have different lines. Yeah So what are what's in here Now anytime you want to get inside here, you're gonna repart side again, so we're having it Have each each symbol be a different box Is that how it should be? I mean, is that an easier way to do it? So do what you're doing here do it like this and I'll leave and we'll try to see if that's easier than we have here This is basically the same thing you can do this because So Now if I said hey for rule so find number of these rules right one and I said, okay rule three At the first of the left most symbol on the right-hand side to the first of a How do you do that over here? So Right so the big difference here is there's inherent structure in these strings right there's an order to So you can rip that out right and represent so that your data represents the order here Then you can say things like start at the first right because then always you have to take the string Do space parsing on it to figure out which was the first one and then try to find it It gets me Same thing and having it in the order of having it separate makes so much more sense now because it's really well Okay, one other thing I want you to think about rows and columns Because you know when I think about like a vector Right each vector is a row in some sense, and then the first element of that is the column. Okay, there should be a way So that's actually definitely how you can represent the rules of The country grammar using But that's not the only thing it's like what are some other parts about a country grammar, right? So let's just describe the rules other What are the other important things about a country grammar? Exactly yeah, so like, you know maybe in addition to this you also want to keep another data structure. That's Symbols right so this would be so what are the symbols in this So you can create this list Right as you're going in part of these rules, right every time you flex and you say, okay I know this is the left-hand side of the rule right because your input is Obviously So you read this in so you can add S&B to your simple list Right and you can say hey So the other thing is just the symbols by themselves Yeah, well it kind of all depends you can either do it. Yeah, you can have two lists as like a terms And on terms bad, right? So this would be Parsing right you say get token, okay It's an S. Great. I know because it's in the first line that this is one of my non-termals great A added to my On hash great that means now I'm part of So I look at this I say this S better be a non-terminal But I create these rules because that's how it has to be and if it isn't one Do you just stop or do you continue and forget that line? I would say And then you part some arrow You get an arrow token and then you part something and you get an ID back you have to look at that ID and say is this a non-terminal Right if it's not then I've seen a new terminal and I can add it here And if you do it in order, right? This will tell you the order that they're at it Right we add a to our list of terminals when we see this token here because we know can they sign a description anything that's a symbol in one of these rules that is not a Terminal That we already know for that's not a non-terminal that we already know it must be a terminal See this we look at on the terminals and we go okay. It's not in there. So add it to my terminal Probably want to check me for some party in there And then you add that a here right and say, okay, I'm not creating Say like okay, I'm creating my rule list. So I have s that's the first element of my list a Right, I'm gonna read the next thing here Be a big a and I see oh, that's a non-terminal. That's great Here you get to the end so you know you're done with that rule. This is just your Right This is the result of you adding Also, so in the Pf of the product description has all the special different Strings that are terminal, but in all of the test cases none of them are anything but single letters Do we have to make sure that we will read full strings? Support like there's the example so there's the fact in more test cases Test case that we give you once they're on the assignment description. There are more test cases in there, right? I think those test cases in there use something. That's all for Right case doesn't matter at all Just about, you know, it's a non-terminal that's in this list. Otherwise So the problem then kind of becomes Right, so yeah, you should definitely like the way to attack the problem is get this all done in there So you've got it and you're correctly parsing everything once you have these rules and these terminals and non-termals Everything becomes so much easier because you can just deal with those and assume that those are correct implement first of all set rules Then you have to ask questions like How do I do that? How do I do because I have Calculate first sets you need to create initialize the empty sets for all of your non-termals I'd say, you know, first Right, I'm just doing it like this, but you would need to Think about how do I represent the set? What data structures am I going to do? How do I represent a set for each of these? Correct, you don't know how much is going to be necessarily in there. There's a few ways to do it You could actually, I believe, see if it was a set class that you would probably use Vectors are nice because You can say this vector is this one It'll add it, but it'll copy it. It'll make it the same thing. Oh, yes. Yes. Yes. Yeah That's part of the trick. That's part of the tricky things, exactly, is you need to like when you're doing set comparison, right? And you say the set containing, you know, A, B should be equal to the second A and B, C Right, so you just implemented this as a vector of A, B Right, the vector A, B is not equal to the other PAs, right? So the vector order matters, but here order doesn't matter So you have to make sure whatever data structure supports this, and also you're going to need the union operator So there is a set structure into this class, sort of? Pretty sure But you can do it using lists or actually one way to do it So part of the potential issue, which is having strings everywhere right, is like strings don't really mean anything. Once you read it in, all you care about are that this symbol is the same as this symbol You don't really care that that symbol is the string capital A If your program, all you need to know is these are the same, but these are different and it's different from everything else, so it's not just this A, right? You also want to know that it's a non-terminal, if that's important So you could represent them as numbers if you need to Exactly, yes With an enum, like would that be useful? So you can't use an enum because an enum is a compile time feature, right? An enum says this type will only be one of these end things You don't know what end is going to be beforehand, right? You can compile it, you can dynamic it, you don't know how much end is stuck to it We definitely use an integer, but you have to keep track of Which one is it? Exactly, exactly, yes And actually, it can make some things so much easier, like say I want to throw you out at one time, so And then it could help with Because the order doesn't matter, you can put it in numerical order and add them in, like in future, you can say What is this number? And then go to where that number should be, if it should be in there Exactly, you're using vectors to represent your sets And you have integers in here Before any time you compare them, you sort them, and you'll be able to know that they're The other thing about sets is There's no duplicate entries in a set, right? So you can't have a set like this You can just use vectors and you were to do like AA The vector AA is not equal to the vector A Because it's in length two and it's in length one But the sets, the sets they're equal, so you need to make sure that they're removed Before that, you'll only have unique elements This is why this project is tricky You're reading the input, you have to build the data structures You have to think about how to design the data structures And then you have to think about sets and how you're going to do sets Any questions on the design level? I haven't gotten very far, so I'm sure I'll come across more issues as I Go through it Start early Yeah