Add ability to define functions with dashes in name
This commit is contained in:
parent
836149ffc2
commit
31c3a2f3a9
2
ast.go
2
ast.go
@ -400,7 +400,7 @@ type MapKVPair struct {
|
||||
// FuncDef stores any function definitions encountered while parsing a script
|
||||
type FuncDef struct {
|
||||
Pos lexer.Position
|
||||
Name *string `"define" @Ident "{"`
|
||||
Name *string `"define" @Ident @("-" Ident)* "{"`
|
||||
InnerCmds []*Command `@@* "}"`
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,12 @@ repeat 6 times { i in
|
||||
print {"brktest: " + (str $i) + " (2)"}
|
||||
}
|
||||
|
||||
define hi {
|
||||
define hello-x {
|
||||
print {"Hello, " + $_args[""]}
|
||||
return {"Hello, " + $_args[""]}
|
||||
print "Something isn't right"
|
||||
}
|
||||
|
||||
hi "Function"
|
||||
set f to (hi "World")
|
||||
hello-x "Function"
|
||||
set f to (hello-x "World")
|
||||
print {"Returned: " + $f}
|
Loading…
Reference in New Issue
Block a user