GithubHelp home page GithubHelp logo

jecepeda / functional-compiler Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 3.0 901 KB

A pseudocode compiler and interpreter using haskell, alex and happy

License: Other

Haskell 68.86% Yacc 18.71% Logos 12.43%
haskell compiler haskell-learning functional-programming compiler-principles

functional-compiler's Introduction

functional-compiler

This repository is one case study in the subject "Programación declarativa" taught at UCLM

The objectives of the case study are:

  • Write an interpreter
  • Use Haskell to write the interpreter

How to compile the project?

  1. First, install Stack
  2. Then, clone this repository
  • git clone https://github.com/JCepedaVillamayor/funcional-compiler.git
  1. Go to the project folder and build the project
  • cd <project-path>
  • stack build

What tools have been used?

  • The lexer has been implemented using Alex, which is a tool for generating lexical analyzers in Haskell. This tool is similar to the tool Flex and Jflex. A tutorial showing how to use alex can be found here
  • The syntax parser has benn implemented using Happy. Happy is a parser generator system: it takes a file containing a BNF specification and produces a Haskell containing a parser for the grammar. A tutorial showing how to use Happy can be found here

Which language do we want to describe?

The BNF syntax for the grammar can be found here

¿How to run the code?

Once the project is built, you need to execute the following command:

  • stack exec functional-compiler-exe

functional-compiler's People

Contributors

jecepeda avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

functional-compiler's Issues

Document the project

Once we've finished the project, we need to explain all the steps involved in the project.

One option is to use LaTex, the other is to use Office

Rewrite the code to support full grammar

The grammar made earlier was designed to make a proof of concept. It is necessary to make a grammar of a complete language, and implement the evaluator of it.

Build evaluator

Now that we have a lexer analyzer and a grammar parser, we need a module which evaluates the program.

  • The skeleton is done: we need to implement the different structures given in Grammar.y.
  • The data structure is created: we need to create a function which checks if the value exists or not (we can change de grammar in orde to implement better this functionality)

The task is to develop the interpreter. Test can be done in order to implement the functionality

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.