With this assignment you will demonstrate:
Please:
Submit, to BrightSpace, a neatly typeset answer to Problem 1, and a link to a GitHub repo or Replit for Problem 2. Please make a best effort for typesetting. Handwritten answers are okay if you are short on time, but pay extra attention to neatness if you go that route.
Give a Denotational Semantics for a small extension to Bella with arrays, booleans, and lists, that is strongly-typed and dynamically typed. Here is the abstract syntax:
The standard library is as we saw in class.
Hint: This is exactly the extension of Bella that we saw in class when we began our study of types in operational semantics. The entire operational semantics for this language extension is provided in the course notes; you are encouraged to build your denotational semantics by simply “translating” the operational semantics to denotational semantics. (This helps to achieve the learning objective of gaining comfort with the similarities and differences between the two forms of semantic description.)
To get you started, here is a portion of the abstract syntax representation:
class Program { constructor(public body: Block) {} } class Block { constructor(public statements: Statement[]) {} } interface Statement { } class Assignment implements Statement { constructor(public target: Identifier, public source: Expression) {} } class VariableDeclaration implements Statement { constructor(public id: Identifier, public initializer: Expression) {} } interface Expression { } // Build the rest of the classes and interfaces here: PrintStatement, // BinaryExpression, UnaryExpression, ConditionalExpression, Numeral, // Identifier, etc.
Your interpreter will be function set up like this:
function interpret(program: Program): void { // your code here }
An invocation of the interpreter might look like this:
const sample: Program = new Program( new Block([new PrintStatement(new Numeral(5))]) ) interpret(sample)