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
|
// FuncDef stores any function definitions encountered while parsing a script
|
||||||
type FuncDef struct {
|
type FuncDef struct {
|
||||||
Pos lexer.Position
|
Pos lexer.Position
|
||||||
Name *string `"define" @Ident "{"`
|
Name *string `"define" @Ident @("-" Ident)* "{"`
|
||||||
InnerCmds []*Command `@@* "}"`
|
InnerCmds []*Command `@@* "}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,12 +65,12 @@ repeat 6 times { i in
|
|||||||
print {"brktest: " + (str $i) + " (2)"}
|
print {"brktest: " + (str $i) + " (2)"}
|
||||||
}
|
}
|
||||||
|
|
||||||
define hi {
|
define hello-x {
|
||||||
print {"Hello, " + $_args[""]}
|
print {"Hello, " + $_args[""]}
|
||||||
return {"Hello, " + $_args[""]}
|
return {"Hello, " + $_args[""]}
|
||||||
print "Something isn't right"
|
print "Something isn't right"
|
||||||
}
|
}
|
||||||
|
|
||||||
hi "Function"
|
hello-x "Function"
|
||||||
set f to (hi "World")
|
set f to (hello-x "World")
|
||||||
print {"Returned: " + $f}
|
print {"Returned: " + $f}
|
Loading…
Reference in New Issue
Block a user