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

@ -22,6 +22,7 @@ import (
"fmt"
"gitlab.com/whom/shs/log"
"gitlab.com/whom/shs/ast"
"gitlab.com/whom/shs/util"
)
func GenFuncTable() ast.FuncTable {
@ -62,13 +63,20 @@ func GenFuncTable() ast.FuncTable {
Args: 2,
},
"input": &ast.Function{
"input": &ast.Function{
Function: input,
Name: "input",
TimesCalled: 0,
Args: 1,
},
"load": &ast.Function{
Function: load,
Name: "load",
TimesCalled: 0,
Args: 1,
},
"...": &ast.Function{
Function: expand,
Name: "...",
@ -337,3 +345,18 @@ func input(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
ret.Set(output)
return ret
}
func load(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
in = in.Eval(ft, vt, true)
if in.Tag != ast.STRING {
log.Log(log.ERR,
"argument to load must be a string",
"load")
return nil
}
bp := in.Value()
bp = AbsPath(bp)
util.LoadScript(bp, vt, ft)
return nil
}