diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/parser/ast.lua | 3 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 5 | ||||
-rw-r--r-- | server/src/vm/value.lua | 6 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 6 |
4 files changed, 14 insertions, 6 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index ff0a4306..136d7565 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -648,8 +648,7 @@ local Defs = { key, value, } end, - NewIndex = function (start, key, finish, value) - key.index = true + NewIndex = function (key, value) return { type = 'pair', start = key.start, diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 599aada2..42e52d05 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -306,11 +306,12 @@ Simple <- (Prefix (Sp Suffix)*) Prefix <- Sp ({} PL DirtyExp DirtyPR) -> Prefix / FreeName +Index <- ({} BL DirtyExp DirtyBR) -> Index Suffix <- DOT Name / DOT {} -> MissField / Method (!(Sp CallStart) {} -> MissPL)? / ({} Table {}) -> Call / ({} String {}) -> Call - / ({} BL DirtyExp DirtyBR) -> Index + / Index / ({} PL CallArgList DirtyPR) -> Call Method <- COLON Name / COLON {} -> MissMethod CallStart <- PL @@ -341,7 +342,7 @@ Table <- Sp ({} TL TableFields? DirtyTR) TableFields <- (Emmy / TableSep {} / TableField)+ TableSep <- COMMA / SEMICOLON TableField <- NewIndex / NewField / Exp -NewIndex <- Sp ({} BL DirtyExp DirtyBR NeedAssign DirtyExp) +NewIndex <- Sp (Index NeedAssign DirtyExp) -> NewIndex NewField <- (MustName ASSIGN DirtyExp) -> NewField diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 19aa1ee4..783bfc4e 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -101,6 +101,9 @@ function mt:getType() end function mt:rawSet(index, value, source) + if index == nil then + return + end if not self._child then self._child = {} end @@ -134,6 +137,9 @@ function mt:rawGet(index) end function mt:setChild(index, value, source) + if index == nil then + return + end self:setType('table', 0.5) self:rawSet(index, value, source) return value diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index f10e07a4..7f5250eb 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -49,8 +49,8 @@ function mt:buildTable(source) self:instantSource(key) key:bindValue(value, 'set') value:setEmmy(emmy) - if key.index then - local index = self:getIndex(obj) + if key.type == 'index' then + local index = self:getIndex(key) key:set('parent', tbl) tbl:setChild(index, value, key) else @@ -699,6 +699,8 @@ function mt:getExp(exp) return value elseif tp == 'simple' then return self:getSimple(exp) + elseif tp == 'index' then + return self:getIndex(exp) elseif tp == 'binary' then return self:getBinary(exp) elseif tp == 'unary' then |