Back to Pause for Breath. On to Introduction to Type Checking.
Held Friday, March 2, 2001
Summary
Overview
Exp ::= Term Exp.value = Term.value Exp.type = Term.type Term ::= Factor Term.value = Factor.value Term.type = Factor.type Factor ::= OPEN Exp CLOSE Factor.value = Exp.value Facator.type = Exp.type
Factor ::= NUMBER Factor.value = NUMBER.value Factor.type = NUMBER.type
Factor ::= NUMBER Factor.value = stringToNumber(NUMBER.string)
Factor ::= ID Factor.type = lookupType(symbols,ID)
Exp_0 ::= Exp_1 + Term Exp_0.value = Exp_1.value + Term.value Exp_0.type = mostGeneral(Exp1.type,Term,type) Exp_0 ::= Exp_1 - Term Exp_0.value = Exp_1.value - Term.value Exp_0.type = mostGeneral(Exp1.type,Term,type)
yacc
or bison
and pay
attention to only values, the rules will look like
exp ::= exp PLUS exp { $$ = $1 + $3; } exp ::= exp MINUS exp { $$ = $1 - $3; }
MULTIPLY
and DIVIDE
as tokens,
we might write something like
MulOp ::= MULTIPLY MulOp.fun = (lambda (x y) (* x y)) MulOp ::= DIVIDE MulOp.fun = (lambda (x y) (/ x y))
Term_0 ::= Term_1 MulOp Factor Term_0.value = MulOp.fun(Term_1.value, Factor.value) Term_0.type = mostGeneral(Term1.type,Factor,type)
Back to Pause for Breath. On to Introduction to Type Checking.
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[98F]
Links
Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.
This page was generated by Siteweaver on Mon Apr 30 10:51:58 2001.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2001S/outline.18.html
.
You may validate
this page's HTML.
The source was last modified Mon Jan 22 10:39:10 2001.