CS/CE 4337 Project Fall 2021 Project (Part 2) This project will explore the topics learned in class, and give you some simple hands- on experience. After completing all three parts, you should have a...

1 answer below »
Someone helped me with this project previously order ID # was 92087 . This is kind of continuation of the project part 2 .if possible may be the same person can help me. I am attaching Lecter (chapter 6) and project part1 as well. let me know if anything needed


CS/CE 4337 Project Fall 2021 Project (Part 2) This project will explore the topics learned in class, and give you some simple hands- on experience. After completing all three parts, you should have a working interpreted language that is unique to you. You are encouraged to have fun and go above and beyond if you have the time. In Part 2 , you will then need to make another small, but substantial change, and create the parser for the modified language. Part 2 assumes you have your lexer form part 1. The changes you make may affect your lexer. So, you may need to go back and update the lexer. If for whatever reason, you do not want to use your lexer from part 1, a lexer will be provided. It will be attached to assignment, and contain instructions for using it. You will be making other changes to your language as the semester goes forward. So, take that into consideration when writing your code. All code should be written in either C,C++,Java, or Python. 1 What to do • Once again modify your language. Use the knowledge in class to decided what change to make. Think about when things should be bound, and the design issues the book presents for the language feature you are considering. For instance, In chapter 6, the book gives the method for implementing arrays. You can use this information to decide the exact kind of arrays you want (assuming that is the change you wish to make). • If the changes to your language causes the grammar to no longer be an LL grammar, then modify it. • Implement the recursive decent parser in your chosen language. At minimum the parser should tell if a program is in the language or not. Preferably, you should print out nice error messages. This will help you with debugging too. 2 What to turn in Upload your submission as a zip archive containing the following: • Source code (c, c++, python, or java files) – Source code should not require a particular IDE to compile and run. – Should work on the cs1 and cs2 machines • Readme (Plain text document) – List the files included in the archive and their purpose – Explain how to compile and run your project – Include any other notes that the TA may need Organization of Programming Languages Page 1 CS/CE 4337 Project Fall 2021 • Write-up (Microsoft Word or pdf format) – An description of your changes. This can be formal (modifying the grammar and semantics) or informal (A text description) – In addition, if you did not complete some feature of the project, why not? ∗ What unsolvable problems did you encounter? ∗ How did you try to solve the problems? ∗ Where do you think the solution might lay? · What would you do to try and solve the problem if you had more time? 3 Grading The grade for this project will be out of 100, and broken down as follows: The change to the language 25 The parser code 65 Correct Output 10 If you were not able to complete some part of the program discussing the problem and potential solutions in the write-up will reduce the points deducted for it. For example, suppose there is a bug in your code that sometimes allows two customers to approach the same worker, and could not figure out the problem before the due date. You can write 2-3 paragraphs in the write-up to discuss this issue. Identify the error and discuss what you have done to try to fix it/find the problem point, and discuss how you would proceed if you had more time. Overall, inform me and the TA that you know the problem exists and you seriously spend time trying to fix the problem. Normally you may lose 5 points (since it is a rare error) but with the write-up you only lose 2. These points can make a large difference if the problem is affecting a larger portion of the program. 4 The Base Language I provide a copy of the language from part 1 for convenience. 4.1 Syntax Ñ (1) Ñ �(2) | “;” (3) Ñ (4) |
(5) | (6) | (7) | (8) Organization of Programming Languages Page 2 CS/CE 4337 Project Fall 2021 Ñ “print” (9) Ñ STRING(10) | (11)

