Skip to content

A compiler for the FAE language from the course Programming Languages at DCC to MIPS

Notifications You must be signed in to change notification settings

gusridd/FAECompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FAEC: Functions and Arithmetic Expressions Compiler

This project is a compiler for the FAE language, studied in the cource of programming languages at DCC/uchile, to the MIPS instruction set.

Syntax

The syntax of the language is a sub-set of the racket syntax. The language implements functions as closures.

<expr> ::= <num>                        number
         | <id>                         indentifier
         | {+ <expr> <expr>}            arithmetic addition
         | {- <expr> <expr>}            arithmetic subtraction
         | {fun {<id>} <expr>}          function definition
         | {<expr> <expr>}              function application

Usage

The compiler can be used with an instalation of racket by running:

racket FAEC.rkt <input-file> <output-file>

The output file can be loaded into an instance of SPIM (A MIPS simulator: http://spimsimulator.sourceforge.net/)

user@machine spim
(spim) load "<output-file>"
(spim) run

Example file

The following example corresponds to an anonymous function, which receives a function "f" and returns a function that applies "f" to its argument "arg". In the example a function which adds one to its argument is passed as "f" and the actual arithmetic argument is 5.

{{{fun {f} 
       {fun {arg} 
            {f arg}}} 
  {fun {x} {+ x 1}}} 5}

About

A compiler for the FAE language from the course Programming Languages at DCC to MIPS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages