comments support, script loading support

This commit is contained in:
Aidan 2020-07-15 18:41:54 -07:00
parent 654e8bd55b
commit bd22b84699
No known key found for this signature in database
GPG key ID: 327711E983899316
11 changed files with 145 additions and 69 deletions

View file

@ -19,7 +19,7 @@ package util
import (
"os"
"os/ioutil"
"io/ioutil"
"gitlab.com/whom/shs/log"
"gitlab.com/whom/shs/ast"
)
@ -33,16 +33,18 @@ func LoadScript(path string, vt ast.VarTable, ft ast.FuncTable) {
return
}
var body string
body, err := ioutil.ReadFile(path)
var body []byte
body, err = ioutil.ReadFile(path)
scriptFile.Close()
if err !- nil {
if err != nil {
log.Log(log.ERR,
"unable to read script: " + err.Error(),
"util")
return
}
set := ast.Lex(body)
set.Eval(ft, vt, false)
set := ast.Lex(string(body))
for iter := set; iter != nil; iter = iter.Next {
iter.Eval(ft, vt, false)
}
}