comments support, script loading support
This commit is contained in:
parent
654e8bd55b
commit
bd22b84699
11 changed files with 145 additions and 69 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue