代做CSCI3136、programming language代做、代写Python/Java程序设计、Python代写代写Python程

CSCI3136Assignment 7Consider the grammar for the Splat programming language in Figure 1, where the terminal intdenotes an integer, the terminal symbol, and the terminal string denotes a quoted string.�Figure 1: A grammar for the Splat language.Splat, is a functional language where all programs consist of one or more expressions. For now,an expression can be one of:1CSCI3136 Summer 2019 Assignment 7arithmetic expressions such as 1 + 2 * 3boolean expressions such as 1 2string expressions such as Hello + world!list expressions such as [a, b, c] and [3, 1, 2] + [4, 5, 6]Expressions in Splat are evaluated in the standard way. For example,1 + 2 * 3 evaluates to 71 2 evaluates to trueHello + world! evaluates to Hello world[3, 1, 2] + [4, 5, 6] evaluates to [3, 1, 2, 4, 5, 6]Formally, an expression is either a literalinteger such as 42,boolean such as truestring such as ”Hello”list of constants such as [1,2,3]or a composition of subexpressions and operators such as above. The expression is evaluated byapplying the operators just like in most programming languages. The operators in Splat are:Operator Description+ add two integersconcatenate two stringsconcatenate two lists- subtract one integer expression from another integer expression, e.g., 3 - 2negate an integer expression, e.g., -42*, / multiply and divide integer expressions, =, # compare two expressions: less than, greater than, equals, not equals&, |, ! combine boolean expressions with and, or, and notTable 1: Operators in Splat.All expressions are evaluated in the same way as in most other languages such as Java or Python.The list expression is evaluated by evaluating each of the elements of the list. E.g., the evaluationof [1+2, 3+4, Hello] is [3, 7 Hello].[50 marks] A recursive descent parser, called splat.1.py, (written in Python) that parses Splatprograms using the context-free grammar specified in Assignment 5 is provided as part of thisassignment. Using this parser, or your own version of the parser (implemented in a language ofyour choice) implement an evaluator that evaluates parsed expressions.Note: The provided solution automatically builds an abstract syntax tree (AST) as it parsesthe input. Each node in the AST contains a field called atoms which is the list of its children. TheAST differs from the parse tree in that all the right-recursive parts of the parse tree are flattened.For example, The parse tree, rooted at TERM for the expression 1 + 2 + 3 is shown in Figure 2,where as the corresponding AST is shown in Figure 3.To evaluate the expressions, your evaluator will need either a parse tree, or an abstract syntaxtree. Note: it is impossible to evaluate the expressions without a tree representation. The outputof your evaluator should evaluate the expressions and print out the results.2CSCI3136 Summer 2019 Assignment 7Figure 2: Parse tree for 1 ? 2 + 3 Figure 3: Abstract syntax tree for 1 ? 2 + 3The following evaluation rules apply:? The evaluation of a literal or a symbol is just the literal or symbol.? The evaluation of a list is a list with each element evaluated.? The evaluation of an expression is the application of the operator to the subexpressions, e.g.,1 ? 2 + 3 should result in 2 being the output.? If an operator cannot be applied to a subexpression, the message Evaluation Error is outputtedand the evaluator should exit.All operators and their precedence in the grammar in Figure 1 should be implemented.The evaluator should print out the result of each of the the top-level evaluations (one per line),in the same format as the input. See the provided tests for examples.You may implement your evaluator in any language that you wish, but it must be runnable onthe bluenose server. The evaluator should take input from stdin and output to stdout.A set of test cases is provided for you to test your evaluator. A test script test.sh is providedto run the tests. Since the choice of language is up to you, you must provide a standard scriptcalled runme.sh to run your evaluator. For example the script for a Python solution looks like:#!/bin/sh# Command to run your programpython3 splat.2.pyTo submit this part of the assignment please use Brightspace. Remember, you need to includea script called runme.sh that will let the marker run your code.3CSCI3136: Assignment 7Summer 2019Student Name Login ID Student Number Student SignatureMarkFunctionality /25Structure /25Total /50Comments:Assignments are due by 9:00am on the due date. Assignments must be submitted electronicallyvia Brightspace. Plagiarism in assignment answers will not be tolerated. By submittingtheir answers to this assignment, the authors named above declare that its content is theiroriginal work and that they did not use any sources for its preparation other than the classnotes, the textbook, and ones explicitly acknowledged in the answers. Any suspected actof plagiarism will be reported to the Facultys Academic Integrity Officer and possibly to theSenate Discipline Committee. The penalty for academic dishonesty may range from failing thecourse to expulsion from the university, in accordance with Dalhousie University’s regulationsregarding academic integrity.本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp

QQ:99515681 或邮箱:[email protected] 微信:codehelp

你可能感兴趣的:(代做CSCI3136、programming language代做、代写Python/Java程序设计、Python代写代写Python程)