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

ICSI 311 Assignment 0 – Some Sample Programs in Shank

Program 1

Write a program that prints the first 12 Fibonacci numbers

Sample output:

  • 1
  • 1
  • 2
  • 3
  • 5
  • 8
  • 13
  • 21
  • 34
  • 55
  • 89
  • 144

Program 2

Write GCD both recursively and iteratively

Sample code:

https://www.freecodecamp.org/news/euclidian-gcd-algorithm-greatest-common-divisor/

Your output will simply be the GCD for the pair of numbers. Call your function with a few pairs and note in comments in your code the expected answer.

Rubric

The rubric for this assignment is pass/fail “did the student make a good faith effort.”

The code must be (reasonably) valid Shank. You cannot use Java, C, JavaScript or some other language.

ICSI 311 Assignment 1 – The Lexer

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.

This assignment must have three different source code files.

One file must be called Shank.java.

Shank.java must contain main. Your main must ensure that there is one and only one argument (args). If there are none or more than 1, it must print an appropriate error message and exit. That one argument will be considered as a filename. Your main must then use File.ReadAllLines to read all of the lines from the file denoted by filename.  Your main must instantiate one instance of your Lexer class (to be defined below). You must parse all lines using the lex method of the Lexer class. If lex throws an exception, you must catch the exception, print that there was an exception. You must then print each token out (this is a temporary step to show that it works) once the lexing is complete.

One file must be called Token.java. This file must contain a Token class. The token class is made up of an instance of an enum and a value string. There must be a public accessor for both the enum and the value string; the underlying variables must be private. You may create whatever constructors you choose.  The enum must be defined as containing values appropriate to what we will be processing. The definition of the enum should be public, but the instance inside Token must be private. We will add to this enum in the next several assignments.  You will find it helpful to create an appropriate “ToString” overload.

The final file must be called Lexer.java. The Lexer class must contain a lex method that accepts a single string and returns a collection (array or list) of Tokens. The lex method must use one or more state machine(s) to iterate over the input string and create appropriate Tokens. Any character not allowed by your state machine(s) should throw an exception. The lexer needs to accumulate characters for some types (consider 123 – we need to accumulate 1, then 2, then 3, then the state machine can tell that the number is complete because the next character is not a number).  

For this assignment, the allowable input consists of basic mathematical symbols and numbers such as you might find in Java. +, -, *, / and both positive and negative numbers, including decimals. Allow but ignore spaces/tabs. At the end of each line, add an “EndOfLine” token.

Some examples of valid input and the result output are:

InputOutput
an empty lineEndOfLine
5NUMBER (5) EndOfLine
5.23 – 8.5 + 3NUMBER(5.23) MINUS NUMBER(8.5) PLUS NUMBER(3) EndOfLine
8 * -4 + 99999NUMBER (8) TIMES NUMBER (-4) PLUS NUMBER (99999) EndOfLine
7 4 3 1NUMBER(7)  NUMBER(4) NUMBER(3) NUMBER(1) EndOfLine
+ – * /PLUS MINUS TIMES DIVIDE EndOfLine

HINTS

Do not wait until the assignment is nearly due to begin. Start early so that you can ask questions.

Write out your state machine(s) before you start coding.

Create some examples and walk through them with your state machine(s)

Test your work thoroughly before handing it in. Trade test cases with your friends to torture each other’s code. Do not hand in your test files.


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)
Basic.java/mainDoesn’t exist or named wrong  (0)  Exists and named correctly (5)
File readingNon-Existent (0)Uses some other mechanism for reading lines from a file(2) Uses RealAllLines(5)
Calling lexNon-Existent (0)Doesn’t call lex appropriately(3) Instantiates Lexer and calls lex for all lines (5)
Handling exceptionsDon’t handle exception (0)  Handles exception and prints message(5)
Printing resultsDoesn’t print results  Prints results appropriately(5)
Token.javaDoesn’t exist(0)One of: private enum, private value, has accessors (5)Two of: Exists, private enum, private value, has accessors (7)Exists, private enum, private value, has accessors (10)
Lexer.javaDoesn’t exist or no public lex method(0)  Exists, has public lex method(5)
State machine(s) – symbols handledNonexistent or never correct (0)Some cases handled(7)Most cases handled(13)All cases handled(20)
State machine(s) – numbers handledNonexistent or never correct (0)Some cases handled(7)Most cases handled(13)All cases handled(20)

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

编程代写
编程代写

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