From a4d7980a4d648b2baf54a6adefb1758d037424b3 Mon Sep 17 00:00:00 2001 From: sumneko Date: Tue, 23 Apr 2019 21:33:58 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9F=90=E4=BA=9B=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=A7=A3=E6=9E=90=E9=80=9F=E5=BA=A6=E6=9E=81?= =?UTF-8?q?=E6=85=A2=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.lua | 2 +- server/src/parser/ast.lua | 1 - server/src/parser/grammar.lua | 29 +++++++++++++++-------------- server/src/service.lua | 3 +++ 4 files changed, 19 insertions(+), 16 deletions(-) (limited to 'server') diff --git a/server/main.lua b/server/main.lua index ac7860c5..685fce01 100644 --- a/server/main.lua +++ b/server/main.lua @@ -22,7 +22,7 @@ local function tryDebugger() log.info('Debugger startup, listen port: 11411') end ---pcall(tryDebugger) +pcall(tryDebugger) require 'utility' require 'global_protect' diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 83c877e4..19aabb9d 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -1538,4 +1538,3 @@ return function (self, lua, mode, version) end return res, Errs end - diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index b5e083e6..00c3dbdb 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -184,18 +184,18 @@ UnaryList <- NOT / '~' !'=' POWER <- Sp {'^'} -BinaryOp <- {} {'or'} Cut - / {} {'and'} Cut - / {} {'<=' / '>=' / '<'!'<' / '>'!'>' / '~=' / '=='} - / {} {'|'} - / {} {'~'} - / {} {'&'} - / {} {'<<' / '>>'} - / {} {'..'} !'.' - / {} {'+' / '-'} - / {} {'*' / '//' / '/' / '%'} - / {} {'^'} -UnaryOp <- {} {'not' Cut / '#' / '~' / '-'} +BinaryOp <- Sp {} {'or'} Cut + / Sp {} {'and'} Cut + / Sp {} {'<=' / '>=' / '<'!'<' / '>'!'>' / '~=' / '=='} + / Sp {} {'|'} + / Sp {} {'~'} + / Sp {} {'&'} + / Sp {} {'<<' / '>>'} + / Sp {} {'..'} !'.' + / Sp {} {'+' / '-'} + / Sp {} {'*' / '//' / '/' / '%'} + / Sp {} {'^'} +UnaryOp <- Sp {} {'not' Cut / '#' / '~' !'=' / '-' !'-'} PL <- Sp '(' PR <- Sp ')' @@ -290,9 +290,10 @@ DirtyName <- {} -> DirtyName ]] grammar 'Exp' [[ -Exp <- ((Sp (UnaryOp / ExpUnit Sp BinaryOp))+ (Sp ExpUnit / {}->DirtyExp)) +Exp <- (UnUnit (BinaryOp (UnUnit / {} -> DirtyExp))*) -> Exp - / Sp ExpUnit +UnUnit <- ExpUnit + / UnaryOp+ (ExpUnit / {} -> DirtyExp) ExpUnit <- Nil / Boolean / String diff --git a/server/src/service.lua b/server/src/service.lua index ea3c4488..01d3424d 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -434,6 +434,9 @@ function mt:compileVM(uri) local ast = self:compileAst(obj) local version = obj.version obj.astCost = os.clock() - clock + if obj.astCost > 0.1 then + log.warn(('Compile[%s] takes [%.3f] sec, size [%.3f]kb'):format(uri, obj.astCost, #obj.text)) + end obj.oldText = nil self:_clearChainNode(obj, uri) -- cgit v1.2.3