这是一门ICSI 311的编程代写网课代上,介绍编程语言的设计和实现,包括语言特性、范式和设计决策。 简要介绍功能和逻辑编程范式并强化面向对象的概念。 讨论解释器、编译器、transpires 和虚拟机,包括词法分析、解析、语义分析、优化、代码生成。 自动机和状态机简介。 先决条件:ICSI/ICEN 210 和 I CSI/I CEN 213 要求 C 级或更高。 CoursePear留学生编程代写 @2009。

This assignment is extremely important – (nearly) every assignment after this one uses this one!

If you have bugs or missing features in this, you will need to fix them before you can continue on to new assignments. This is very typical in software development outside of school.

You must submit .java files. Any other file type will be ignored. Especially “.class” files.

You must not zip or otherwise compress your assignment. Blackboard will allow you to submit multiple files.

You must submit buildable .java files for credit.

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<b<2 style) so we don’t need any recursion. Implement a booleanExpression method in the parser that generates a booleanExpressionNode.

Previously, the only statement type we had was assignments. Now, we will add the loops and conditionals (if). The key thing to notice is that every statement is one of these. Make new functions for while, for and if, following the pattern that we have seen:

  1. Look for keywords to discern if this function is applicable
  2. If not, make sure that we haven’t taken any tokens and return null.

Add modulo to term, much the same as multiplication or division.

Right now, we can’t make an expression that references a variable. For example:

c:=b+1

We can add this by making factor accept an identifier (and creating a variableReferenceNode).

Testing

We can now test with real programs, so long as they don’t call functions (hint – that’s next). Use some of the test programs we wrote in our first assignment but remove the function calls. Make sure that they parse correctly.


Rubric
PoorOKGoodGreat
CommentsNone/Excessive (0)“What” not “Why”, few (5)Some “what” comments or missing some (7)Anything not obvious has reasoning (10)
Variable/Function namingSingle letters everywhere (0)Lots of abbreviations (5)Full words most of the time (8)Full words, descriptive (10)
ASTNodes – BooleanExpressionNone (0) Class present, some methods/members missing (3)All methods/members (5)
ASTNodes – WhileNone (0) Class present, some methods/members missing (3)All methods/members (5)
ASTNodes – ForNone (0) Class present, some methods/members missing (3)All methods/members (5)
ASTNodes – RepeatNone (0) Class present, some methods/members missing (3)All methods/members (5)
ASTNodes – IfNone (0) Class present, some methods/members missing (3)All methods/members (5)
Add ModuloNone (0) Token created (3)Token created and added to AST (5)
Parser – Boolean ExpressionsNone (0)Attempted (3) Boolean expressions added to AST (5)
Parser – WhileNone (0)Attempted (5) While AST nodes created (10)
Parser – IfNone (0)Attempted (5) If AST nodes created and chained correctly (10)
Parser – ForNone (0)Attempted (5) For AST nodes created (10)
Parser – RepeatNone (0)Attempted (5) Repeat AST nodes created (10)
Parser – Variable ReferencesNone (0)Attempted (3) Variables can be used as sources for assignment (5)
留学生编程代写

CoursePear™是一家服务全球留学生的专业代写
—-我们专注提供高质靠谱的美国、加拿大、英国、澳洲、新西兰代写服务。
—-我们专注提供Essay、统计、金融、CS、经济、数学等覆盖100+专业的作业代写服务。

留学生代写编程
留学生代写编程

CoursePear™提供各类学术服务,Essay代写Assignment代写Exam / Quiz助攻Dissertation / Thesis代写Problem Set代做等。