Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #18

Merged
merged 112 commits into from
Jan 14, 2024
Merged

Dev #18

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
6729ced
Merge pull request #7 from X-R-G-B/main
Saverio976 Dec 26, 2023
18f3758
Add parse of one expression
Saverio976 Dec 27, 2023
f10900c
Add parser for multiline
Saverio976 Dec 27, 2023
9a3aef9
Fix multiple line of expression
Saverio976 Dec 27, 2023
44f05e6
Fix norm
Saverio976 Dec 27, 2023
d844b8c
Adjust parseAllCharUntil to not include the until + Add alias
Saverio976 Dec 29, 2023
bcd2a32
Remove not used export from Alias
Saverio976 Dec 29, 2023
9b50698
Fix too long line
Saverio976 Dec 29, 2023
00961d9
Merge pull request #9 from X-R-G-B/step-2nd-modify-text
guillaumeAbel Dec 30, 2023
0b080b5
add vscode extension
TTENSHII Dec 20, 2023
80a387b
add better readme for vscode extension
TTENSHII Dec 24, 2023
d115a37
add support for modulo operator
TTENSHII Dec 24, 2023
6aa321f
fix merge request
TTENSHII Jan 3, 2024
dca1a82
update main readme.md
TTENSHII Jan 3, 2024
4e4f570
Update docs/SyntaxHighlighting.md
TTENSHII Jan 3, 2024
8958ed1
add work in progress
TTENSHII Jan 5, 2024
6a6bafb
move getFileContent in loadModule
TTENSHII Jan 5, 2024
570e147
add better error control
TTENSHII Jan 5, 2024
30fc7b6
add first version of getLEB128
TTENSHII Jan 5, 2024
2a5ce20
add better leb128
TTENSHII Jan 5, 2024
d4891b0
add better error handler
TTENSHII Jan 6, 2024
37eccd8
add work in progress
TTENSHII Jan 6, 2024
5328948
Step 3rd parser lvt (#10)
Saverio976 Jan 6, 2024
b5129cc
Remove generic mention
Saverio976 Jan 6, 2024
4f86d0b
Add start implementation
Saverio976 Jan 6, 2024
f848b1e
add working typesFunc
TTENSHII Jan 7, 2024
7623136
add type parsing
TTENSHII Jan 7, 2024
9cc4bc6
Add first part of watlike
Saverio976 Jan 7, 2024
55cb491
Fix norm
Saverio976 Jan 7, 2024
84af1a6
Add header
Saverio976 Jan 8, 2024
958ce59
Merge pull request #11 from X-R-G-B/step-5th-wat-like
TTENSHII Jan 8, 2024
d58c0f1
Add operators and add parse func declaration
Saverio976 Jan 8, 2024
5bc2f0c
Merge remote-tracking branch 'origin/dev' into fix-parser
Saverio976 Jan 8, 2024
225d828
Fix lexeme wtf
Saverio976 Jan 8, 2024
ccab3c8
Remove ''
Saverio976 Jan 8, 2024
6e58934
Merge pull request #12 from X-R-G-B/fix-parser
TTENSHII Jan 8, 2024
e115651
Add cli for compilation
Saverio976 Jan 8, 2024
c3fd7a1
Fix norm
Saverio976 Jan 8, 2024
4ee064c
add save
TTENSHII Jan 9, 2024
7b699d1
refactor + good global parsing
TTENSHII Jan 10, 2024
1e7a2d7
Add wat
Saverio976 Jan 10, 2024
323b37c
Fix params index
Saverio976 Jan 10, 2024
8802916
Add error (undefined is bad)
Saverio976 Jan 10, 2024
ebc432f
Add isExport in FuncPrototype; Add some wasm data
Saverio976 Jan 10, 2024
6d2a27b
Add original name of func
Saverio976 Jan 10, 2024
841fce5
Add wat to wasm
Saverio976 Jan 10, 2024
7ce4072
Fix norm
Saverio976 Jan 10, 2024
a2a1cc0
add exports
TTENSHII Jan 10, 2024
6fe88c3
add getFuncTypeIdx
TTENSHII Jan 10, 2024
bade394
getStartFunc
TTENSHII Jan 10, 2024
54f6db5
good instruciton parsing
TTENSHII Jan 11, 2024
2bb85cf
add execution
TTENSHII Jan 11, 2024
5ee052c
add work in progress
TTENSHII Jan 11, 2024
b0e63f0
add work in progress
TTENSHII Jan 11, 2024
f6359bf
add new execution version
TTENSHII Jan 12, 2024
280d80c
Add write for wasm
Saverio976 Jan 13, 2024
a8a25e9
Fix tests and norm
Saverio976 Jan 13, 2024
71414d1
Merge pull request #14 from X-R-G-B/step-6th-true-wat
Saverio976 Jan 13, 2024
fe30d5f
Merge pull request #13 from X-R-G-B/lvtc-cli
Saverio976 Jan 13, 2024
9d2b233
Merge branch 'dev' into step-7th-wasm
Saverio976 Jan 13, 2024
4f91529
Fix compil
Saverio976 Jan 13, 2024
33ef5e8
Merge pull request #15 from X-R-G-B/step-7th-wasm
Saverio976 Jan 13, 2024
029ba91
Merge branch 'dev' into step-8th-write-wasm
Saverio976 Jan 13, 2024
a336d42
Fix stack lock
Saverio976 Jan 13, 2024
2db7c6d
Fix windows compil
Saverio976 Jan 13, 2024
9b5c933
Merge pull request #16 from X-R-G-B/step-8th-write-wasm
Saverio976 Jan 13, 2024
c441cd0
Add link to all step for wasm
Saverio976 Jan 13, 2024
cabc04b
Add true program
Saverio976 Jan 13, 2024
185c58e
add new operations
TTENSHII Jan 13, 2024
1653978
Fix memory error wasm
Saverio976 Jan 13, 2024
7710b62
Fix wasm generation
Saverio976 Jan 13, 2024
bfcab44
Fix test
Saverio976 Jan 13, 2024
4a6314f
Add debug rule
Saverio976 Jan 13, 2024
54cc9f1
Fix vars modif
Saverio976 Jan 13, 2024
d3a18ba
add some fixes
TTENSHII Jan 13, 2024
e62a710
Fix leb128 and declaration
Saverio976 Jan 13, 2024
26f6c47
fix locals index
TTENSHII Jan 14, 2024
cafae16
remove trace
TTENSHII Jan 14, 2024
00db589
add better main
TTENSHII Jan 14, 2024
e330c91
rename leb128 func
TTENSHII Jan 14, 2024
34cb9bd
clean code
TTENSHII Jan 14, 2024
5587c49
Add lexeme
Saverio976 Jan 14, 2024
b7c8d85
Add BNF docs
Saverio976 Jan 14, 2024
c08082d
move to lib
TTENSHII Jan 14, 2024
bb5fc93
add some operation
TTENSHII Jan 14, 2024
5b47c0e
Add verbose flag
Saverio976 Jan 14, 2024
2a5515f
Remove all not implemented
Saverio976 Jan 14, 2024
fabc45f
clean code
TTENSHII Jan 14, 2024
8efe9bf
fix some warning
TTENSHII Jan 14, 2024
6b75cd5
fix compilation
TTENSHII Jan 14, 2024
a24f195
Fix if
Saverio976 Jan 14, 2024
1559875
Fix priority
Saverio976 Jan 14, 2024
1b63e16
fix if and eq
TTENSHII Jan 14, 2024
9b46bef
Add webrunner
Saverio976 Jan 14, 2024
9c70d16
Fix docs
Saverio976 Jan 14, 2024
cd28dee
clean code
TTENSHII Jan 14, 2024
139245b
split opcode
TTENSHII Jan 14, 2024
1d679e6
Merge branch 'dev' into vm
TTENSHII Jan 14, 2024
bbe2420
clean code
TTENSHII Jan 14, 2024
2fa4b3a
fix some norm error
TTENSHII Jan 14, 2024
ab268b6
fix some norm error
TTENSHII Jan 14, 2024
aacdacf
fix some norm error
TTENSHII Jan 14, 2024
905178f
fix some norm error
TTENSHII Jan 14, 2024
dd5b17a
fix some norm error
TTENSHII Jan 14, 2024
5be9022
fix some norm error
TTENSHII Jan 14, 2024
1c78d33
fix some norm error
TTENSHII Jan 14, 2024
b33e6bd
fix some norm error
TTENSHII Jan 14, 2024
15175f9
fix some norm error
TTENSHII Jan 14, 2024
663d44f
fix some norm error
TTENSHII Jan 14, 2024
26f3ac1
fix some norm error
TTENSHII Jan 14, 2024
86b9607
fix some norm error
TTENSHII Jan 14, 2024
a306af4
Merge pull request #17 from X-R-G-B/vm
guillaumeAbel Jan 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ jobs:
if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main'
run: mdbook build

- name: Copy OnlineRunner
if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main'
run: cp ./lvtext/webrunner/index.html ./book/OnlineVM.html

- name: Setup Pages
if: github.ref == 'refs/heads/main'
uses: actions/configure-pages@v3
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ $(TARGET):
"$(MAKE)" -C "$(LVT_COMPILER)"
"$(MAKE)" -C "$(LVT_RUNER)"

debug:
"$(MAKE)" -C "$(LVT_COMPILER)" debug
"$(MAKE)" -C "$(LVT_RUNER)" debug

clean:
"$(MAKE)" -C "$(LVT_COMPILER)" clean
"$(MAKE)" -C "$(LVT_RUNER)" clean
Expand Down
77 changes: 16 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
// This is a comment
```

- **Alias**

```
alias A = Int;
```

- **Variables Declaration**

```hs
@Int a = 1;
@String b = "hello";
@StringView b = "hello";
```

- **Variables Assignment**
Expand Down Expand Up @@ -79,21 +85,6 @@ fn add(a: Int, b: Int, c: Int) -> Int
};
```

- **Generic Functions**

```rust
fn add[A](a: A, b: A) -> A
{
<- a + b;
};
```

- **Generic Functions Call**

```rust
add[Int](1, 2);
```

- **Conditions**

```c
Expand Down Expand Up @@ -123,70 +114,34 @@ while (i < 10)
};
```

- **Imports**

```c
// Circular imports are not allowed
import "path/to/file.lvt"
```

- **Entrypoint**

```rust
// If you don't have this function, the program will not be run
fn start() -> Int
export fn start() -> Int
{
<- 0;
};
```

- **Operators**

```
```python
a + b
a - b
a * b
a / b
a == b
a != b
a < b
a <= b
a > b
a >= b
```

- **Structs**
- **Priority of Operators**

```c
struct Point
{
x: Int,
y: Int,
};
```

- **Structs Initialization**
```
@Point p = {1, 2};
```

- **Structs Access**
```
p:x
```

- **Nested Structs**
```
struct Rect
{
Point size;
Point pos;
};
@Rect r = {{1, 2}, {3, 4}};
r:size:x
```

- **Generic Structs**

```c
struct Rect[A]
{
attribute: A,
};
// realy peticuliar buut we use { for ( and } for )
{a + B} * c
```
61 changes: 61 additions & 0 deletions docs/BNF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Leviator BNF

```bnf
<syntax> ::= <expression>*

<expression> ::= <alias> | <function> | <comment>

<alias> ::= "alias " <identifierAlias> " " <replacement> ";\n"
<identifierAlias> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
"J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
"S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" |
"b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" |
"k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" |
"t" | "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" |
"2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "_" |
"." | "-" | ":" | "!" | "@" | "#" | "$" | "%" | "^" |
"&" | "*" | "(" | ")" | "[" | "]" | "{" | "}" | "|" |
"\\" | "+" | "=" | ";" | "<" | ">" | "?" | "/" | "`" |
"~"
<replacement> ::= <char2>

<comment> ::= "//" <char1>* "\n"

<function> ::= "fn " <identifier> "(" <parameterList>* ") -> " <type> "\n{\n" <instruction>* "}\n"
<identifier> ::= <lowerLetter> <char2>
<parameterList> ::= <parameter> ","
<parameter> ::= <identifier> ": " <type>
<type> ::= <upperLetter> <char2>
<instruction> ::= <instructionIns> ";\n"
<instructionIns> ::= <declaration> | <assignment> | <functionCall> | <return> | <condition>
<declaration> ::= "@" <type> " " <identifier> " = " <value>
<assignment> ::= <identifier> " = " <value>
<functionCall> ::= <identifier> "(" <varParamList>* ")"
<varParamList> ::= <value> ","
<return> ::= "<- " <value>
<value> ::= <functionCall> | <identifier> | <literal>
<literal> ::= <digit> | <character> | <bool> | <stringview>
<condition> ::= <conditionIf> | <conditionIfElse>
<conditionIfElse> ::= <conditionIf> <conditionElse>
<conditionIf> ::= "if (" <value> ")\n{\n" <instruction>* "}\n"
<conditionElse> ::= "else\n{\n" <instruction>* "}\n"

<character> ::= "'" <char1> "'"
<bool> ::= "True" | "False"
<stringview> ::= "\"" <char1>* "\""

<char> ::= <lowerLetter> | <upperLetter> | <digit>
<char1> ::= <char> | "" | " " | <specialAll>
<char2> ::= <lowerLetter> | <upperLetter> | <digit> | <special>
<lowerLetter> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
"j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
"s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
<upperLetter> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
"J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
"S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<special> ::= "_"
<specialAll> ::= <special> | "!" | "@" | "#" | "$" | "%" | "^" | "&" |
"*" | "(" | ")" | "[" | "]" | "{" | "}" | "|" | "\\" |
"+" | "=" | ";" | "<" | ">" | "?" | "/" | "`" | "~"
```
Empty file added docs/OnlineVM.md
Empty file.
3 changes: 3 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ made in Haskell.
[README](README.md)
[Byte Code Spec](ByteCodeSpec.md)
[Byte Code Spec Ex](ByteCodeSpecEx.md)
[Syntax Highlighting Extension](SyntaxHighlighting.md)
[BNF](BNF.md)
[Online VM](OnlineVM.md)
10 changes: 10 additions & 0 deletions docs/SyntaxHighlighting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Leviator Lang Extension for Visual Studio Code

We are thrilled to introduce our Leviator lang extension, providing enhanced syntax highlighting for an optimized coding experience. While currently available exclusively for vscode, we have ambitious plans to extend support to JetBrains and Vim in the future.

### Installation

To install the Leviator Language extension for **Visual Studio Code**, follow the steps below:

1. Navigate to the "lvtext" directory in our [Leviator GitHub repository](https://github.com/X-R-G-B/Leviator/lvtext).
2. Refer to the detailed installation instructions provided in the [README.md](https://github.com/X-R-G-B/Leviator/blob/lvtext/vscode/leviator-lang/README.md) file.
3 changes: 3 additions & 0 deletions lvtc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ all: $(TARGET)
$(TARGET):
stack build --copy-bins --local-bin-path .

debug:
stack build --trace --copy-bins --local-bin-path .

clean:
stack clean

Expand Down
85 changes: 85 additions & 0 deletions lvtc/app/Args.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{-
-- EPITECH PROJECT, 2023
-- Leviator compiler
-- File description:
-- Args
-}


module Args
(
Action(..),
Args(..),
parseArgs,
printHelp
) where

import System.Directory (getCurrentDirectory)

data Action = ShowHelp | ShowVersion | Run

data Args = Args {
action :: Action,
folderPath :: String,
outFile :: String,
verbose :: Bool
}

parseArgs' :: [String] -> Args -> Either Args String
parseArgs' [] args =
Left args
parseArgs' ("--help":xs) args =
parseArgs' xs (args {action = ShowHelp})
parseArgs' ("-h":xs) args =
parseArgs' xs (args {action = ShowHelp})
parseArgs' ("--version":xs) args =
parseArgs' xs (args {action = ShowVersion})
parseArgs' ("-v":xs) args =
parseArgs' xs (args {action = ShowVersion})
parseArgs' ("-o":x:xs) args =
parseArgs' xs (args {outFile = x})
parseArgs' ["-o"] _ =
Right "Missing argument for -o"
parseArgs' ("--verbose":xs) args =
parseArgs' xs (args {verbose = True})
parseArgs' (('-':xs):_) _ =
Right ("Unknown option: " ++ xs)
parseArgs' (x:xs) args =
parseArgs' xs (args {action = Run, folderPath = x})

parseArgs :: [String] -> IO (Either Args String)
parseArgs args =
getCurrentDirectory >>= \path ->
return (parseArgs' args (Args {
action = Run, folderPath = path, outFile = "out.wasm", verbose = False
}))

hLine1 :: String
hLine1 = "Usage: lvtc [OPTION] [FOLDER]\n"
hLine2 :: String
hLine2 = "\n"
hLine3 :: String
hLine3 = "Compile Leviator source code to WebAssembly\n"
hLine4 :: String
hLine4 = ""
hLine5 :: String
hLine5 = "Options:\n"
hLine6 :: String
hLine6 = "\t-h, --help\n\t\tDisplay this help and exit\n"
hLine7 :: String
hLine7 = "\t-v, --version\n\t\tOutput version information and exit\n"
hLine8 :: String
hLine8 = "\t-o FILE\n\t\tWrite WebAssembly to FILE\n"
hLine9 :: String
hLine9 = part1 ++ part2
where
part1 = "\tFOLDER\n\t\tTake all Leviator"
part2 = " source code recursively from FOLDER\n"
hLine10 :: String
hLine10 = "\t--verbose\n\t\tVerbose mode\n"

printHelp :: IO ()
printHelp =
putStr hLine1 >> putStr hLine2 >> putStr hLine3 >> putStr hLine4
>> putStr hLine5 >> putStr hLine6 >> putStr hLine7 >> putStr hLine8
>> putStr hLine9 >> putStr hLine10
17 changes: 15 additions & 2 deletions lvtc/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@

module Main (main) where

import Lib
import System.Environment (getArgs)

import Args (Args (..), parseArgs, Action (..), printHelp)
import Run (run)
import Version (printVersion)

dispatchArgs :: Args -> IO ()
dispatchArgs (Args Run fPath oFile v) = run (Args Run fPath oFile v)
dispatchArgs (Args ShowHelp _ _ _) = printHelp
dispatchArgs (Args ShowVersion _ _ _) = printVersion

dispatchIfOk :: Either Args String -> IO ()
dispatchIfOk (Left args) = dispatchArgs args
dispatchIfOk (Right str) = print str

main :: IO ()
main = someFunc
main = getArgs >>= parseArgs >>= dispatchIfOk
Loading
Loading