Add ability to define functions with dashes in name

This commit is contained in:
Elara 2021-04-29 23:14:52 -07:00
parent 836149ffc2
commit 31c3a2f3a9
2 changed files with 4 additions and 4 deletions

2
ast.go
View File

@ -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 `@@* "}"`
}

View File

@ -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}