export var functions
This commit is contained in:
parent
a08677b4f4
commit
4865c7ce92
5 changed files with 33 additions and 3 deletions
|
|
@ -48,6 +48,13 @@ func GenFuncTable() ast.FuncTable {
|
|||
Args: -1,
|
||||
},
|
||||
|
||||
"export": &ast.Function{
|
||||
Function: export,
|
||||
Name: "export",
|
||||
TimesCalled: 0,
|
||||
Args: 2,
|
||||
},
|
||||
|
||||
"input": &ast.Function{
|
||||
Function: input,
|
||||
Name: "input",
|
||||
|
|
|
|||
|
|
@ -22,4 +22,19 @@ import (
|
|||
"gitlab.com/whom/shs/log"
|
||||
)
|
||||
|
||||
func export(input *ast.Token, vars ast.VarTable, funcs ast.FuncTable) *ast.Token {
|
||||
input = input.Eval(funcs, vars, false)
|
||||
|
||||
name := input
|
||||
form := name.Next
|
||||
if name.Tag != ast.STRING {
|
||||
log.Log(log.ERR,
|
||||
"non string handed to name arg",
|
||||
"export")
|
||||
return nil
|
||||
}
|
||||
|
||||
ast.SetVar(name.Value(), form, vars)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue