summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-23 21:33:58 +0800
committersumneko <sumneko@hotmail.com>2019-04-23 21:33:58 +0800
commita4d7980a4d648b2baf54a6adefb1758d037424b3 (patch)
treebed83bfbf036bc6ffba3e6b58c12f545b5c7259d /server/src
parentef7e113a22eebdf6c56b0060c93cdf9df372d3d8 (diff)
downloadlua-language-server-a4d7980a4d648b2baf54a6adefb1758d037424b3.zip
修正某些脚本文件解析速度极慢的BUG
Diffstat (limited to 'server/src')
-rw-r--r--server/src/parser/ast.lua1
-rw-r--r--server/src/parser/grammar.lua29
-rw-r--r--server/src/service.lua3
3 files changed, 18 insertions, 15 deletions
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)