Held: Friday, February 6, 1998
Exp ::= Term
Exp.value = Term.value
Term ::= Factor
Term.value = Factor.value
Factor ::= '(' Exp ')'
Factor.value = Exp.value
AddOp ::= '+' AddOp.function = add AddOp ::= '-' AddOp.function = subtract MulOp ::= '*' MulOp.function = multiply MulOp ::= '/' MulOp.function = divide
Exp_0 ::= Exp_1 AddOp Term Exp_0.value = AddOp.function(Exp_1.value, Term.value) Term_0 ::= Term_1 MulOp Factor Term_0.value = AddOp.function(Term_1.value, Factor.value)
RELJMP.
Statement ::= if Exp then Statement else Statement
// Verify the type and initialize the list of errors
if Exp.type != Bool {
newerrs = [Statement_0.line, "Must use booleans in conditionals"]
}
else {
newerrs = [];
}
// Generate the code from the various components.
Statement_0.code =
Exp.code +
[RELJMPNONZERO Exp.loc length(Statement_1.code)+1] +
Statement_1.code +
[RELJMP length(Statement_2.code)] +
Statement_2.code;
Statement_0.errs =
newerrs + Statement_1.errs + Statement_2.errs
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Thu May 7 20:29:37 1998.
This page generated on Thu May 7 20:34:37 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu