-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f1a487d
Showing
64 changed files
with
2,731 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.stack-work/ | ||
*~ | ||
glados | ||
glados.cabal | ||
Tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-module(oneplusone). | ||
-export([add/0]). | ||
add() -> | ||
1 + 1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6765 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.