Git Product home page Git Product logo

glados-2023's Introduction

GLaDOS-2023

drawing

Features

  • Basic scheme interpreter
  • Written in Haskell
  • Strict testing policy
    • Continuous integration running tests on every Pull Request
    • Over 100 Unit tests and close to 50% coverage
    • Close to 20 Integration tests
  • Abstract Syntax Tree and Concrete Parse Tree implementation
  • Standard input reading
  • An ABNF syntax description
  • An ABNF syntax description for the "compiled" code
  • Infix notations for operators and custom functions

Supported Scheme Features

  • Atoms
    • Signed Integers
    • Symbol
  • Boolean type
  • Function execution
  • Function definition
    • Named Functions
    • Lambda Functions
  • Variable definition
  • Conditional expressions

Builtin Functions

In addition to these basic features, our interpreter also implements the following builtins :

  • println
  • print
  • div
  • mod
  • *
  • -
  • +
  • <
  • <=
  • >
  • >=
  • eq?

Repl mode

You can also enter into an interactive session by running :

./glados -i

or

./glados --interactive

Install Dependencies

Install cabal by installing GHCUP or another method described on the Haskell Website.

cabal update;

Also install the following VSCode/Codium/CodeOSS extensions:

hoovercj.haskell-linter
justusadam.language-haskell
haskell.haskell

Run project

cabal run glados -- file.scm;

or

make ARGS="file.scm"

Running the tests

In order to see coloured output and no coverage when running the tests, please run the tests with one of the following commands:

cabal run test
make test

Build Guide

Bonus ideas :

  • Fully featured REPL
  • Exception stack tracing
  • Exception line tracing

glados-2023's People

Contributors

audetuczapski avatar bilou931 avatar mindoodoo avatar nydragon avatar virgile-crtl avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

andrewchawk

glados-2023's Issues

Normal Expression Crashes

(print (+ (- (* 4 3) (/ 6 3)) 5))

This code results in the following error:

glados: Function -: args are not Atoms

Fix Infinite If

This issue aims to resolve the issue presented in the integrationTests/TestFiles/Factorial.scm test file where because we evaluate the arguments of the if function before evaluating the if condition, if we have recursive calls we will recurse infinitely.

Implement reading from stdin

add builtins to read from standard input / output

read -> returns (RetVal Registry Ast.Literal)
readNum -> returns (RetVal Registry Ast.Literal)

Parsing Libary

This issue tracks:

  • Conversion of parsing to standalone library
  • VSCode test syntax highlighting fix
  • No other VSCode issue

Update Build System

Purpose

This issue serves the purpose of updating the build system in order to produce :

  • A "compiler" binary
  • A "execution environment" binary

Implement Infix user defined and builtin functions

Describe the solution you'd like

(define (add a b) (+ a b))
(a `add` b)

or

(3 `eq?` 2)

Should be valid expressions.
If a function is surrounded by inclined quotation marks ` it is supposed to be called as an infix function with the lowest priority level.
This means that infix functions can only be called with exactly 2 arguments.

Implement compileExpr

Goal

The goal of this issue is to implement the basic features of compileExpr (none of the more advanced features that reference detailed parts of the compileExpr).

Implement writing to file

Describe the solution you'd like
It should be possible to write an Ast.Expr to a file or to append an Ast.Expr to a file ny transforming it into a string using the show function

Refactor Tests

The goal of this issue is to improve the readability and rigor of the tests in our test suite.

This means :

  • Put input and assertion values in variables for increased readability
  • Make sure test is not redundant and correct
  • Ensure you are declaring the least variables possible (try to reuse input values for previous tests where possible)
  • Check test name (simplify where possible)

Files to cleanup :

Stack Implementation

To do :

  • Implement Stack and Function Execution
  • Stack frame should contain :
    • Return pointer
    • Arguments bound to variable names
    • Resume offset

Update Exception Handling

Purpose

Update exception handling to reflect switch to a semi "compiled" language. Two exception types need to be implemented :

  • Compilation Exceptions
  • Runtime Exceptions

Create Array handling

Describe the solution you'd like
It should be possible to use arrays and they should be wrapped by syntactic sugar to give a syntax like that:

[1, 2, 3]

Additional context
Add any other context or screenshots about the feature request here.

Implement file reading

Describe the solution you'd like
It should be possible to read the contents of a file and return it as an Ast.Literal

CPT and AST Implementation

Main parsing of the interpreter

This issue will track the development of the main parsing components that will then allow the efficient execution of the code.

Todo :

  • Tokenization
  • Parse tokens into Concrete Parse Tree
  • Translate CPT into Abstract Syntax Tree

Basic Documentation

Basic Documentation

The goal of this issue is to write basic documentation for the scheme language and for the main components of our library / interpreter.

Checklist :

  • Check relevence of all comments
  • Readme.md
    • Table of contents
    • Installation
    • Building
    • Misc
    • Badges (to make it pretty hehe)
  • Contributing.md
    • Style
    • Commitizen
    • PR Workflow

Implement script launching

  • Load files via stdin
$ ./glados < test.scm
  • Load files via flag
$ ./glados -f test.scm
$ ./glados --file test.scm
  • launch repl
./glados
> (+ 3 2)

Additional flags:

  • -d --debug: stops at each scope change and waits for an enter keypress

Exception Show Instance

The goal of this issue is to implement a custom instance (as opposed to simply deriving it) of the Show typeclass for the RuntimeException data type.

By doing so, we will be able to "pretty" print the exceptions as soon as we catch them.

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.