summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/locale/en-US/script.lni1
-rw-r--r--server/locale/zh-CN/script.lni1
-rw-r--r--server/src/parser/ast.lua8
-rw-r--r--server/src/parser/grammar.lua4
4 files changed, 12 insertions, 2 deletions
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni
index cdd3ffa9..1f1b68d0 100644
--- a/server/locale/en-US/script.lni
+++ b/server/locale/en-US/script.lni
@@ -15,5 +15,6 @@ MWS_COMPLETE = 'Workspace is complete now. You may try again...'
PARSER_CRASH = 'Parser crashed! Last words:{}'
PARSER_UNKNOWN = 'Unknown syntax error...'
+PARSER_MISS_NAME = '<name> expected'
SYMBOL_ANONYMOUS = '<Anonymous>'
diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni
index c0922bac..d207078d 100644
--- a/server/locale/zh-CN/script.lni
+++ b/server/locale/zh-CN/script.lni
@@ -15,5 +15,6 @@ MWS_COMPLETE = '工作目录准备好了,你可以再试一下了...'
PARSER_CRASH = '语法解析崩溃了!遗言:{}'
PARSER_UNKNOWN = '未知语法错误...'
+PARSER_MISS_NAME = '需要一个名字'
SYMBOL_ANONYMOUS = '<匿名函数>'
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index 2096fd28..c419e50a 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -75,6 +75,12 @@ local defs = {
}
end,
DirtyName = function (pos)
+ pushError {
+ type = 'MISS_NAME',
+ start = pos,
+ finish = pos,
+ level = 'error',
+ }
return {
type = 'name',
start = pos,
@@ -429,5 +435,5 @@ return function (self, lua, mode)
pushError(err)
return nil, Errs
end
- return res
+ return res, Errs
end
diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua
index 5ec5b826..7afea5e7 100644
--- a/server/src/parser/grammar.lua
+++ b/server/src/parser/grammar.lua
@@ -269,7 +269,9 @@ ExpList <- (COMMA DirtyExp)+
-> List
NameList <- (COMMA MustName)+
-> List
- / (Name (COMMA MustName)*)?
+ / (Name (COMMA MustName)*)
+ -> List
+ / DirtyName
-> List
ArgList <- (COMMA AfterArg)+