EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
数据结构代写
您的位置: 主页 > 编程案例 > 数据结构代写 >
代做数据结构:Last lab编译原理Fundamentals of Compiling 课程Lab CS留学生代写JAVA实现 - 数据结构代做
发布时间:2021-07-25 13:56:56浏览次数:
IntroductionZINC (for ZINC Is Not C) is a language that is similar to Ada. It is designed to provide you the experience writing a compiler without getting burdened by all of the complexities and details of a complete, standard programming language. (ZINC is adapted from an instructional language formerly used by Michael Franz in his CS241 course at University of California, Irvine.)Example ZINC Program1program2varN:integer;3varSQRT:integer;4begin5N:=readInt;6SQRT:=0;78--gountilSQRTexceedsthesquarerootofN}9whileSQRT*SQRT =Nloop10SQRT:=SQRT+1;11endwhile;1213SQRT:=SQRT-1;--subtractoneSQRTis =sqrt(N)1415writeInt(SQRT);1617end Language OverviewLexical FeaturesThe ZINC language is lexically simple. All identifiers start with a capital letter, and may contain only numbers, capital letters, and underscores. All keywords start with lower-case letters or are a symbol. The symbols ( , ) , := , , ** , * , div , mod , + , - , = , , , Data TypesZINC supports 32-bit integers ( integer ). Variables are always declared to be of a particular type, but the only type is integer.OperatorsZINC has several infix binary operators that work on integer operands. The multiplication * , division div , modulus mod , addition + , and subtraction - produce integer results. The comparison operators (i.e., equals = , not equal , less than , less-than or equal-to Control StructuresZINC is a structured programming language. The only control structures supported are if and while statements. Both take a boolean expression that guards the body of the control structure. In the case of an if statement, the statements after the then are executed if the expression is true, and the statements after the else (if there is one) are executed if the expression is false. In the case of the while statement, the loop is exited if the expression false; otherwise if the expression is true, the body will be executed, and then the expression will be re-evaluated.AssignmentAssignments are a kind of statement rather than a kind of operator. The := keyword is used to separate the left hand side (which is the variable being assigned to) from the right hand side, which is an expression that must be of the same type as the left hand side.Built-in ProceduresZINC does not support user-defined functions or procedures, but it does support one built-in procedures writeInt that outputs an integer and a new-line to the console (respectively), and one user-defined function, readInt that reads an integer from the console. The syntax for these is hard-coded into ZINC s BNF grammar.SyntaxCommentsThe occurrence of the character pair (two consecutive hyphens) on a line denotes the start of a comment that extends to the end of that line. For purposes of determining the lexical elements of the source file, the entire comment will be treated as if it were whitespace.Lexical ElementsIf the definition of a lexical element is in quotes, then it is meant to match exactly, the contained string. Otherwise, it is a regular expression. Square brackets in regular expressions are used as an abbreviation for matching ranges of letters. For example, [0-9] matches any digit, and [a-zA-Z] matches any English letter in capital or lower case.Numbers, Literals, and Identifiers:·num = (+|-)?[1-9][0-9]*|0The regular expression allows all natural numbers, but since we are using 32-bit integers, only -2147483648 through 2147483647 are valid integer constants. Integer constants outside of that range should be flagged as illegal.·ident = [A-Z][_A-Z0-9]*Symbols and Operators:·LP = ( ·RP = ) ·ASGN = := ·SC = ·COLON = : ·POWER = ** ·MULTIPLICATIVE = * | div | mod ·ADDITIVE = + | - ·COMPARE = = | | | | Keywords:·IF = if ·THEN = then ·ELSE = else ·BEGIN = begin ·END = end ·ENDIF = endif ·ENDWHILE = endwhile ·WHILE = while ·LOOP = loop ·PROGRAM = program ·VAR = var ·INT = integer Built-in Procedures:·WRITEINT = writeInt ·READINT = readInt BNF Grammar::=PROGRAMBEGINEND::=VARidentCOLONSC|ε::=INT::=SC|ε::=||||ε::=identASGN|identASGNREADINT::=IFTHENENDIF::=ELSE|ε::=WHILELOOPENDWHILE::=WRITEINT::=|COMPARE::=ADDITIVE|::=MULTIPLICATIVE|::=POWER|::=ident|num|LPRPOperator Precedence and AssociativityThe order of precedence among the operators is:1.The POWER operator.2.The MULTIPLICATIVE operators.3.The ADDITIVE operators.4.The COMPARE operators.All binary operators are left-associative.Type Rules1.The operands of all MULTIPLICATIVE, ADDITIVE, and COMPARE operators must be integers2.The MULTIPLICATIVE and ADDITIVE operators create an integer result.3.The COMPARE operators create integerresults (0 = “false”, non-zero = “true”);4.All variables must be declared, and may be declared only once.5.The left-hand of assignment must be a variable, and the right-hand side must be an expression of the variable s type.Semantics·Only those variables which have been declared can be assigned to or used.oAll integer variables and array elements are considered to have initial values of 0 .·All binary operators operate on signed integer operands:o x * y results in the product of x and y.o x div y which results in the integer quotient of x divided by y. The behavior is not defined if y is 0.o x mod y results in the remainder of x divided by y when x is non-negative and y is positive. Otherwise, the result is undefined.o“x ** y” results in x being raised to the power of y when y is non-negative. Otherwise, the result is undefined.o x + y results in the sum of x and y.o x y is the difference of y subtracted from x.o x = y is true if x and y are the same, otherwise it is false.o x y is false if x and y are the same, otherwise it is true.o x y is true if x is less than y, otherwise it is false.o x y is true if x is greater than y, otherwise it is false.o x oComputations on ZINC integers should be done using a 32-bit 2 s complement representation. Overflowing computations should simply wrap around that is, the result of all integer operations should be the integer that is not less than-231, not more than231-1, and congruent modulus232with the result of performing the normal mathematical operation on actual mathematical integers. · if statements evaluate their expression; if the expression is true, then the then-statements are executed, if it is false, the else-statements are executed.· while statements first evaluates its expression. If it is false, execution continues after the end of the while statement. If it is true, the statements in the body of the while loop are executed. After they finish executing, the expression is re-evaluated. As long as the expression is true, the process repeats itself, alternatively evaluating the expression and executing the statements in the body. Once the expression is false, execution continues after the end of the while loop.· writeInt evaluates its expression and outputs the result to the console and causes the cursor to move to the beginning of the next line.· readInt reads an integer from the console and updates an integer variable to hold that value.Write a program which contains alexical analyzer for theZinCprogramming language described in the document posted on Blackboard. The input to the program is aZinCprogram. The output will be a sequence ofif, while,etc.) is up to you. You canpreloadthe symbol table with them, OR you can have the lexical analyzer handle them as a special case. When the lexical analysis is finished, you should print out the contents of the symbol table you generated.For example if your program file starts:1program2varN:integer;3varSQRT:integer;4begin5N:=readInt;Then your output would be:Your program should be able to determine if an input source file (such as myprog.znc) has been passed as a shell argument. If no valid argument is given then a usage message should be printed and the use allowed to input the filnameof a ZinC language program. Output should go to standard outpu代写CS Finance|建模|代码|系统|报告|考试编程类:C++,JAVA ,数据库,WEB,Linux,Nodejs,JSP,Html,Prolog,Python,Haskell,hadoop算法,系统 机器学习金融类:统计,计量,风险投资,金融工程,R语言,Python语言,Matlab,建立模型,数据分析,数据处理服务类:Lab/Assignment/Project/Course/Qzui/Midterm/Final/Exam/Test帮助代写代考辅导E-mail:[email protected]微信:BadGeniuscs 工作时间:无休息工作日-早上8点到凌晨3点如果您用的手机请先保存二维码到手机里面,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。