From 31c3a2f3a9668df89c9a38b617e72a663e454906 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Thu, 29 Apr 2021 23:14:52 -0700 Subject: [PATCH] Add ability to define functions with dashes in name --- ast.go | 2 +- test.scpt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ast.go b/ast.go index 03d9a74..4642b62 100644 --- a/ast.go +++ b/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 `@@* "}"` } diff --git a/test.scpt b/test.scpt index 64919a4..67bb274 100755 --- a/test.scpt +++ b/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} \ No newline at end of file