Skip to content

Instantly share code, notes, and snippets.

@haya14busa
Created July 19, 2017 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haya14busa/47f53f3c92c1756c6680737c28386865 to your computer and use it in GitHub Desktop.
Save haya14busa/47f53f3c92c1756c6680737c28386865 to your computer and use it in GitHub Desktop.
vimlparser diff
--- vim-jp/vim-vimlparser/autoload/vimlparser.vim 2017-07-19 15:49:59.859034000 +0000
+++ haya14busa/go-vimlparser/autoload/vimlparser.vim 2017-07-19 16:09:22.166189982 +0000
@@ -137,6 +137,7 @@
let s:NODE_CURLYNAMEPART = 90
let s:NODE_CURLYNAMEEXPR = 91
let s:NODE_LAMBDA = 92
+let s:NODE_PARENEXPR = 93
let s:TOKEN_EOF = 1
let s:TOKEN_EOL = 2
@@ -403,6 +404,7 @@
" CURLYNAMEPART .value
" CURLYNAMEEXPR .value
" LAMBDA .rlist .left
+" PARENEXPR .value
function! s:Node(type)
return {'type': a:type}
endfunction
@@ -939,7 +941,7 @@
endif
endfor
- if self.neovim
+ if self.neovim
for x in self.neovim_additional_commands
if stridx(x.name, name) == 0 && len(name) >= x.minlen
unlet cmd
@@ -956,7 +958,7 @@
endif
endfor
endif
-
+
" FIXME: user defined command
if (cmd is s:NIL || cmd.name ==# 'Print') && name =~# '^[A-Z]'
let name .= self.reader.read_alnum()
@@ -3517,7 +3519,9 @@
endwhile
return node
elseif token.type == s:TOKEN_POPEN
- let node = self.parse_expr1()
+ let node = s:Node(s:NODE_PARENEXPR)
+ let node.pos = token.pos
+ let node.value = self.parse_expr1()
let token = self.tokenizer.get()
if token.type != s:TOKEN_PCLOSE
throw s:Err(printf('unexpected token: %s', token.value), token.pos)
@@ -4213,6 +4217,8 @@
return self.compile_curlynameexpr(a:node)
elseif a:node.type == s:NODE_LAMBDA
return self.compile_lambda(a:node)
+ elseif a:node.type == s:NODE_PARENEXPR
+ return self.compile_parenexpr(a:node)
else
throw printf('Compiler: unknown node: %s', string(a:node))
endif
@@ -4296,7 +4302,7 @@
if a:node.depth is s:NIL
call self.out('(lockvar %s)', join(list, ' '))
else
- call self.out('(lockvar %s %s)', a:node.depth, join(list, ' '))
+ call self.out('(lockvar %d %s)', a:node.depth, join(list, ' '))
endif
endfunction
@@ -4305,7 +4311,7 @@
if a:node.depth is s:NIL
call self.out('(unlockvar %s)', join(list, ' '))
else
- call self.out('(unlockvar %s %s)', a:node.depth, join(list, ' '))
+ call self.out('(unlockvar %d %s)', a:node.depth, join(list, ' '))
endif
endfunction
@@ -4676,6 +4682,10 @@
return printf('(lambda (%s) %s)', join(rlist, ' '), self.compile(a:node.left))
endfunction
+function! s:Compiler.compile_parenexpr(node)
+ return self.compile(a:node.value)
+endfunction
+
" TODO: under construction
let s:RegexpParser = {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment