-
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
Houcine EL ADDALI
committed
Dec 22, 2023
1 parent
cd50f08
commit 60b711f
Showing
14 changed files
with
254 additions
and
69 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
- feature/* | ||
|
||
jobs: | ||
build: | ||
|
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
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
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,58 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/houcine7/JIPL/internal/lexer" | ||
"github.com/houcine7/JIPL/internal/parser" | ||
"github.com/houcine7/JIPL/internal/runtime" | ||
"github.com/houcine7/JIPL/internal/types" | ||
) | ||
|
||
func main() { | ||
// read file and evalal the code | ||
|
||
// read file | ||
|
||
fl, err := os.Open("./test.jipl") | ||
defer fl.Close() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// read file content | ||
content, err := ioutil.ReadAll(fl) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// eval the code | ||
// lexer | ||
|
||
// fmt.Println(string(content)) | ||
l := lexer.InitLexer(string(content)) | ||
|
||
p := parser.InitParser(l) | ||
|
||
pr :=p.Parse() | ||
|
||
// if err | ||
if len(p.Errors()) != 0 { | ||
for _, e := range p.Errors() { | ||
panic(e) | ||
} | ||
} | ||
|
||
ctx := types.NewContext() | ||
|
||
//eval | ||
evl,_ :=runtime.Eval(pr,ctx) | ||
if evl!=nil { | ||
fmt.Println(evl.ToString()) | ||
} | ||
|
||
} |
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 @@ | ||
out("begin interpreting"); | ||
|
||
function isPrime(n) { | ||
if (n < 2) { | ||
return false; | ||
} else { | ||
for (def i = 2; i < n; i++) { | ||
if (n % i == 0) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
}; | ||
|
||
out("here test 7 "); | ||
|
||
out(isPrime(7)); | ||
|
||
out("here test 2"); | ||
|
||
out(isPrime(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
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
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
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
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 |
---|---|---|
|
@@ -16,8 +16,6 @@ const ( | |
PREFIX // -a or !a | ||
CALL // hello(a) | ||
|
||
|
||
|
||
INCREMENT // -- ++ | ||
) | ||
|
||
|
Oops, something went wrong.