Highlights
Problem 1:
1. Extend the language from assignment 2 to now have support for functions. In particular, support for the following concrete syntax should be provided:
• Anonymous function: fn (x :: typ) ? exp end
• Named function: fun hnamei(y :: typ) :: typ ? exp end
• Application: (f A)
It is worth noticing that one cannot define a recursive function through an anonymous function.
For this assignment, recursive functions can be implemented only through named functions. We provide some examples indicating concrete and abstract syntax. Note that you can have a slightly different abstract syntax so long as it captures the essential aspects of the concrete syntax.
Concrete syntax Abstract syntax
(f 3) AppExp ( VarExp ("f"), NumExp (3))
fn (x ::int) ? 1 Fn("x", INT, NumExp(1))
fun currF (x :: int) :: int ? int ?
fn (y :: int) ? y+1
FunExp(VarExp ("curryF"), VarExp
("x"), INT, ARROW(INT,INT), Fn
("y", INT, BinExp(PLUS, VarExp
("y"), NumExp(1))))
We will provide you with skeletal Alex and Happy files that you will have to complete for this assignment. Note that you are free to not use our provided files and extend the recursive descent parser that you submitted as part of assignment 2.
2. For the second part of this assignment, implement a type checker for this extended language. Each expression is either well-typed (i.e., associated with at most one type) or an exception must be raised. For instance, if e1 then e2 else e3 fi expression is well-typed when e1 is a boolean type and e2 and e3 must have the same types. In order to implement the type checker, you must implement a type grammar (that provides you with rules that must be searched and a derivation has to be obtained to conclude the type checking).
HINT: You may have to define a type environment, and define the domain and range types for each operator
This COL765 - IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.