Description
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Explanation & Answer
here you go....
What is the numerical range of a char?
A.-128 to 12...
Completion Status:
100%
Review
Review
Anonymous
Really helped me to better understand my coursework. Super recommended.
Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Most Popular Content
University at Albany Experience Using Databases and Structured Query Language Project
http://cs-people.bu.edu/azs/mf602/assignments/a10.htmlhttp://cs-people.bu.edu/azs/mf602/assignments/a10.html
University at Albany Experience Using Databases and Structured Query Language Project
http://cs-people.bu.edu/azs/mf602/assignments/a10.htmlhttp://cs-people.bu.edu/azs/mf602/assignments/a10.html
Project
CMSC 430 Project 3
The third project involves modifying the attached interpreter so that it interprets programs for the ...
Project
CMSC 430 Project 3
The third project involves modifying the attached interpreter so that it interprets programs for the
complete language.
You may convert all values to double values, although you can maintain their individual types if
you wish.
When the program is run on the command line, the parameters to the function should be supplied
as command line arguments. For example, for the following function header of a program in the
file text.txt:
function main a: integer, b: integer returns integer;
One would execute the program as follows:
$ ./compile < test.txt 2 4
In this case, the parameter a would be initialized to 2 and the parameter b to 4.
An example of a program execution is shown below:
$ ./compile < test.txt 2 4
1 function main a: integer, b: integer returns integer;
2 c: integer is
3 if a > b then
4 a rem b;
5 else
6 a ** 2;
7 endif;
8 begin
9 case a is
10 when 1 => c;
11 when 2 => (a + b / 2 - 4) * 3;
12 others => 4;
13 endcase;
14 end;
Compiled Successfully
Result = 0
After the compilation listing is output, the value of the expression which comprises the body of
the function should be displayed as shown above.
The existing code evaluates some of the arithmetic, relational and logical operators together with
the reduction statement and integer literals only. You are to add the necessary code to include all
of the following:
Real and Boolean literals
All additional arithmetic operators
All additional relational and logical operators
Both if and case statements
Functions with multiple variables
Functions with parameters
This project requires modification to the bison input file, so that it defines the additional the
necessary computations for the above added features. You will need to add functions to the
library of evaluation functions already provided in values.cc. You must also make some
modifications to the functions already provided.The fourth project involves modifying the semantic analyzer for the attached compiler by adding
checks for semantic errors. The static semantic rules of this language are the following:
Variables and parameter names have local scope. The scope rules require that all names be
declared and prohibit duplicate names within the same scope. The type correspondence rules are
as follows:
Boolean expressions cannot be used with arithmetic or relational operators.
Arithmetic expressions cannot be used with logical operators.
Reductions can only contain numeric types.
Only integer operands can be used with the remainder operator.
The two statements in an if statement must match in type. No coercion is performed.
All the statements in a case statement must match in type. No coercion is performed.
The type of the if expression must be Boolean.
The type of the case expression must be Integer
A narrowing variable initialization or function return occurs when a real value is being
forced into integer. Widening is permitted.
Boolean types cannot be mixed with numeric types in variable initializations or function
returns.
Type coercion from an integer to a real type is performed within arithmetic expressions.
You must make the following semantic checks. Those highlighted in yellow are already
performed by the code that you have been provided, although you are must make minor
modifications to account for the addition of real types and the need to perform type coercion and
to handle the additional arithmetic and logical operators.
Using Boolean Expressions with Arithmetic Operator
Using Boolean Expressions with Relational Operator
Using Arithmetic Expressions with Logical Operator
Reductions containing nonnumeric types
Remainder Operator Requires Integer Operands
If-Then Type Mismatch
Case Types Mismatch
If Condition Not Boolean
Case Expression Not Integer
Narrowing Variable Initialization
Variable Initialization Mismatch
Undeclared Variable
Duplicate Variable
Narrowing Function Return
This project requires modification to the bison input file, so that it defines the additional
semantic checks necessary to produce these errors and addition of functions to the library of type
checking functions already provided in types.cc. You must also make some modifications to
the functions provided. You need to add a check to the checkAssignment function for
mismatched types in the case that Boolean and numeric types are mixed. You need to also add
code to the checkArithmetic function to coerce integers to reals when the types are mixed and
the error message must be modified to indicate that numeric rather than only integer types are
permitted.
The provided code includes a template class Symbols that defines the symbol table. It already
includes a check for undeclared identifiers. You need to add a check for duplicate identifiers.
Like the lexical and syntax errors, the compiler should display the semantic errors in the
compilation listing, after the line in which they occur. An example of compilation listing output
containing semantic errors is shown below:
1 -- Test of Multiple Semantic Errors
2
3 function test a: integer returns integer;
4 b: integer is
5 if a + 5 then
6 2;
7 else
8 5;
9 endif;
Semantic Error, If Expression Must Be Boolean
10 c: real is 9.8 - 2 + 8;
11 d: boolean is 7 = f;
Semantic Error, Undeclared f
12 begin
13 case b is
14 when 1 => 4.5 + c;
15 when 2 => b;
Semantic Error, Case Types Mismatch
16 others => c;
17 endcase;
18 end;
Lexical Errors 0
Syntax Errors 0
Semantic Errors 3
You are to submit two file
34 pages
Final Paper
Hanakimi Uniforms is a small national clothing retailer chain specializing in educational and occupational based clothing ...
Final Paper
Hanakimi Uniforms is a small national clothing retailer chain specializing in educational and occupational based clothing options for all ages and ...
FIN 320 SNHU Principals of Finance & The Bensington Glass Company Discussion
Please see the attached for the questions. There are a total of 12 questions that involve Rate of Interest, Bond Valuatio ...
FIN 320 SNHU Principals of Finance & The Bensington Glass Company Discussion
Please see the attached for the questions. There are a total of 12 questions that involve Rate of Interest, Bond Valuation, Yield to Maturity, Bond Valuation Relationships and Inflation and interest rates.
16 pages
Assignmentfinal Copy 1
The Lasso and Ridge algorithms allow the undertaking of regression analysis on data with varying variable properties. Here ...
Assignmentfinal Copy 1
The Lasso and Ridge algorithms allow the undertaking of regression analysis on data with varying variable properties. Herein, an analysis of data is ...
University of California Irvine Inventory System for a Library Python Program
You are writing an inventory system for a library. This program will allow the user to enter a book, remove a book, and fi ...
University of California Irvine Inventory System for a Library Python Program
You are writing an inventory system for a library. This program will allow the user to enter a book, remove a book, and find a book. The book titles will be stored in a dictionary. Each key in the dictionary is a book’s title, and each value is the number of copies currently in stock. In a continuous loop, give the user the option to add a book, remove a book, find a book, and quit. If the user chooses to add a book, call a function named add_book. This function should ask the user for a book title. If the title is not in the dictionary, add it with a value of 1 to indicate there is now a single copy of that book in stock. If it is in the dictionary, update its value to indicate that another copy is now in stock.If the user chooses to find a book, call a function named find_book which asks the user for a book title. If the book’s title exists in the dictionary, print out how many copies of it are currently in stock. Otherwise, print that no copies are in stock. If the user chooses to remove a book, call a function named remove_book. In this function, ask the user to enter a title. If the title exists in the dictionary, remove a single copy. If there are no more copies in stock, remove the key/value pair from the dictionary. Hint: You may want to refer to the very end of lecture 12 for info on how to remove a specific key/value pair from a dictionary. If the user chooses quit, write all of the dictionary's information to a text file (i.e. store each book's name as well as how many copies of that book the library has in stock). Hint: Don't append! When the program starts, the data from the text file should be loaded into the dictionary (if the file exists).Previous
Similar Content
In this project, you will create a Doubly Linked List using you problems solving skills and what you know about Linked Lists (In Java).
For this project, you will take the LinkedList.java we created during our Linked List lecture and turn it into a DoublyLin...
DCCC C Programming Worksheet
The homework contains 4 problems: 1. CSAPP3 Problem 12.16 (https://www.cs.drexel.edu/~sph77/CS283/H6.html)
2. CS...
CSC 604 UNI Python Neural Networks and Deep Learning Final Project
CSC 604: Neural Networks and Deep Learning
Final Project
Object Detection in Hazardous Environment
Groups of three to fou...
American InterContinental University Programming Concepts Paper
10:38 AM (CT)
Unit 3 Individual Project
Assignment Overview
Type: Individual Project
Unit: Normalization & Relationshi...
How to create the hafh relational db using MySQL (in csmaster.sxu.ed/phpminiadmin). This db has the 9 tables. I also showed you how to drop from the db all its tables
How to create the hafh relational db using MySQL (in csmaster.sxu.ed/phpminiadmin). This db has the 9 tables.I also showe...
NVCC Operating System Discussion
Introduction:
The shell is a program that interacts with the user through a terminal or takes the input
from a file and ex...
Linux Installation
This report is aimed towards providing the installation steps for both Kali Linux and Volafox firewall on the same virtual...
Loops In Python
Loops in python are used to repeat a given block of code based on the satisfaction of the loop condition. Loops are useful...
Appscreens
...
Related Tags
Book Guides
Shattered - Inside Hillary Clintons Doomed Campaign
by Amie Parnes and Jonathan Allen
Steppenwolf
by Hermann Hesse
The 48 Laws of Power
by Robert Greene
Sounds Like Titanic
by Jessica Chiccehito Hindman
Bridge to Terabithia
by Katherine Paterson
Narrative of the Life of Frederick Douglass
by Frederick Douglass
Big Little Lies
by Liane Moriarty
Broke Millennial: Stop Scraping by and Get Your Financial Life Together
by Erin Lowry
The Picture of Dorian Gray
by Oscar Wilde
Get 24/7
Homework help
Our tutors provide high quality explanations & answers.
Post question
Most Popular Content
University at Albany Experience Using Databases and Structured Query Language Project
http://cs-people.bu.edu/azs/mf602/assignments/a10.htmlhttp://cs-people.bu.edu/azs/mf602/assignments/a10.html
University at Albany Experience Using Databases and Structured Query Language Project
http://cs-people.bu.edu/azs/mf602/assignments/a10.htmlhttp://cs-people.bu.edu/azs/mf602/assignments/a10.html
Project
CMSC 430 Project 3
The third project involves modifying the attached interpreter so that it interprets programs for the ...
Project
CMSC 430 Project 3
The third project involves modifying the attached interpreter so that it interprets programs for the
complete language.
You may convert all values to double values, although you can maintain their individual types if
you wish.
When the program is run on the command line, the parameters to the function should be supplied
as command line arguments. For example, for the following function header of a program in the
file text.txt:
function main a: integer, b: integer returns integer;
One would execute the program as follows:
$ ./compile < test.txt 2 4
In this case, the parameter a would be initialized to 2 and the parameter b to 4.
An example of a program execution is shown below:
$ ./compile < test.txt 2 4
1 function main a: integer, b: integer returns integer;
2 c: integer is
3 if a > b then
4 a rem b;
5 else
6 a ** 2;
7 endif;
8 begin
9 case a is
10 when 1 => c;
11 when 2 => (a + b / 2 - 4) * 3;
12 others => 4;
13 endcase;
14 end;
Compiled Successfully
Result = 0
After the compilation listing is output, the value of the expression which comprises the body of
the function should be displayed as shown above.
The existing code evaluates some of the arithmetic, relational and logical operators together with
the reduction statement and integer literals only. You are to add the necessary code to include all
of the following:
Real and Boolean literals
All additional arithmetic operators
All additional relational and logical operators
Both if and case statements
Functions with multiple variables
Functions with parameters
This project requires modification to the bison input file, so that it defines the additional the
necessary computations for the above added features. You will need to add functions to the
library of evaluation functions already provided in values.cc. You must also make some
modifications to the functions already provided.The fourth project involves modifying the semantic analyzer for the attached compiler by adding
checks for semantic errors. The static semantic rules of this language are the following:
Variables and parameter names have local scope. The scope rules require that all names be
declared and prohibit duplicate names within the same scope. The type correspondence rules are
as follows:
Boolean expressions cannot be used with arithmetic or relational operators.
Arithmetic expressions cannot be used with logical operators.
Reductions can only contain numeric types.
Only integer operands can be used with the remainder operator.
The two statements in an if statement must match in type. No coercion is performed.
All the statements in a case statement must match in type. No coercion is performed.
The type of the if expression must be Boolean.
The type of the case expression must be Integer
A narrowing variable initialization or function return occurs when a real value is being
forced into integer. Widening is permitted.
Boolean types cannot be mixed with numeric types in variable initializations or function
returns.
Type coercion from an integer to a real type is performed within arithmetic expressions.
You must make the following semantic checks. Those highlighted in yellow are already
performed by the code that you have been provided, although you are must make minor
modifications to account for the addition of real types and the need to perform type coercion and
to handle the additional arithmetic and logical operators.
Using Boolean Expressions with Arithmetic Operator
Using Boolean Expressions with Relational Operator
Using Arithmetic Expressions with Logical Operator
Reductions containing nonnumeric types
Remainder Operator Requires Integer Operands
If-Then Type Mismatch
Case Types Mismatch
If Condition Not Boolean
Case Expression Not Integer
Narrowing Variable Initialization
Variable Initialization Mismatch
Undeclared Variable
Duplicate Variable
Narrowing Function Return
This project requires modification to the bison input file, so that it defines the additional
semantic checks necessary to produce these errors and addition of functions to the library of type
checking functions already provided in types.cc. You must also make some modifications to
the functions provided. You need to add a check to the checkAssignment function for
mismatched types in the case that Boolean and numeric types are mixed. You need to also add
code to the checkArithmetic function to coerce integers to reals when the types are mixed and
the error message must be modified to indicate that numeric rather than only integer types are
permitted.
The provided code includes a template class Symbols that defines the symbol table. It already
includes a check for undeclared identifiers. You need to add a check for duplicate identifiers.
Like the lexical and syntax errors, the compiler should display the semantic errors in the
compilation listing, after the line in which they occur. An example of compilation listing output
containing semantic errors is shown below:
1 -- Test of Multiple Semantic Errors
2
3 function test a: integer returns integer;
4 b: integer is
5 if a + 5 then
6 2;
7 else
8 5;
9 endif;
Semantic Error, If Expression Must Be Boolean
10 c: real is 9.8 - 2 + 8;
11 d: boolean is 7 = f;
Semantic Error, Undeclared f
12 begin
13 case b is
14 when 1 => 4.5 + c;
15 when 2 => b;
Semantic Error, Case Types Mismatch
16 others => c;
17 endcase;
18 end;
Lexical Errors 0
Syntax Errors 0
Semantic Errors 3
You are to submit two file
34 pages
Final Paper
Hanakimi Uniforms is a small national clothing retailer chain specializing in educational and occupational based clothing ...
Final Paper
Hanakimi Uniforms is a small national clothing retailer chain specializing in educational and occupational based clothing options for all ages and ...
FIN 320 SNHU Principals of Finance & The Bensington Glass Company Discussion
Please see the attached for the questions. There are a total of 12 questions that involve Rate of Interest, Bond Valuatio ...
FIN 320 SNHU Principals of Finance & The Bensington Glass Company Discussion
Please see the attached for the questions. There are a total of 12 questions that involve Rate of Interest, Bond Valuation, Yield to Maturity, Bond Valuation Relationships and Inflation and interest rates.
16 pages
Assignmentfinal Copy 1
The Lasso and Ridge algorithms allow the undertaking of regression analysis on data with varying variable properties. Here ...
Assignmentfinal Copy 1
The Lasso and Ridge algorithms allow the undertaking of regression analysis on data with varying variable properties. Herein, an analysis of data is ...
University of California Irvine Inventory System for a Library Python Program
You are writing an inventory system for a library. This program will allow the user to enter a book, remove a book, and fi ...
University of California Irvine Inventory System for a Library Python Program
You are writing an inventory system for a library. This program will allow the user to enter a book, remove a book, and find a book. The book titles will be stored in a dictionary. Each key in the dictionary is a book’s title, and each value is the number of copies currently in stock. In a continuous loop, give the user the option to add a book, remove a book, find a book, and quit. If the user chooses to add a book, call a function named add_book. This function should ask the user for a book title. If the title is not in the dictionary, add it with a value of 1 to indicate there is now a single copy of that book in stock. If it is in the dictionary, update its value to indicate that another copy is now in stock.If the user chooses to find a book, call a function named find_book which asks the user for a book title. If the book’s title exists in the dictionary, print out how many copies of it are currently in stock. Otherwise, print that no copies are in stock. If the user chooses to remove a book, call a function named remove_book. In this function, ask the user to enter a title. If the title exists in the dictionary, remove a single copy. If there are no more copies in stock, remove the key/value pair from the dictionary. Hint: You may want to refer to the very end of lecture 12 for info on how to remove a specific key/value pair from a dictionary. If the user chooses quit, write all of the dictionary's information to a text file (i.e. store each book's name as well as how many copies of that book the library has in stock). Hint: Don't append! When the program starts, the data from the text file should be loaded into the dictionary (if the file exists).Previous
Earn money selling
your Study Documents