RU beehive logo ITEC dept promo banner
ITEC 380
2016summerIII
ibarland

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)

Q0
Interpreting Q

The language Q0

  Expr       ::= Num | ParenExpr | BinExpr | ParityExpr
  ParenExpr  ::= [[ Expr ]]
  BinExpr    ::= ( Expr BinOp Expr )
  ParityExpr ::= parity Expr even: Expr odd: Expr ;
  BinOp      ::= add | sub | mul 
where Num is any numeric literal (as written in either Java or Racket, your choice). For the provided parsers to work, whitespace is required between all terminals with the exception of punctuation.


Discussion


Where we're headed

Q0 Implementations


1

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 Q0's arithmetic will be similar to IEEE floating point arithmetic (rather than perfectly-correct arithmetic).

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

     

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)


©2015, Ian Barland, Radford University
Last modified 2016.Jul.10 (Sun)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.