Lexical analyzer and the compilation listing generator code

Assignment Help Theory of Computation
Reference no: EM133387312

Design and Implementation of Programming Languages

Project

The first project involves modifying the attached lexical analyzer and the compilation listing generator code. You need to make the following modifications to the lexical analyzer, scanner.l:

1. A new token ARROW should be added for the two character punctuation symbol =>.

2. The following reserved words should be added:

case, else, endcase, endif, if, others, real, then, when

Each reserved words should be a separate token. The token name should be the same as the lexeme, but in all upper case.

3. Two additional logical operators should be added. The lexeme for the first should be or and its token should be OROP. The second logical operator added should be not and its token should be NOTOP.

4. Five relational operators should be added. They are =, /=, >, >= and <=. All of the lexemes should be represented by the single token RELOP.

5. One additional lexeme should be added for the ADDOP token. It is binary -.

6. One additional lexeme should be added for the MULOP token. It is/.

7. A new token REMOP should be added for the remainder operator. Its lexeme should be
rem.

8. A new token EXPOP should be added for the exponentiation operator. Its lexeme should be **.

9. A second type of comment should be added that begins with // and ends with the end of line. As with the existing comment, no token should be returned.

10. The definition for the identifiers should be modified so that underscores can be included, however, consecutive underscores, leading and trailing underscores should not be permitted.

11. A real literal token should be added. It should begin with a sequence of one or more digits following by a decimal point followed by zero or more additional digits. It may optionally end with an exponent. If present, the exponent should begin with an e or E, followed by an optional plus or minus sign followed by one or more digits. The token should be named REAL_LITERAL.

12. A Boolean literal token should be added. It should have two lexemes, which are true and
false. The token should be named BOOL_LITERAL.

You must also modify the header file tokens.h to include each the new tokens mentioned above.

The compilation listing generator code should be modified as follows:

1. The lastLine function should be modified to compute the total number of errors. If any errors occurred the number of lexical, syntactic and semantic errors should be displayed.

If no errors occurred, it should display Compiled Successfully. It should return the total number of errors.
2. The appendError function should be modified to count the number of lexical, syntactic and semantic errors. The error message passed to it should be added to a queue of messages that occurred on that line.
3. The displayErrors function should be modified to display all the error messages that have occurred on the previous line and then clear the queue of messages.

An example of the output of a program with no lexical errors is shown below:

1 // Program with no errors 2
3 function test1 returns boolean;
4 begin
5 7 + 2 > 6 and 8 = 5 * (7 - 4);
6 end;

Compiled Successfully

Here is the required output for a program that contains more than one lexical error on the same line:

1 -- Function with two lexical errors 2
3 function test2 returns integer;
4 begin
5 7 $ 2 ^ (2 + 4);
Lexical Error, Invalid Character $ Lexical Error, Invalid Character ^
6 end;

Lexical Errors 2
Syntax Errors 0
Semantic Errors 0

You are to submit two files.

1. The first is a .zip file that contains all the source code for the project. The .zip file should contain the flex input file, which should be a .l file, all .cc and .h files and a makefile that builds the project.

2. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following:

a. A discussion of how you approached the project

b. A test plan that includes test cases that you have created indicating what aspects of the program each one is testing and a screen shot of your compiler run on that test case

c. A discussion of lessons learned from the project and any improvements that could be made

Reference no: EM133387312

Questions Cloud

What are common elements in the elect and college : What are common elements in the ELECT and College of early childhood education (CECE) and how, if any, has it raised the quality of early learning programs?
What developmentally appropriate practices were observed : What developmentally appropriate practices were observed to establish a positive and respectful learning environment for students? How does the teacher
Describe the social and emotional functions : Describe the social and emotional functions that preschool programs need to target to prevent childhood aggression Identify warning signs for potential
Write a personal statement about human development family : Write an compelling one-paragraph argument on why you wish to go to graduate school. Choose ONE program for which to write a personal statement
Lexical analyzer and the compilation listing generator code : CMSC 430 Design and Implementation of Programming Languages, The University of Maryland, lexical analyzer and the compilation listing generator code
What is the difference between nonbinary and genderqueer : What is the difference between nonbinary and genderqueer? How might medical professionals help or hinder transgender people's access to medical care?
Discuss the five most important accomplishments : After reviewing President Biden's State of the Union Address video below, discuss in specific detail, the five most important accomplishments
What question or problem is the author addressing : What question or problem is the author addressing? Methods used/population Does the research use established frameworks or take an innovative approach?
How are white people harmed by racism : How are white people harmed by racism? What are some ways white people can develop healthier racial identities?

Reviews

len3387312

4/11/2023 10:19:07 PM

However you did not submit the expected snapshots. The snapshops should be the output from the compiler you are building and not the code that makes the compiler. The snapshots should show that your compiler can compile the test cases provided with the assignment. It should also show any errors generated by the compiler. See attached example. In addition please add your screen shots to the document with your write-up.

Write a Review

Theory of Computation Questions & Answers

  The challenges of antonios wayfive basic goals often

the challenges of antonios wayfive basic goals often referred to as the backbone of antonios way were posted in

  How would an attacker break a caesar-style cipher

Julius Caesar used one of the earliest known cipher systems to communicate with Cicero in Rome while he was conquering Europe. Caesar knew that there was.

  Is the given grammar left or right recursive

Is the given grammar left or right recursive - describe these in detail because I am having a hard time trying to figure this all out.

  Construct a truth table for the given statement form

Construct a truth table for the given statement form, then state whether or not the given statement form is a tautology - Determine whether the following argument is valid.

  What output information is required of the ultimate product

What output information is required of the ultimate product - demonstrates an understanding of it which the client can use to validate that the correct problem

  Construct a truth table for each of the given arguments

Construct a truth table for each of the following arguments. Determine whether each argument is valid or invalid. Justify your answer with a complete or partial truth table.

  Write down the minimum expressions for the outputs

Assume that invalid BCD digits do not occur as inputs. Construct the truth table. Write down the minimum expressions for the outputs by inspection of the truth table. (Hint: Try to match output columns in the table with input columns .)

  Devise a scheme for converting hexadecimal directly

Convert to hexadecimal: 1457.1110.Round to two digits past the hexadecimal point. Convert to hexadecimal: 1457.1110. Round to two digits past the hexadecimal point. Convert your answer to binary, and then to octal.

  Find a busy beaver machine with four states

Find a busy beaver machine with four states by testing all possible Turing machines with four states and alphabet {1, B}.

  Redundant sequence identi cation

Redundant sequence identi cation

  If m is a dfa accepting language b

If M is a DFA accepting language B, then exchangeing the accept and reject states gives a new DFA accepting the complement of B. Does this work for an NFA, why?

  Company a which has been acquired by company b company a

company a which has been acquired by company b. company a was founded in 1956 in mobile alabama. the average age of its

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd