diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-12-13 21:00:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-12-13 21:00:38 +0800 |
commit | eb05f7ac0f85d034c20e29f68b12d84fa7436601 (patch) | |
tree | 1f93744bf103c861bfe2252f3b7d2eb37ef741d7 /script/parser | |
parent | ed97a9e8905fdbb3b23694896c813cfdb73cd91f (diff) | |
download | lua-language-server-eb05f7ac0f85d034c20e29f68b12d84fa7436601.zip |
stash
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/compile.lua | 45 | ||||
-rw-r--r-- | script/parser/guide.lua | 3 |
2 files changed, 30 insertions, 18 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua index b8040382..73aef048 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -3136,6 +3136,22 @@ local function parseGoTo() return action end +local function parseFilter() + local exp = parseExp() + if exp then + local filter = { + type = 'filter', + start = exp.start, + finish = exp.finish, + exp = exp, + } + exp.parent = filter + return filter + else + missExp() + end +end + local function parseIfBlock(parent) local ifLeft = getPosition(Tokens[Index], 'left') local ifRight = getPosition(Tokens[Index] + 1, 'right') @@ -3151,13 +3167,11 @@ local function parseIfBlock(parent) } } skipSpace() - local filter = parseExp() + local filter = parseFilter() if filter then ifblock.filter = filter ifblock.finish = filter.finish filter.parent = ifblock - else - missExp() end skipSpace() local thenToken = Tokens[Index + 1] @@ -3210,13 +3224,11 @@ local function parseElseIfBlock(parent) } Index = Index + 2 skipSpace() - local filter = parseExp() + local filter = parseFilter() if filter then elseifblock.filter = filter elseifblock.finish = filter.finish filter.parent = elseifblock - else - missExp() end skipSpace() local thenToken = Tokens[Index + 1] @@ -3524,15 +3536,16 @@ local function parseWhile() skipSpace() local nextToken = Tokens[Index + 1] - local filter = nextToken ~= 'do' - and nextToken ~= 'then' - and parseExp() - if filter then - action.filter = filter - action.finish = filter.finish - filter.parent = action - else + if nextToken == 'do' + or nextToken == 'then' then missExp() + else + local filter = parseFilter() + if filter then + action.filter = filter + action.finish = filter.finish + filter.parent = action + end end skipSpace() @@ -3611,12 +3624,10 @@ local function parseRepeat() Index = Index + 2 skipSpace() - local filter = parseExp() + local filter = parseFilter() if filter then action.filter = filter filter.parent = action - else - missExp() end else diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 147e6237..c74593a4 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -139,7 +139,8 @@ local childMap = { ['getfield'] = {'node', 'field'}, ['list'] = {'#'}, ['binary'] = {1, 2}, - ['unary'] = {1}, + ['unary'] = { 1 }, + ['filter'] = {'exp'}, ['doc'] = {'#'}, ['doc.class'] = {'class', '#extends', '#signs', 'comment'}, |