Ñ “get” ID(12) Ñ ID “=” (13) Ñ “if” “then” “else” “end”(14) Ñ “while” “do” “end”(15) Ñ (16) Ñ �(17) | “and” (18) | “or” (19) Ñ (20) Ñ �(21) | “+” (22) | “-” (23) Ñ (24) Ñ �(25) | “*” (26) | “/” (27) | “%” (28) Ñ (29) Ñ �(30) | “>” (31) | “>=” (32) | “<”>(33) | “<=”>(34) | “==” (35) | “!=” (36) Ñ “(” “)”(37) | “not” (38) | “-” (39) | ID(40) | INT(41) 4.1.1 Tokens This subsection describes the token used in the above grammar. Provided for each token is a regex and a description. The regex is for those that know regular expressions and prefer it as a description. The description says the same thing in English. Preprocessing describes how the lexeme is transformed before passing it to the parser. Organization of Programming Languages Page 3 CS/CE 4337 Project Fall 2021 STRING As a regex: "([ˆ"]|\")*" Description: A quotation mark followed by zero or more characters, where quo- tation marks must be preceded by a backslash, followed by another quotation mark. Preprocessing: The first and last quotation marks are removed. Scanning from left to right, “\\” is replaced with “\”, “\t” is replaced with a tab, “\n” is replaced with a newline, “\"” is replaced with “"”, and any “\” that is followed by anything else is removed. ID As regex: [_a-zA-Z][_a-zA-Z0-9]* Description: A letter or underscore followed by a combination of zero or more let- ters, underscores or digits. INT As Regex: (+|-)?[0-9]+ Description: an optional “+” or “-” followed by one or more digits. 4.2 Static Semantics 1 .ids “ tu 3 r0s.ids “ t .idu Y r0s.ids .ids “ r0s.ids 4 .ids “ .ids 5 .id “

.id 6 .id “ .id .ids “ .ids 7 .ids “ .ids 8 .ids “ .ids 9 .ids “ .ids 11 .ids “ .ids 12

.id “ ID .id 13 .id “ ID .id 16 .ids “ .ids “ Organization of Programming Languages Page 4 CS/CE 4337 Project Fall 2021 18 .ids “ 19 .ids “ 20 .ids “ .ids “ 22 .ids “ .ids 23 .ids “ .ids 24 .ids “ .ids .ids “ .ids 26 .ids “ .ids 27 .ids “ .ids 28 .ids “ .ids 29 .ids “ .ids .ids “ .ids 31 .ids “ .ids 32 .ids “ .ids 33 .ids “ .ids 34 .ids “ .ids 35 .ids “ .ids 36 .ids “ .ids 37 .ids “ .ids 38 r1s.ids “ r0s.ids 39 r1s.ids “ r0s.ids 40 Predicate: ID .id P .ids 4.3 Dynamic Semantics This section gives the dynamic semantics of the language using denotational semantics. Consider the demsem function the denotational semantics for this language. We will use a mapping from variable name to value to represent the symbol table of the program during execution, and in code can be represented as a HashMap or similar datatype in your language of choice. We will use a sequence of characters to represent the output of a program, with � representing the empty sequence. I will also assume that all strings will be represented as sequences of characters. Assume there is a function append that, when given two sequences, appends the second sequence to the first. Also assume, there is a function Organization of Programming Languages Page 5 CS/CE 4337 Project Fall 2021 seq that takes an integer and gives a sequence of characters representing that integer as text. Assume there are the functions head, which maps a sequence to its first element, tail, which maps a sequence to a new one created by removing the first element, clean, which maps a sequence of input characters to a new sequence by removing any non-digits from the front of the sequence, and int that maps a sequence of digits to the corresponding integer. If the sequence is empty, int will give zero. A state, as well as the meaning of a program, will be a 3-tuple consisting of a variable name mapping function, a sequence of input characters and an output sequence. The initial state for any program is ptu, i, �q, where i is some sequence of characters the user will input. If a token (represented by all caps and bold font) appears as a value on the right hand side of a function definition, then replace it with its lexeme. So if a ID was generated by the lexer from an x, then replace ID with x. densemp�, pθ, i, pqq “ pθ, i, pq densemp “;” , pθ, i, pqq “ densemp , densemp , pθ, i, pqqq densemp “print” STRING , pθ, i, pqq “ pθ, i, appendpp, STRING qq densemp “print” , pθ, i, pq “ pθ, i, appendpp, seqpoutqqq where out “ exprsemp q densemp “get” ID , pθ, i, pqq “ pθ1, i1, pq where px, i1q “ getIntpcleanpiqq θ1pnq “ if n “ ID then x else θpnq densemp ID “=” , pθ, i, pqq “ pθ1, i, pq where θ1pnq “ if n “ ID then exprsemp , θq else θpnq densemp , pθ, i, pqq “ if exprsemp . , θq ‰ 0 then densemp . r0s, pθ, i, pqq else densemp . r1s, pθ, i, pqq densemp , pθ, i, pqq “ if exprsemp . , θq “ 0 then pθ, i, pq else densemp , densemp . , pθ, i, pqqq exprsemp
Answered 94 days AfterOct 17, 2021

Answer To: CS/CE 4337 Project Fall 2021 Project (Part 2) This project will explore the topics learned in class,...

Karthi answered on Jan 19 2022
115 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here