Code Monkey home page Code Monkey logo

firelink's Introduction

Fire Link

Build Status

Fire Link es un lenguaje de programación basado en el lore de la serie de videojuegos Dark Souls, diseñado para la cadena de electivas de área Lenguajes de Programación II y III (CI-4721, CI-4722), durante los trimestres Septiembre - Diciembre 2019 y Enero - Marzo 2020 en la Universidad Simón Bolívar.

Autores

  • Germán Robayo (14-10924)
  • Andrés Ignacio Torres (14-11082)

Especificación

Puedes encontrar la especificación del lenguaje en español aquí.

Uso

Tras compilar con stack build, se puede ejecutar el compilador de la siguiente manera:

stack run -- <archivo> [<flag>]

Donde:

  • archivo: es la ruta a un archivo .souls con el código a compilar
  • flag: es una opción de configuración válida, entre las que se encuentran:
    • -s o --symtable: imprime la tabla de símbolos, si el archivo contiene un programa válido
    • -p o --program: imprime el programa parseado, si el archivo contiene un programa válido
    • -f o --frontend: imprime ambas opciones superiores: la tabla de símbolos y el programa parseado, si el archivo contiene un programa válido
    • -t o --tac: imprime la representación intermedia en código de tres direcciones (TAC) del programa, si el archivo contiene un programa válido
    • -b o --blocks: imprime los bloques básicos del código de tres direcciones (TAC), si el archivo contiene un programa válido
    • -g o --graph: imprime el grafo de flujo asociado al programa, si el archivo contiene un programa válido
    • -c o --target-code: imprime el código final en MIPS asociado al programa, si el archivo contiene un programa válido

Si no se pasa ningún flag, el compilador imprime todo lo génerado: tabla de símbolos, programa, código intermedio, bloques básicos y grafo de flujo.

Ejecución

En el repositorio se incluye un pequeño script en bash para ejecutar en vivo un programa válido escrito en FireLink. Para poder ejecutarlo, spim debe estar instalado en la máquina y poder ejecutarse desde el $PATH.

Para ejecutarlo, se puede utilizar:

./runfirelink <archivo.souls>

Si el archivo contiene un programa válido en FireLink, se ejecutará. En caso contrario, se reportará el error respectivo en la salida estandar.

firelink's People

Contributors

aitorres avatar german1608 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ldiazn

firelink's Issues

Separate parser errors from semantic errors

PR #51 closed issue #5 and introduced modularized error handling. However, the error handler does not differentiate between parse errors and semantic errors, due to the fact that the category of an error is not handled when it's raised, but rather where it's catched, and both parsing and semantic analysis are done at the same time.

A suggestion would be for the error category to be part of the Error data type.

Error module: centralizing errors in the project

We need to centralize all compilers errors in the project, a file named Errors.hs with an only data type CompilerError that derives from Show would be ideal.

The errors that we need to handle are the following:

  • Lexer errors:
    • "Did you mean this token instead of this?" kind of errors
    • General errors
  • Parser errors:
    • For the moments, just a simple parse error
  • Semantic errors:
    • Variable redeclaration on the same declaration block
    • Name not found:
      • For functions
      • For variables
      • For accesing properties that does not exists on a variable of type bezel or link.

Iterator variables

Iterator variables are not taken into account for the moment for the semantic analysis

Semantic analysis is not type-checking assignments

Currently, the following (clearly invalidly typed) programs raise no errors whatsoever.

hello ashen one

    traveling somewhere
    with
        var a of type humanity,
        var b of type hollow,
        var c of type bonfire
    in your inventory
        a <<= 1 \
        a <<= lit \
        a <<= 4.5 \
        b <<= 1 \
        b <<= lit \
        b <<= 4.5 \
        c <<= 1 \
        c <<= lit \
        c <<= 4.5

    you died

farewell ashen one

Assignments should be type-checked in order to ensure that the LVAL and RVAL types match, on compile time.

It shouldn't allow to declare a variable with the same name of an alias

the following program:

hello ashen one

requiring help of
    knight myAlias <1>-chest of type humanity
help received


traveling somewhere
with
    var myAlias of type myAlias
in your inventory
    with orange saponite say |a|
you died


farewell ashen one

will show an error on the var myAlias of type myAlias declaration, but the following one:

hello ashen one

requiring help of
    knight myAlias <1>-chest of type humanity
help received


traveling somewhere
    trust your inventory
    lit:
        traveling somewhere
        with
            var myAlias of type myAlias
        in your inventory
            with orange saponite say @haha@
        you died
    inventory closed
you died


farewell ashen one

Type checking for LVALs

LVALs should not be separate from other EXPRs. They should be properly type checked on assignments and memory dereferencing, as well as ref parameter passing.

Define a way to interact with `union` data types

We need a statement or something to know in an specific moment what option an union variable has. For example,

union {int a; char b} c;
c.a = 1; // the value on c.b is overriden
c.b = 'a'; // the value on c.a is overriden
if (c.a is active) ... else ...

Type checking on for each statement

  • Traversed expression should be array or set
  • Traversed expression should not be modified inside loop
  • If type or traversed expression is container<T>, type of iterator variable should be T
  • Iterator variable should not be modified inside loop

Parse errors to catch

[ ] unclosed "if" block
[ ] unclosed "switch" block
[ ] unclosed indetermined "for" block
[ ] unclosed determined "for" block
[ ] unclosed parenthesis
[ ] missing colon on while statement
[ ] missing colon on switch statement

Code generation for sets

Every aspect of TAC code generation for sets is missing. This might require a garbage collector.

Type alias name conflicts

Currently, running our compiler with the test.souls file generates three errors, one of them being:

Screenshot_20200128_230256

We should either fix the file or discuss if we should allow variables to be named as type aliases (I can't remember if we have already talked about this).

Fix language specs

  • Specify that you can only perform I/O operations (read/print) on scalar types.
    • Also check/change type-checking in order to ensure this.
  • Specify that structured iteration will be prioritized during development for lists.
  • Fix: after iterations, the iteration variable will keep the last value used on the guard checking
  • Check functions code samples (they're outdated)
  • Fix typo on pointers specification
  • Add size function for strings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.