RU beehive logo ITEC dept promo banner
ITEC 380
2021spring
ibarland

Interpreting Y
(as developed in lecture)

The language Y0

Y0:

Expr ::= Num | Paren | BinOp | IfZero Paren ::= {= Expr =} Interpretation: a parenthesized expression BinOp ::= > Op Expr Expr < Interpretation: apply a binary operator Op ::= blam | swish | splat Interpretation: addition, subtraction, multiplication (resp.) IfZero ::= bliff Expr zok Expr nooo Expr Interpretation: if 1st-expr is 0, eval to 2nd-expr, else 3rd-expr. Mnemonic: branch iffzero,ok? … else if nooot: …

Y1:see Y2.html for details

Op ::= | pow | oof Interpretation: “exponentiation”, “remainder1 Expr ::= | IfGT Interpretation: “if greater than” IfGT ::= glurp Expr Expr zok Expr nooo Expr Mnemonic: greater/lesser(p)

Y2:see Y2.html for details

Expr ::= | Id | LetExpr Interpretation: identifier; let LetExpr ::= zlott Id biff Expr @ Expr Mnemonic: (z)let Id be(ff) … in(at)

Y4:see Y4.html for details

Expr ::= | FuncExpr | FuncApplyExpr FuncExpr ::= thonk Id => Expr Interpretation: a function-value, with parameter Id and body-Expr. FuncApplyExpr ::= krunch Expr <= Expr Interpretation: apply a function (1st expr) to an argument (2nd expr)
where Num is any numeric literal (as written in either Java or Racket, your choice2). For the provided parsers to work, whitespace is required between all terminals with the exception of punctuation.

Semantics (interpretation):


Discussion


Where we're headed

Y0 Implementations

stills of 1960's TV Batman fight-words

Discuss the implementation

Once we've talked in class about internal-representation (and given examples of the W programs and corresponding internal-data), then we can discuss the provided-implementation, including recursive-descent parsing:

2018 version: The videos below are based on 2018fall's language, T0. So details of the syntax are different than this semester, and some statements might have different semantics, but overall the content is extremely similar to this semester's language.


1 Like remainder, except working for negative and fractional amounts. See homework for details.      
2 This is so we can just use our language's built-in number-parsing functions, without getting bogged down in tokening input. So racket implementations will allow exactly those strings recognized by number?, (including +nan.0, -inf.0, and 2+3i).

Similarly, if using Java, the semantics of Y0's arithmetic will be similar to IEEE floating point arithmetic (rather than perfectly-correct arithmetic).

Don't confuse Y0's class Num (which extends Expr) with the existing java.lang.Number, which doesn't extend Expr.

     

logo for creative commons by-attribution license
This page licensed CC-BY 4.0 Ian Barland
Page last generated
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.