From 459717cd81450acddd863bcabce9e77a3a1efec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 30 Jul 2019 11:13:03 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0LuaParser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/parser/ast.lua | 8 ++++++-- server/src/parser/grammar.lua | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'server/src/parser') diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index a83f5abf..0be0027d 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -996,10 +996,14 @@ local Defs = { end return tags end, - Local = function (tags, keys, values) + LocalName = function (tags, name) + name.tags = tags + return name + end, + Local = function (keys, values) return { type = 'local', - keys, values, tags + keys, values, } end, DoBody = function (...) diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index a923e5eb..aa44a3ce 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -493,10 +493,15 @@ RepeatBody <- REPEAT LocalTag <- (Sp '<' Sp MustName Sp LocalTagEnd)* -> LocalTag LocalTagEnd <- '>' / {} -> MissGT -Local <- (LOCAL LocalTag NameList (AssignOrEQ ExpList)?) +Local <- (LOCAL LocalNameList (AssignOrEQ ExpList)?) -> Local Set <- (SimpleList AssignOrEQ ExpList?) -> Set +LocalNameList + <- (LocalName (COMMA LocalName)*) + -> List +LocalName <- (LocalTag MustName) + -> LocalName Call <- Simple -> SimpleCall -- cgit v1.2.3