Programming Assignment For Compiler Construction

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Programming Assignment for Compiler Construction

We wish to add a do-until statement to j--. For example,


do
{
x = x * x;
}
until (x > 1000);

a. Write a grammar rule for defining the context-free syntax for a new do-until
statement. (The grammar rule should be written in “grammar” text file with
comments at the start and at the end of rule.
/* rule start */
RULE
/* rule end */

b. Modify the Scanner to deal with any necessary new tokens. (The code
should be written in “Scanner.java” file with comments at the start and at the
end of code).
/* start of inserted code */
CODE
/* end of inserted code */
c. Modify the Parser to parse and return nodes for the do-until statement. (The
code should be written in “Parser.java” file with comments at the start and at
the end of code).
/* start of inserted code */
CODE
/* end of inserted code */

Note: All the required files and complete source code of j—compiler
(“jminusminus”) is available in files with the assignment. You can consult
any file to understand the compiler.

You might also like