Skip to content

Commit

Permalink
init + readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tm26a21p committed Mar 29, 2024
0 parents commit f1a487d
Show file tree
Hide file tree
Showing 64 changed files with 2,731 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Tests & mirroring & Release
env:
MIRROR_URL: git@github.com:EpitechPromo2025/B-FUN-500-PAR-5-2-glados-florian.labarre.git
on:
pull_request:
push:
branches:
- main
jobs:
test:
name: CI
runs-on: ubuntu-latest
steps:
- name: Setup GHC
uses: haskell/actions/setup@v2
with:
ghc-version: "9.2.5"
enable-stack: true
- name: Set up Erlang
uses: erlef/setup-beam@v1
with:
otp-version: '24.0'
- name: Clone project
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Build and run tests
run: "stack test --fast --no-terminal --system-ghc"
- name: Function Test
run: "stack --local-bin-path . install --system-ghc && mv glados-exe glados && ./testFunctional.sh"
push_to_mirror:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Clone project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Push to mirror
uses: pixta-dev/repository-mirroring-action@v1
with:
target_repo_url:
${{ env.MIRROR_URL }}
ssh_private_key:
${{ secrets.SSH_PRIVATE_KEY }}
release:
name: "Release"
runs-on: "ubuntu-latest"
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Setup GHC
uses: haskell/actions/setup@v2
with:
ghc-version: "9.2.5"
enable-stack: true
- name: Clone project
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.stack
key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Build
run: "stack --local-bin-path . install --system-ghc"
- name: Bump version and push tag
id: generateTag
uses: anothrNick/github-tag-action@1.55.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ steps.generateTag.outputs.tag }}
prerelease: false
title: "Release Build"
files: |
LICENSE
glados-exe
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.stack-work/
*~
glados
glados.cabal
Tests/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog for `glados`

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the
[Haskell Package Versioning Policy](https://pvp.haskell.org/).

## Unreleased

## 0.1.0.0 - YYYY-MM-DD
17 changes: 17 additions & 0 deletions ErlangCodeBase/official_basic_op.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-module(basic_op).
-export([add/2, sub/2, mul/2, divide/2, mod/2]).

sub(A, B) ->
A - B.

add(A, B) ->
A + B.

mul(A, B) ->
A * B.

divide(A, B) ->
A div B.

mod(A, B) ->
A rem B.
6 changes: 6 additions & 0 deletions ErlangCodeBase/official_oneplusone.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
% a simple 1 + 1 = 2 program
-module(official_oneplusone).
-export([add/0]).
add() ->
A = "1",
1 + 1.
4 changes: 4 additions & 0 deletions ErlangCodeBase/oneplusone.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-module(oneplusone).
-export([add/0]).
add() ->
1 + 1.
30 changes: 30 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright Author name here (c) 2023

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Author name here nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
##
## EPITECH PROJECT, 2023
## B-FUN-500-PAR-5-2-glados-florian.labarre
## File description:
## Makefile
##

NAME = glados

all:
stack --local-bin-path . install
mv glados-exe $(NAME)

clean:
stack clean;

fclean: clean
rm -f $(NAME)

re: fclean all

.PHONY: all clean fclean re
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# GLaDOS: Generic Language and Data Operand Syntax

## Technical Overview

## Project Objective

GLaDOS is a programming language project implemented in Haskell. It aims to develop a minimalist clone of the Erlang interpreter, as its foundational component.

### General Information

Binary Name:
Languages: Haskell
Compilation: Via Makefile, including re, clean, and fclean OR stack build
Repository Structure:
Source files included, excluding unnecessary files like binaries, temp files, and obj files.

### Build System and Dependencies
GLaDOS utilizes a Makefile for compilation, providing rules for building, cleaning, and removing temporary files.
While you are free to choose any build system, I recommand Stack for its robustness and reliability.

### Testing

Comprehensive testing is crucial for the development of GLaDOS. Unit and integration tests are mandatory, and you must demonstrate how much of your code is covered by these tests. Additionally, automation of testing through Continuous Integration (CI) and Continuous Delivery (CD) is encouraged to maintain code quality and prevent the introduction of errors.

## Algorithm

### Syntax and Parsing

GLaDOS supports Symbolic-Expressions (S-expressions) as its primary representation. It must handle atoms such as signed integers and symbols, as well as lists with nested sub-expressions. The parser must be able to interpret these expressions correctly to ensure the proper functioning of the interpreter.

### Core Concepts
GLaDOS supports almost all basic of Erlang, and procedures. It also includes features for defining bindings, user-defined functions (both anonymous lambdas and named functions), and conditional expressions using "if" notation.

### Evaluation and Execution
The interpreter evaluates expressions using an Abstract Syntax Tree (AST) and an environment for variable bindings. It supports both anonymous and named functions, including recursion, and handles conditional expressions and built-in functions as specified in the project requirements.

### Tests and Run
This project uses GitHub Actions as defined in the .github/workflows/ci.yml file for continuous integration. The workflow is triggered on every pull request and push to the main branch.

The workflow has 2 jobs:

- test: This job sets up GHC and Erlang, clones the project, caches dependencies, builds the project, and runs tests. The tests are run with the command stack test --fast --no-terminal --system-ghc. After the tests, it runs functional tests with the command stack --local-bin-path . install --system-ghc && mv glados-exe glados && ./testFunctional.sh.

- release: This job is also dependent on the test job and only runs if the test job passes. It sets up GHC, clones the project, caches dependencies, builds the project, bumps the version, pushes a tag, and creates a release.

Example of launch launch this project locally:
```sh
make; ./glados ErlangCodeBase/official_basic_op.erl
```

## Conclusion

GLaDOS is a challenging yet rewarding project that offers valuable insights into functional programming, language design, and compiler construction. By implementing an Erlang interpreter in Haskell, I gain practical experience in parsing, evaluation, and testing, while also exploring advanced topics like type inference, optimization, and metaprogramming.
2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
1 change: 1 addition & 0 deletions TestsResult/add.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
1 change: 1 addition & 0 deletions TestsResult/basicFuncDecl.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions TestsResult/divide.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions TestsResult/factorial.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6
1 change: 1 addition & 0 deletions TestsResult/fib.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6765
1 change: 1 addition & 0 deletions TestsResult/mod.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
1 change: 1 addition & 0 deletions TestsResult/mul.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
1 change: 1 addition & 0 deletions TestsResult/sub.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1
6 changes: 6 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main (main) where

import Input

main :: IO ()
main = mainErlang
Binary file added official_basic_op.beam
Binary file not shown.
64 changes: 64 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: glados
version: 0.1.0.0
github: "githubuser/glados"
license: BSD3
author: "Author name here"
maintainer: "example@example.com"
copyright: "2023 Author name here"

extra-source-files:
- README.md
- CHANGELOG.md

# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on GitHub at <https://github.com/githubuser/glados#readme>

dependencies:
- base >= 4.7 && < 5
- bytestring
- word8
- directory
- filepath

ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints

library:
source-dirs: src

executables:
glados-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- glados

tests:
glados-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- glados
- hspec
Loading

0 comments on commit f1a487d

Please sign in to comment.