From db0c04a5f59ecdb7c57610f6abb56f6407551b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 17 Nov 2019 14:22:04 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=AD=E6=B3=95=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/parser/ast.lua | 10 ++++++++++ server-beta/src/parser/grammar.lua | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'server-beta/src/parser') diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index ff5a6ae1..c5303796 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -661,6 +661,16 @@ local Defs = { end return e end, + SubBinary = function (op, symb) + if symb then + return op, symb + end + PushError { + type = 'MISS_EXP', + start = op.start, + finish = op.finish, + } + end, Binary = function (first, op, second, ...) if not first then return second diff --git a/server-beta/src/parser/grammar.lua b/server-beta/src/parser/grammar.lua index b64f6277..48e2f86e 100644 --- a/server-beta/src/parser/grammar.lua +++ b/server-beta/src/parser/grammar.lua @@ -297,8 +297,10 @@ DirtyName <- {} -> DirtyName ]] grammar 'Exp' [[ -Exp <- (UnUnit (BinaryOp UnUnit / BinaryOp->None MissExp)*) +Exp <- (UnUnit BinUnit*) -> Binary +BinUnit <- (BinaryOp UnUnit?) + -> SubBinary UnUnit <- ExpUnit / (UnaryOp+ (ExpUnit / MissExp)) -> Unary -- cgit v1.2.3