From e958b59c9635f0a01e29e3f30c34adecd327cc1f Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 11 Sep 2020 17:59:53 +0800 Subject: revert binary operator rules, change implicit object start symbol. --- spec/inputs/syntax.moon | 24 ++++++++++++------------ spec/inputs/tables.moon | 13 +++++++------ src/MoonP/moon_parser.cpp | 4 ++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon index 4435a1e..99daac5 100644 --- a/spec/inputs/syntax.moon +++ b/spec/inputs/syntax.moon @@ -284,8 +284,8 @@ z = a- b str = --[[ This is a multi line comment. It's OK. -]] strA -- comment 1 - .. strB -- comment 2 +]] strA \ -- comment 1 + .. strB \ -- comment 2 .. strC func --[[port]] 3000, --[[ip]] "192.168.1.1" @@ -322,7 +322,7 @@ v = { a -1 a( -1) - a + a \ - 1 a-1 a - 1 @@ -335,7 +335,7 @@ v = { a ~1 a( ~1) - a + a \ ~ 1 a~1 a ~ 1 @@ -347,26 +347,26 @@ v = { } do - a = 1 - + 2 + a = 1 \ + + 2 \ * 3 / 4 - _1 = f1 -1 - + 2 + _1 = f1 -1 \ + + 2 \ + 3 - _2 = f1 - 1 - + 2 + _2 = f1 - 1 \ + + 2 \ + 3 - f2 = (x)-> print x + f2 = (x)-> print x \ +1 a = f2! -1 |> f2 - a = f2! + a = f2! \ - 1 |> f2 _1 \ diff --git a/spec/inputs/tables.moon b/spec/inputs/tables.moon index a1e861b..079be35 100644 --- a/spec/inputs/tables.moon +++ b/spec/inputs/tables.moon @@ -164,20 +164,21 @@ heroine = age: 18 job: "Princess" likes: - # name: "kittens" + * name: "kittens" img: "/image/kittens.png" - # name: "flower" + * name: "flower" img: "/image/flower.png" items: - # name: "ring" + * name: "ring" amount: 2 - # name: "necklace" + * name: "necklace" amount: 1 status: desc: "weak" - # attribute: "health" + * attribute: "health" value: 50 - # attribute: "mana" + * attribute: "mana" value: 100 nil + diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 53a6b8f..394ce50 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp @@ -332,7 +332,7 @@ MoonParser::MoonParser() { expr(">>") | expr("//") | set("+-*/%><|&~"); - exp_op_value = (White >> not_(unary_operator) | Space) >> BinaryOperator >> *SpaceBreak >> backcall_exp; + exp_op_value = Space >> BinaryOperator >> *SpaceBreak >> backcall_exp; Exp = Seperator >> backcall_exp >> *exp_op_value; ChainValue = Seperator >> (Chain | Callable) >> -existential_op >> -InvokeArgs; @@ -432,7 +432,7 @@ MoonParser::MoonParser() { TableBlockInner = Seperator >> KeyValueLine >> *(+SpaceBreak >> KeyValueLine); TableBlock = +SpaceBreak >> Advance >> ensure(TableBlockInner, PopIndent); - TableBlockIndent = sym('#') >> Seperator >> KeyValueList >> -sym(',') >> + TableBlockIndent = sym('*') >> Seperator >> KeyValueList >> -sym(',') >> -(+SpaceBreak >> Advance >> ensure(KeyValueList >> -sym(',') >> *(+SpaceBreak >> KeyValueLine), PopIndent)); class_member_list = Seperator >> KeyValue >> *(sym(',') >> KeyValue); -- cgit v1.2.3-55-g6feb