summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-07 10:19:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-07 10:19:24 +0800
commitde63af45054e742806f6f4cc78e2819b12c364e6 (patch)
tree5551e1b50f8ed12f32dc9b72bcbb028990d7cede
parenta55bc60e412ac97ca90d4dc4f13c15f58b0a6cdb (diff)
downloadlua-language-server-de63af45054e742806f6f4cc78e2819b12c364e6.zip
跳过动作
-rw-r--r--server/src/core/vm.lua4
-rw-r--r--server/src/parser/ast.lua3
-rw-r--r--server/src/parser/grammar.lua8
-rw-r--r--server/test/vm/example.lua5
4 files changed, 17 insertions, 3 deletions
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index 36a8f21b..a17727d6 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -1383,6 +1383,10 @@ function mt:doLocalFunction(action)
end
function mt:doAction(action)
+ if not action then
+ -- Skip
+ return
+ end
local tp = action.type
if tp == 'do' then
self:doDo(action)
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index d08db694..993a4914 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -379,6 +379,9 @@ local defs = {
Nothing = function ()
return nil
end,
+ Skip = function ()
+ return false
+ end,
Set = function (keys, values)
return {
type = 'set',
diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua
index 133ffbbd..6dfbeed6 100644
--- a/server/src/parser/grammar.lua
+++ b/server/src/parser/grammar.lua
@@ -75,8 +75,8 @@ end
local function errorpos(pos, err)
return {
type = 'UNKNOWN',
- start = pos,
- finish = pos,
+ start = pos or 0,
+ finish = pos or 0,
err = err,
}
end
@@ -351,7 +351,7 @@ Set <- END
grammar 'Action' [[
Action <- Sp (CrtAction / UnkAction)
-CrtAction <- SEMICOLON
+CrtAction <- Semicolon
/ Do
/ Break
/ Return
@@ -372,6 +372,8 @@ UnkAction <- ({} {Word+})
/ ({} {. (!Sps !CrtAction .)*})
-> UnknownSymbol
+Semicolon <- SEMICOLON
+ -> Skip
SimpleList <- (Simple (COMMA Simple)*)
-> List
diff --git a/server/test/vm/example.lua b/server/test/vm/example.lua
index 3b040a32..5775465b 100644
--- a/server/test/vm/example.lua
+++ b/server/test/vm/example.lua
@@ -1 +1,6 @@
+local fs = require 'bee.filesystem'
+
TEST(io.load(ROOT / 'src' / 'core' / 'vm.lua'))
+
+-- 临时
+TEST(io.load(fs.path [[D:\Github\lua\testes\constructs.lua]]))