diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-17 15:13:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-17 15:13:50 +0800 |
commit | 31e9a5235cd17c8a61d2a0a732212cd68135bed5 (patch) | |
tree | e484a02b70633ff4a50eeb4ba4a9337b285c3b1b /script/parser | |
parent | f2559d2f42f8357c49b13b5df3a72bf5d7418797 (diff) | |
download | lua-language-server-31e9a5235cd17c8a61d2a0a732212cd68135bed5.zip |
update
Diffstat (limited to 'script/parser')
-rw-r--r-- | script/parser/newparser.lua | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 0e12ab45..9721526c 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -2340,17 +2340,26 @@ function parseExp(asAction, level) if uop then skipSpace() local child = parseExp(asAction, uopLevel) - exp = { - type = 'unary', - op = uop, - start = uop.start, - finish = child and child.finish or uop.finish, - [1] = child, - } - if child then - child.parent = exp + -- 预计算负数 + if uop.type == '-' + and child + and (child.type == 'number' or child.type == 'integer') then + child.start = uop.start + child[1] = - child[1] + exp = child else - missExp() + exp = { + type = 'unary', + op = uop, + start = uop.start, + finish = child and child.finish or uop.finish, + [1] = child, + } + if child then + child.parent = exp + else + missExp() + end end else exp = parseExpUnit() |