Skip to content
Fork of OCaml code for Compiler Construction course at University of Cambridge
Branch: master
Clone or download
Pull request Compare This branch is 7 commits ahead, 41 commits behind Timothy-G-Griffin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
tests
.gitignore
README.md
README.txt
ast.ml
ast.mli
changes.md
errors.ml
errors.mli
free_vars.ml
free_vars.mli
front_end.ml
front_end.mli
interp_0.ml
interp_0.mli
interp_1.ml
interp_1.mli
interp_2.ml
interp_2.mli
interp_3.ml
interp_3.mli
jargon.ml
jargon.mli
lexer.mll
load.ml
parser.mly
parser.output
past.ml
past.mli
past_to_ast.ml
past_to_ast.mli
slang.ml
static.ml
static.mli
tests.ml
tests.mli

README.md

Slang with extra features I wrote

I messed around with the compiler to implement the following features:

  • nested comments
  • line comments (thank you Emma Holliday for the help)
  • integer division /
  • integer modulo %
  • high precedence, left associative unambiguous function application
    • allows if ... then ... else <fun> <args> without end
  • removed end for if-else expressions
  • short-circuit evaluation for && and ||
  • removed end from lambda-expressions
  • removed end from case-expression
  • added declaration lists (as a derived form, allowing me to remove a bunch of lets and ends)
  • added pattern-matching for product types
  • added rudimentary type inference (thank you James Clarke for helping out)
  • hence removed type annotations (except for inl and inr where it is necessary)
  • removed need for parentheses around identifiers as patterns

The code is probably not the best/actual way a lot of these features would be implemented but it was fun (and very distracting/addictive) to make these changes.

Type inference uses references and mutability all over the place. Algorithm W seems like it would be worth a shot at some point.

static.ml

This complete rewrite, at its essence, passes a reference to an expected type down (a synthesised attribute) which is unified/constrained depending on the expression being typed.

You can’t perform that action at this time.