-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (42 loc) · 768 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"FLanguage/Evaluator"
Lexer "FLanguage/Lexer"
"FLanguage/Lexer/Token"
"FLanguage/Parser"
"FLanguage/repl"
"fmt"
"os"
)
func lexerFromFile(path string) (Lexer.Lexer, error) {
file, _ := Lexer.GetByteFromFile(path)
lexer, e := Lexer.New(file)
return lexer, e
}
func main() {
parm := os.Args[1]
if parm == "r" {
repl.Start()
return
}
path := parm
l, e := lexerFromFile(path)
if e != nil {
fmt.Println(e)
return
}
p, e := Parser.ParsingStatement(&l, Token.END)
if e != nil {
fmt.Println(e)
return
}
env := Evaluator.NewEnvironment()
Evaluator.LoadBuiltInFunction(env)
Evaluator.LoadBuiltInVariable(env)
_, e = Evaluator.Eval(p.(*Parser.StatementNode), env)
if e != nil {
fmt.Println(e)
return
}
return
}