Browse Source

Add ability to define functions with dashes in name

master
Arsen Musayelyan 6 months ago
parent
commit
31c3a2f3a9
  1. 2
      ast.go
  2. 6
      test.scpt

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

6
test.scpt

@ -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…
Cancel
Save