From fb47c11bd942c83317f1f9a2e255535649401cbf Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 28 Jan 2020 00:41:53 +0800 Subject: Add multi-line comment support. Add escape new line symbol. Add back call syntax. --- spec/inputs/backcall.moon | 46 ++++++++++++++++++++++++++++++++++++++++++++++ spec/inputs/syntax.moon | 10 ++++++++++ 2 files changed, 56 insertions(+) create mode 100644 spec/inputs/backcall.moon (limited to 'spec') diff --git a/spec/inputs/backcall.moon b/spec/inputs/backcall.moon new file mode 100644 index 0000000..407a5a7 --- /dev/null +++ b/spec/inputs/backcall.moon @@ -0,0 +1,46 @@ + +{"abc", 123, 998} |> foreach print + +{1,2,3} \ + |> map((x)-> x * 2) \ + |> filter((x)-> x > 4) \ + |> reduce(0, (a,b)-> a + b) \ + |> print + +[i |> tostring for i = 0,10] |> table.concat(",") |> print + +b = 1 + 2 + (4 |> tostring |> print(1) or 123) + +if x = 233 |> math.max 998 + print x + +998 |> func2 "abc", 233 |> func0 |> func1 +998 |> func0("abc", 233) |> func1 |> func2 + +do + (data) <- http?.get "ajaxtest" + body[".result"]\html data + (processed) <- http.get "ajaxprocess", data + body[".result"]\append processed + <- setTimeout 1000 + print "done" + +do + <- syncStatus + (err,data="nil") <- loadAsync "file.moon" + print err if err + (codes) <- compileAsync data + func = loadstring codes + func! + +do + <- f1 + <- f2 + do + <- f3 + <- f4 + <- f5 + <- f6 + f7! + +alert "hi" diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon index bf0cf04..3ac9991 100644 --- a/spec/inputs/syntax.moon +++ b/spec/inputs/syntax.moon @@ -270,3 +270,13 @@ z = a- b -- cooool + +str = --[[ +This is a multi line comment. +It's OK. +]] strA \ -- comment 1 + .. strB \ -- comment 2 + .. strC + +func --[[port]] 3000, --[[ip]] "192.168.1.1" + -- cgit v1.2.3-55-g6feb