From 584b26c62fafe843c6ae618dba1350d07bf8f091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 31 Dec 2018 19:06:15 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=AD=E6=B3=95=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/parser/ast.lua | 5 ++++- server/src/parser/grammar.lua | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'server/src/parser') diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 291d93c6..ae46e660 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -306,7 +306,7 @@ local defs = { key, value, } end, - NewIndex = function (key, value) + NewIndex = function (start, key, finish, value) key.index = true return { type = 'pair', @@ -639,6 +639,7 @@ local defs = { symbol = '}', } } + return pos + 1 end, MissBR = function (pos) pushError { @@ -649,6 +650,7 @@ local defs = { symbol = ']', } } + return pos + 1 end, MissPR = function (pos) pushError { @@ -659,6 +661,7 @@ local defs = { symbol = ')', } } + return pos + 1 end, ErrEsc = function (pos) pushError { diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 3bff2e31..907a5754 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -61,6 +61,7 @@ defs.NotReserved = function (_, _, str) end return true, str end +defs.np = m.Cp() / function (n) return n+1 end local eof = re.compile '!. / %{SYNTAX_ERROR}' @@ -192,9 +193,9 @@ Nothing <- {} -> Nothing TOCLOSE <- Sp '*toclose' DirtyAssign <- ASSIGN / {} -> MissAssign -DirtyBR <- BR / {} -> MissBR -DirtyTR <- TR / {} -> MissTR -DirtyPR <- PR / {} -> MissPR +DirtyBR <- BR {} / {} -> MissBR +DirtyTR <- TR {} / {} -> MissTR +DirtyPR <- PR {} / {} -> MissPR ]] grammar 'Nil' [[ @@ -289,7 +290,7 @@ Suffix <- DOT MustName / Sp ({} Table {}) -> Call / Sp ({} String {}) -> Call / Sp ({} BL DirtyExp (BR / Sp) {}) -> Index - / Sp ({} PL CallArgList DirtyPR {}) -> Call + / Sp ({} PL CallArgList DirtyPR) -> Call DirtyExp <- Exp / {} -> DirtyExp @@ -319,14 +320,14 @@ AfterArg <- DOTS / MustName -Table <- Sp ({} TL TableFields? DirtyTR {}) +Table <- Sp ({} TL TableFields? DirtyTR) -> Table TableFields <- (TableSep {} / TableField / DirtyField)+ DirtyField <- Sp ({} {(!TR !BL !COMMA !SEMICOLON !Word .)+}) -> UnknownSymbol TableSep <- COMMA / SEMICOLON TableField <- NewIndex / NewField / Exp -NewIndex <- (BL DirtyExp DirtyBR DirtyAssign DirtyExp) +NewIndex <- Sp ({} BL DirtyExp DirtyBR DirtyAssign DirtyExp) -> NewIndex NewField <- (MustName ASSIGN DirtyExp) -> NewField -- cgit v1.2.3