Week 5




Here is my finished Parser. I can't run it quite yet because I need to finish my bison code so that it will run. What I'm doing in this parser is taking my BNR Grammar and converting in to readable code for bison so it can follow my grammar and find things like loops, assignment statements, etc. You can see at the top I take my tokens for the operators and words that my program will you. We then have start of the grammar, "statement list" the broadest term in the grammar, which leads to questions, what is a statement list? following statement list we have its definition as " " or statement followed by a statement list(recursion so you can have as many statements as you'd like without coming with an error). Next, we need to define a statement, we define a statement as either an assignment statement, conditional statement(if then), loop statement(while),block statement, expression, and function call. Now we have multiple things to define, which will bring up other tiny question, which can be solved without adding too much problem. Following the code you will see how I define each statement and how I tackle the tiny questions that need to be solved. Finally, we arrive at the operators which is the final thing I define and finishes my parser for my tiny language.

Comments

  1. Great work this week, can't wait to see when you get Parser to run!

    ReplyDelete

Post a Comment

Popular posts from this blog

Week 9

Week 10

Week 11