diff options
author | ZyX <kp-pav@yandex.ru> | 2017-09-03 21:58:16 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-10-08 22:25:03 +0300 |
commit | 430e516d3ac1235c1ee3009a8a36089bf278440e (patch) | |
tree | 8c5adecf383ae70cd61044d98873f71d135050b3 /test/unit/helpers.lua | |
parent | 919223c23ae3c8c904f35e7d605b1cf14d44a5f0 (diff) | |
download | rneovim-430e516d3ac1235c1ee3009a8a36089bf278440e.tar.gz rneovim-430e516d3ac1235c1ee3009a8a36089bf278440e.tar.bz2 rneovim-430e516d3ac1235c1ee3009a8a36089bf278440e.zip |
viml/parser/expressions: Start creating expressions parser
Currently supported nodes:
- Register as it is one of the simplest value nodes (even numbers are
not that simple with that dot handling).
- Plus, both unary and binary.
- Parenthesis, both nesting and calling.
Note regarding unit tests: it stores data for AST in highlighting in
strings in place of tables because luassert fails to do a good job at
representing big tables. Squashing a bunch of data into a single string
simply yields more readable result.
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r-- | test/unit/helpers.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index a5ca7b069b..d3d14a5ca2 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -783,6 +783,31 @@ local function kvi_new(ct) return kvi_init(ffi.new(ct)) end +local function make_enum_conv_tab(lib, values, skip_pref, set_cb) + child_call_once(function() + local ret = {} + for _, v in ipairs(values) do + local str_v = v + if v:sub(1, #skip_pref) == skip_pref then + str_v = v:sub(#skip_pref + 1) + end + ret[tonumber(lib[v])] = str_v + end + set_cb(ret) + end) +end + +local function ptr2addr(ptr) + return tonumber(ffi.cast('intptr_t', ffi.cast('void *', ptr))) +end + +local s = ffi.new('char[64]', {0}) + +local function ptr2key(ptr) + ffi.C.snprintf(s, ffi.sizeof(s), '%p', ffi.cast('void *', ptr)) + return ffi.string(s) +end + local module = { cimport = cimport, cppimport = cppimport, @@ -808,6 +833,9 @@ local module = { kvi_size = kvi_size, kvi_init = kvi_init, kvi_new = kvi_new, + make_enum_conv_tab = make_enum_conv_tab, + ptr2addr = ptr2addr, + ptr2key = ptr2key, } return function() return module |