add rudimentary control flow
This commit is contained in:
parent
de5566b3ec
commit
a216d9af41
3 changed files with 115 additions and 1 deletions
|
|
@ -26,7 +26,28 @@ import (
|
|||
func GenFuncTable() ast.FuncTable {
|
||||
var stdlib ast.FuncTable
|
||||
stdlib = &map[string]*ast.Function{
|
||||
"...": &ast.Function{
|
||||
"if": &ast.Function{
|
||||
Function: shs_if,
|
||||
Name: "if",
|
||||
TimesCalled: 0,
|
||||
Args: 3,
|
||||
},
|
||||
|
||||
"while": &ast.Function{
|
||||
Function: shs_while,
|
||||
Name: "while",
|
||||
TimesCalled: 0,
|
||||
Args: -1,
|
||||
},
|
||||
|
||||
"eval": &ast.Function{
|
||||
Function: eval,
|
||||
Name: "eval",
|
||||
TimesCalled: 0,
|
||||
Args: -1,
|
||||
},
|
||||
|
||||
"...": &ast.Function{
|
||||
Function: expand,
|
||||
Name: "...",
|
||||
TimesCalled: 0,
|
||||
|
|
@ -242,3 +263,7 @@ func sh_info(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func eval(in *ast.Token, vt ast.VarTable, ft ast.VarTable) *ast.Token {
|
||||
return in.Eval(ft, vt, false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue