diff options
-rw-r--r-- | server-beta/src/core/engineer.lua | 2 | ||||
-rw-r--r-- | server-beta/src/parser/ast.lua | 16 | ||||
-rw-r--r-- | server-beta/src/parser/guide.lua | 6 |
3 files changed, 14 insertions, 10 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua index dae501b1..12aab98d 100644 --- a/server-beta/src/core/engineer.lua +++ b/server-beta/src/core/engineer.lua @@ -142,8 +142,6 @@ mt['field'] = function (self, source, mode, callback) end end) end -mt['getfield'] = mt['field'] -mt['setfield'] = mt['field'] mt['special'] = function (self, source, mode, callback) local name = self:getSpecial(source) if not name then diff --git a/server-beta/src/parser/ast.lua b/server-beta/src/parser/ast.lua index 47a8d4d1..727cec9e 100644 --- a/server-beta/src/parser/ast.lua +++ b/server-beta/src/parser/ast.lua @@ -558,16 +558,18 @@ local Defs = { } end, GetField = function (dot, field) - if field then - field.type = 'field' - end - return { + local obj = { type = 'getfield', field = field, dot = dot, start = dot.start, finish = (field or dot).finish, } + if field then + field.type = 'field' + field.node = obj + end + return obj end, GetIndex = function (start, index, finish) return { @@ -898,14 +900,16 @@ local Defs = { return tbl end, NewField = function (start, field, value, finish) - field.type = 'field' - return { + local obj = { type = 'tablefield', start = start, finish = finish-1, field = field, value = value, } + field.type = 'field' + field.node = obj + return obj end, Index = function (start, index, finish) return { diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index 4ef433dd..f06264cd 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -36,7 +36,7 @@ m.childMap = { ['ifblock'] = {'filter', '#'}, ['elseifblock'] = {'filter', '#'}, ['elseblock'] = {'#'}, - ['setfield'] = {'node', 'value'}, + ['setfield'] = {'node', 'field', 'value'}, ['setglobal'] = {'value'}, ['local'] = {'attrs', 'value'}, ['setlocal'] = {'value'}, @@ -56,7 +56,7 @@ m.childMap = { ['paren'] = {'exp'}, ['call'] = {'node', 'args'}, ['callargs'] = {'#'}, - ['getfield'] = {'node'}, + ['getfield'] = {'node', 'field'}, ['list'] = {'#'}, } @@ -363,6 +363,8 @@ function m.getKeyName(obj) return obj[1] elseif obj.type == 'getfield' or obj.type == 'setfield' then return obj.field[1] + elseif obj.type == 'field' then + return obj[1] end return nil end |