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:
Answer rating: 100% (QA)
To create the lexical and syntax analyzer for the programming language described we need to define the languages grammar and rules Heres an outline of ... View the full 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
-
Problem 1 (35 pts) - Equivalent Systems Consider the system shown to the right. The forces have been determined to be: F = 18 kN, F = 25 kN, and F3 = 12+ 14 kN. The force F is vertical. Determine an...
-
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...
-
Prepare journal entries to record the following transactions involving the short-term securities investments of Duke Co., all of which occurred during year 2013. a. On March 22, purchased 1,000...
-
You are trying to estimate the value of a property that you are interested in buying. The subject property is located at 322 Rock Creek Road in a new suburb of a large metropolitan area. The property...
-
The Trapani Company had the following actual data for 2006 and 2007: The basic production data at standard unit costs for the two years were Fixed factory overhead was budgeted at $98,000 per year....
-
Prepare common-sized financial statements for Leslie Fay for the period 19871991. For that same period, compute for Leslie Fay the ratios shown in Exhibit 2. Given these data, which financial...
-
Find the slope of the line that passes through the pair of points. (-42.86,5.8) and (3.86,4.6) Select the correct choice below and, if necessary, fill in the answer box to compl OA. The slope is...
-
The City of Castletons General Fund had the following post-closing trial balance at June 30, 2022, the end of its fiscal year: Debits Credits Cash $ 265,120 Sales Taxes Receivable 11,000 Taxes...
-
Assume a $6,500 investment and the following cash flows for two alternatives. Year Investment X Investment Y $ 1,000 $ 1,300 2 1,800 2,000 3 1,100 4 1,500 5 600 1,700 2,000 Under the payback method,...
-
How does risk and uncertainty factor into the calculation and interpretation of IRR? 10. How can sensitivity analysis be used to assess the impact of changing IRR assumptions? 11. Are there any...
-
6 3 Is the ordered pair 7' a solution of the equation 7a +5b 1? Select the correct choice below and, if necessary, fill in the answer box to complete your choice. 5 A. Yes because after substituting...
-
Public Relations (PR) is a promotional tool that is used by many companies. what are the benefits of this tool?
-
Thoroughly define organizational culture and provide three examples of different types of organizational cultures. Several sources and examples support thinking. explain how leaders and managers...
-
A dad pushes tangentially on a small hand-driven merry-go-round and is able to accelerate it from rest to a frequency of 14 rpm in 10.0 s. Assume the merry-go-round is a uniform disk of radius 2.5 m...
-
Albert Ellis and Gloria - Counselling 1965 Full Session - Rational Emotive Therapy 1)Why did the suicidal patient go to therapy? 2) What was her background? 3) What CBT techniques were used? Define...
-
KD Insurance Company specializes in term life insurance contracts. Cash collection experience shows that 20 percent of billed premiums are collected in the month before they are due, 60 percent are...
-
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...
-
(a) Fixed costs are really variable. The more you produce, the less they become. Do you agree? Explain. (b) In the long term, all costs are variable. Explain with reference to the relevant range.
-
How can you identify semi-variable costs and separate them into the fixed and variable elements?
-
What is a semi-variable cost?
Study smarter with the SolutionInn App