More statements

Responsive Centered Red Button

Need Help with this Question or something similar to this? We got you! Just fill out the order form (follow the link below), and your paper will be assigned to an expert to help you ASAP.

In this assignment, we will fill in the rest of the core functionality in the lexer and parser to give our language a “real” language feeling – calling functions, loops, and conditionals. We will also tweak our expression handling to allow us to use variables and we will also add modulo.

Lexer changes

We need to add several new keywords to our lexer. This is, remember, as easy as making new tokens and adding them to our hash map. You will need:

if, then, else, elsif, for, from, to, while, repeat, until, mod

We also need the boolean comparators (tokens and lexer changes):

>, <, >=, <=, =, <> (not equal)

AST Nodes

We need to make ASTNodes for:

BooleanExpression (has a left expression and a right expression and a condition)

While (booleanExpression and collection of statementNodes)

Repeat (booleanExpression and collection of statementNodes)

For (variableReference, start ASTNode, end astNode, collection of statementNodes)

If is a little bit interesting. How do we model that unlimited length chain of “elsif”?

A linked list: If (booleanExpression, collection of statementNodes, ifNode)

For else, you can either use a null boolean expression or make an ElseNode that derives from IfNode. One is more work now, one is more work later.

Add modulo to MathOpNode.

Parser Changes

Our simple boolean expressions are left-to-right, no precedence, so we can implement them without the expression-term-factor pattern. They also don’t chain (1 How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services