-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (35 loc) · 826 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
package main
import (
"islash/modules/interpreter"
"islash/modules/lexer"
"log"
"os"
"path/filepath"
"strings"
)
func main() {
/*
Finding the program path.
*/
if len(os.Args) < 2 {
log.Fatal("No program name specified.")
}
if !strings.HasSuffix(os.Args[1], ".isl") {
log.Fatal("Your program extension must be '.isl'.")
}
cwd, err := os.Getwd()
if err != nil {
log.Fatal("Unnable to get user's current directory.")
}
sourceCodePath := filepath.Join(cwd, os.Args[1])
/*
Mounting tokens with the lexer.
*/
tokensList := lexer.MountTokens(sourceCodePath)
/*
Interpreting the tokens with the interpreter.
*/
sourceCodeDir := filepath.Join(sourceCodePath, "..")
interpreter := interpreter.NewInterpreter()
interpreter.Interpret(tokensList, sourceCodeDir)
}