simonsejse / FastoLangCompiler

FastoLangCompiler is a open-source compiler for the FASTO language written in F#, developed as part of the "Implementation of Programming Languages" course at DIKU, University of Copenhagen, in 2024.
2 stars 0 forks source link
compiler fasto fsharp functional-programming interpreter

Compiler & Interpreter for Fasto

This is a compiler and interpreter for the Fasto programming language. The source code resides in the Fasto directory.

Commits

For a detailed overview of changes and additions, check the commit history: Commit History.

Requirements

Building the Compiler

To build the compiler, run:

make

or

dotnet build Fasto

Usage

Running Tests

To run all tests from the tests directory (or another specified directory), use:

bin/runtests.sh

Options:

Running tests for compiler optimization

You can show the result of the optimizations with:

Ex. ./bin/fasto.sh -p ic tests/copyConstPropFold2.fo

For a detailed view over the OPTS:

let extractOpt (op : opt) =
    match op with
        | 'i' -> Some inlineOptimiseProgram
        | 'c' -> Some optimiseProgram
        | 'd' -> Some removeDeadBindings
        | 'D' -> Some removeDeadFunction

where i and c was just explained, and the rest is pretty selfexplanatory.

Parameter list for ./bin/fasto.sh

match paramList with
  | [|"-i"; file|] -> interpret (sanitiseFilename file)
  | [|"-r"; file|] -> let res = interpretSimple (sanitiseFilename file)
                      printfn "\n\nResult of 'main': %s\n" (AbSyn.ppVal 0 res)
  | [|"-c"; file|] -> compile  (sanitiseFilename file) (fun x -> x)
  | [|"-o"; file|] -> compile  (sanitiseFilename file) defaultOptimisations
  | [|"-o"; opts; file|] ->
      match extractOpts (explode opts) with
        | Some (opts') -> compile (sanitiseFilename file) opts'
        | None         -> bad ()
  | [|"-P"; file|] ->
      printOptimised (sanitiseFilename file) withoutOptimisations
  | [|"-p"; file|] ->
      printOptimised (sanitiseFilename file) defaultOptimisations
  | [|"-p"; opts; file|] ->
      match extractOpts (explode opts) with
          | Some (opts') -> printOptimised (sanitiseFilename file) opts'
          | None         -> bad ()
  | _ -> bad ()

Here is a detailed view over all params you can use for the fasto.sh file!

For more details and updates, check the commit history: Commit History