Creating the lexical and syntax analyzer for a programming language that will be defined in this...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Creating the lexical and syntax analyzer for a programming language that will be defined in this problem. This language will be able to create variables, assign them value, calculate basic mathematic operations and relational operations for integers of different types, as well as variables that can be either. This program should be able to not only recognize the following operations but have a proper evaluation order that conforms to the real-life principles of mathematics for in order operations: a. Addition b. Subtraction c. Multiplication d. Division e. Module f. Less than g. Greater than h. Less than Equal To i. Greater than Equal To j. Equal To k. Not Equal To 1. Assignment m. (There must also be a way to break precedence, this is usually done with the use of parenthesis) Each program should have a clear beginning and end as well as a way to separate multiple statements. For integer literals you must be able to specify whether in memory this value should be saved as 1 byte, 2 bytes, 4 bytes or 8 bytes. Variables should be able to be declared but on in separate lines from the assignment of value. Variable names can only be 6-8 letters, cannot contain numbers, but may contain underscores. Language must be able to handle keywords to allow for loops, data type declarations, and selection statements. This question is assignment is 8-fold: a. (15 Points) Define the rules for recognizing all lexemes as their proper token, and clearly define integer token codes for each token required for this language Should have Regular Grammar, Regular Expression, or Finite Automat defined b. (15 Points) Define production rules for implementing the mathematical syntax of operators and operands, loops, variable declaration, selection statements Enforce a non PEMDAS (BODMAS) order of operation, must have at least 6 levels of precedence c. (10 points) Show whether every rule set in your language conforms to the standard of an LL Grammar. d. (5 points) Make sure it is not ambiguous grammar e. (15 points) Write a program that process all lexemes in a file by recognizing all tokens in a file, and produces a list of those tokens in order If a group of characters is not defined in your language your program should print an error message stating what went wrong and terminate (stop running) This program should be written in an Object-Oriented fashion This program should have comments to describe each method that is defined f. (10 points) Write a program or an extension to the above program that determines if the tokens conform to the correct syntax. g. (10 points) Create 4 test files that have different names where each should have 30 or more lexemes that can be converted into tokens Keywords cannot use the words while, for, do, if, int, short, long i. Keywords should be unique, if others share your same words, you may lose more points than this problem is worth You must clearly state the structure of your language with production rules 2 with no errors at all based on the language you created h. (20 points) Create a LR (1) parse table for your language. And show the trace of 4 code samples. Each must have 6 or more tokens. 1 with a at least 5 lexical errors based on the rules you defined i. Detail each error and say why it doesn't work 1 with at least 5 syntax errors based on the rules you defined i. Detail each error and say why it doesn't work Table must be provided, and the rules must be listed 2 code samples must have errors Show were these samples fail and pass the test Creating the lexical and syntax analyzer for a programming language that will be defined in this problem. This language will be able to create variables, assign them value, calculate basic mathematic operations and relational operations for integers of different types, as well as variables that can be either. This program should be able to not only recognize the following operations but have a proper evaluation order that conforms to the real-life principles of mathematics for in order operations: a. Addition b. Subtraction c. Multiplication d. Division e. Module f. Less than g. Greater than h. Less than Equal To i. Greater than Equal To j. Equal To k. Not Equal To 1. Assignment m. (There must also be a way to break precedence, this is usually done with the use of parenthesis) Each program should have a clear beginning and end as well as a way to separate multiple statements. For integer literals you must be able to specify whether in memory this value should be saved as 1 byte, 2 bytes, 4 bytes or 8 bytes. Variables should be able to be declared but on in separate lines from the assignment of value. Variable names can only be 6-8 letters, cannot contain numbers, but may contain underscores. Language must be able to handle keywords to allow for loops, data type declarations, and selection statements. This question is assignment is 8-fold: a. (15 Points) Define the rules for recognizing all lexemes as their proper token, and clearly define integer token codes for each token required for this language Should have Regular Grammar, Regular Expression, or Finite Automat defined b. (15 Points) Define production rules for implementing the mathematical syntax of operators and operands, loops, variable declaration, selection statements Enforce a non PEMDAS (BODMAS) order of operation, must have at least 6 levels of precedence c. (10 points) Show whether every rule set in your language conforms to the standard of an LL Grammar. d. (5 points) Make sure it is not ambiguous grammar e. (15 points) Write a program that process all lexemes in a file by recognizing all tokens in a file, and produces a list of those tokens in order If a group of characters is not defined in your language your program should print an error message stating what went wrong and terminate (stop running) This program should be written in an Object-Oriented fashion This program should have comments to describe each method that is defined f. (10 points) Write a program or an extension to the above program that determines if the tokens conform to the correct syntax. g. (10 points) Create 4 test files that have different names where each should have 30 or more lexemes that can be converted into tokens Keywords cannot use the words while, for, do, if, int, short, long i. Keywords should be unique, if others share your same words, you may lose more points than this problem is worth You must clearly state the structure of your language with production rules 2 with no errors at all based on the language you created h. (20 points) Create a LR (1) parse table for your language. And show the trace of 4 code samples. Each must have 6 or more tokens. 1 with a at least 5 lexical errors based on the rules you defined i. Detail each error and say why it doesn't work 1 with at least 5 syntax errors based on the rules you defined i. Detail each error and say why it doesn't work Table must be provided, and the rules must be listed 2 code samples must have errors Show were these samples fail and pass the test
Expert Answer:
Related Book For
Business Statistics In Practice
ISBN: 9780073401836
6th Edition
Authors: Bruce Bowerman, Richard O'Connell
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
answer all questions as instructed below. attend all questions. 4 Computer Vision (a) Explain why such a tiny number of 2D Gabor wavelets as shown in this sequence are so efficient at representing...
-
Explain and justify what stage current bubble is in ?Analyze the financial markets and contribution of participants that create the bubble? Justify and explain the factors that will cause this bubble...
-
The Carrefour Group reports the following description of its trading securities (titled "financial assets reported at fair value in the income statement"). These are financial assets held by the...
-
Why could a lenders expected return be lower when the risk premium is increased on a loan? In addition to the risk premium, how can a lender increase the expected return on a wholesale loan? A retail...
-
Consider the three models a. \(y=\beta_{0}+\beta_{1}(1 / x)+\varepsilon\) b. \(1 / y=\beta_{0}+\beta_{1} x+\varepsilon\) c. \(y=x /\left(\beta_{0}-\beta_{1} x ight)+\varepsilon\) All of these models...
-
The following table shows some simple student data as of the date 06/20/2015: The following transactions occur on 06/21/2015: Student 004 changes major from Math to Business. Student 005 is deleted...
-
Why does it later rise? How would you describe that in economic terms again?
-
A project manager went on a vacation and returned to discord. According to two stakeholders, stakeholder C is causing problems. Every day for the last two weeks, stakeholder C sent an email to the...
-
How is the three-month contract on LIBOR settled?
-
Explain whether interest is paid on (a) initial margin and (b) variation margin in a futures trade.
-
What is the difference between a known yield and a known dollar income?
-
What is the limitation of duration-based hedging?
-
Draw up G. Stoner's statement of financial position from the following information as at 31 December 2015: Capital 44,400 Accounts receivable 1,600 Car 16,600 Accounts payable 1,800 Equipment 15,800...
-
The Max- Min theorem states that: 1) If f has neither an absolute Max nor an absolute Min on [a, b], then f is not continuous on [a,b] 2) fis continuous on [a, b], iff f has an absolute Max and an...
-
What is a content filter? Where is it placed in the network to gain the best result for the organization?
-
The auditor for a large corporation routinely monitors cash disbursements. As part of this process, the auditor examines check request forms to determine whether they have been properly approved....
-
The following table summarizes investment outcomes and corresponding probabilities for a particular oil well" X = the outcome in $p(x) -$40,000 (no oil)................ .25 10,000 (some...
-
An investment broker reports that the yearly returns on common stocks are approximately normally distributed with a mean return of 12.4 percent and a standard deviation of 20.6 percent. On the other...
-
In the 2016 Olympics in Rio, after the 50 m freestyle competition, a problem with the pool was found. In lane 1 there was a gentle 1.2 cm/s current flowing in the direction that the swimmers were...
-
A soccer player takes a free kick from a spot that is 20 m from the goal. The ball leaves his foot at an angle of 32, and it eventually hits the crossbar of the goal, which is 2.4 m from the ground....
-
The moon completes one (circular) orbit of the earth in 27.3 days. The distance from the earth to the moon is 3.84 10 8 m. What is the moons centripetal acceleration?
Study smarter with the SolutionInn App