Question
C++, Python, CoCo - Foundations of Programming Languages *All references to CoCo = CoCo Virtual Machine implemented in C++ and based on the Python Virtual
C++, Python, CoCo - Foundations of Programming Languages
*All references to CoCo = CoCo Virtual Machine implemented in C++ and based on the Python Virtual Machine. More details found at: http://knuth.luther.edu/~leekent/CoCo/
Problem 1:
Implement true division and floor division for floats in CoCo. Write a test program to thoroughly test these new operations supported by floats. The test program and the source code are both required for the solution to this problem. You may use the disassembler to help generate your test program.
Problem 2:
Alter the CoCo grammar to allow each line of a function's code to be either a CoCo instruction or a source code line. Any source code line should be preceeded by a pound sign, a line number, and a colon followed by the text of the source code line. A source code line would reflect a line from a source language other than CoCo which was compiled to the CoCo assembly language. Then, when an uncaught exception occurs in the CoCo program, the traceback should be printed along with the source code line that caused the exception. This is a challenging exercise and requires changes to the scanner, parser, internal storage of PyCode objects and traceback handling.
Problem 3(optional):
Empty type calls produce empty results in Python but not in CoCo. For instance, when int() is called in Python, the object () is created. In CoCo this produces an error. Use Python to determine what should happen for all the empty type calls that CoCo supports. Then modify CoCo so it will behave in a similar fashion.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started