[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Held Friday, October 2, 1998
Notes
Exp ::= Term Exp.value = Term.value Term ::= Factor Term.value = Factor.value Factor ::= OPEN Exp CLOSE Factor.value = Exp.value
Factor ::= NUMBER Factor.value = NUMBER.value
Factor ::= NUMBER Factor.value = stringToNumber(NUMBER.string)
Exp_0 ::= Exp_1 + Term Exp_0.value = Exp_1.value + Term.value Exp_0 ::= Exp_1 - Term Exp_0.value = Exp_1.value - Term.value
yacc
or bison
, the rules will look like
exp ::= exp PLUS exp { $$ = $1 + $3; } exp ::= exp MINUS exp { $$ = $1 - $3; }
CUP
, the rules will look more like
exp ::= exp:e1 PLUS exp:e2
MULTIPLY
and DIVIDE
as tokens,
we might write something like
MulOp ::= MULTIPLY MulOp.fun = f(x,y) { return x * y; } MulOp ::= DIVIDE MulOp.fun = f(x,y) { return x / y; }
Term_0 ::= Term_1 MulOp Factor Term_0.value = MulOp.fun(Term_1.value, Factor.value)
exp_{} ::= LET declarations IN exp_{1} END
exp_{1}
should
be the type declarations available to
exp_{}
modified by the additional settings from
declarations
.
exp_{1}.typeTable = exp_{}.typeTable.extendWith(declarations.typeTable)
History
Back to Parsing, concluded. On to Abstract parse trees.
[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
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 Mon Oct 5 11:29:40 1998.
This page generated on Mon Oct 5 11:47:21 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu