diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-19 21:14:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-19 21:14:44 +0800 |
commit | 15f76378dbe93a3cbff155c8e98f9bed59af75b0 (patch) | |
tree | 37d18868909bd3c9cbd96378af6343ee82ce92b3 /src/parser | |
parent | 2712ffefa8275ad9039b6355846378e5f2019d38 (diff) | |
download | lua-language-server-15f76378dbe93a3cbff155c8e98f9bed59af75b0.zip |
全局变量在第一次赋值时定义
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/grammar.lua | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/parser/grammar.lua b/src/parser/grammar.lua index 7f20b5c2..ef2fbcd3 100644 --- a/src/parser/grammar.lua +++ b/src/parser/grammar.lua @@ -215,7 +215,8 @@ ExpUnit <- Nil / Function / Simple -Simple <- Prefix (Suffix)* +Simple <- (Prefix (Suffix)*) + -> Simple Prefix <- PL Exp PR / Name ColonName <- (COLON Name) @@ -239,8 +240,12 @@ TableField <- NewIndex / NewField / Exp NewIndex <- BL Exp BR ASSIGN Exp NewField <- Name ASSIGN Exp -Function <- (FUNCTION FuncName PL ArgList PR) -> FunctionDef - (!END Action)* -> Function +Function <- FunctionLoc / FunctionDef +FunctionLoc <- (LOCAL FUNCTION FuncName PL ArgList PR) -> FunctionLoc + (!END Action)* -> Function + END +FunctionDef <- (FUNCTION FuncName PL ArgList PR) -> FunctionDef + (!END Action)* -> Function END FuncName <- (Name (FuncSuffix)*)? -> FuncName @@ -252,7 +257,7 @@ Action <- !. . ]] grammar 'Action' [[ -Action <- SEMICOLON / Do / Break / Return / Label / GoTo / If / For / While / Repeat / Set / Local / Function / Call +Action <- SEMICOLON / Do / Break / Return / Label / GoTo / If / For / While / Repeat / Function / Set / Local / Call ExpList <- Exp (COMMA Exp)* NameList <- (Name (COMMA Name)*) -> NameList @@ -302,13 +307,12 @@ Repeat <- REPEAT -> RepeatDef (!UNTIL Action)* -> Repeat (UNTIL Exp) -> Until -Set <- (LOCAL !FUNCTION NameList ASSIGN ExpList) +Set <- (LOCAL NameList ASSIGN ExpList) -> LocalSet - / SimpleList ASSIGN ExpList + / (SimpleList ASSIGN ExpList) + -> Set -Local <- LOCAL Function - -> LocalFunction - / LOCAL NameList +Local <- LOCAL NameList -> LocalVar Call <- Prefix (Suffix)* |