diff --git a/.travis.yml b/.travis.yml index a4828240..e2bf9cb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,18 +5,6 @@ git: matrix: include: - - env: - - VIM_VERSION=v7.4 - - MAKE_TARGET=test - - TEST_PROFILE=vim-profile-v7.4.txt - - env: - - VIM_VERSION=v8.0.0000 - - MAKE_TARGET=test - - TEST_PROFILE=vim-profile-v8.0.txt - - env: - - VIM_VERSION=master - - MAKE_TARGET=test - - TEST_PROFILE=vim-profile-master.txt - env: - VIM_VERSION=installed - MAKE_TARGET="clean_compiled check js/test py/test test/node_position/test_position.out" @@ -34,7 +22,7 @@ script: - uname -a - which -a vim - vim --cmd version --cmd quit - - make $MAKE_TARGET + - make --keep-going $MAKE_TARGET after_success: - covimerage write_coverage $TEST_PROFILE diff --git a/autoload/vimlparser.vim b/autoload/vimlparser.vim index 4b897ef7..55a316c9 100644 --- a/autoload/vimlparser.vim +++ b/autoload/vimlparser.vim @@ -239,7 +239,7 @@ function! s:iswhite(c) endfunction function! s:isnamec(c) - return a:c =~# '^[0-9A-Za-z_:#]$' + return a:c =~# '^[0-9A-Za-z_#]$' endfunction function! s:isnamec1(c) @@ -3570,7 +3570,8 @@ function! s:ExprParser.parse_dot(token, left) endif let pos = self.reader.getpos() let name = self.reader.read_word() - if s:isnamec(self.reader.p(0)) + let c = self.reader.p(0) + if c ==# ':' || c ==# '#' " XXX: foo is str => ok, foo is obj => invalid expression " foo.s:bar or foo.bar#baz return s:NIL @@ -3979,7 +3980,18 @@ function! s:StringReader.read_nonwhite() endfunction function! s:StringReader.read_name() - let r = '' + " We come here for valid names only. + let r = self.getn(1) + + " Colon only allowed at 2nd position, with scope identifiers. + let c = self.peekn(1) + if c ==# ':' + if r !~# '[vgslabwt]' + return r + endif + let r .= self.getn(1) + endif + while s:isnamec(self.peekn(1)) let r .= self.getn(1) endwhile diff --git a/js/vimlfunc.js b/js/vimlfunc.js index b4dbd260..a1ad4af3 100644 --- a/js/vimlfunc.js +++ b/js/vimlfunc.js @@ -78,11 +78,12 @@ var pat_vim2js = { "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$", "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$", "^[A-Za-z_]$" : "^[A-Za-z_]$", - "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$", + "^[0-9A-Za-z_#]$" : "^[0-9A-Za-z_#]$", "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$", "^[A-Z]$" : "^[A-Z]$", "^[a-z]$" : "^[a-z]$", "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$", + "[vgslabwt]" : "[vgslabwt]", "^[0-7]$" : "^[0-7]$", } diff --git a/js/vimlparser.js b/js/vimlparser.js index 236abe61..33f78b26 100644 --- a/js/vimlparser.js +++ b/js/vimlparser.js @@ -78,11 +78,12 @@ var pat_vim2js = { "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$", "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$", "^[A-Za-z_]$" : "^[A-Za-z_]$", - "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$", + "^[0-9A-Za-z_#]$" : "^[0-9A-Za-z_#]$", "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$", "^[A-Z]$" : "^[A-Z]$", "^[a-z]$" : "^[a-z]$", "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$", + "[vgslabwt]" : "[vgslabwt]", "^[0-7]$" : "^[0-7]$", } @@ -426,7 +427,7 @@ function iswhite(c) { } function isnamec(c) { - return viml_eqregh(c, "^[0-9A-Za-z_:#]$"); + return viml_eqregh(c, "^[0-9A-Za-z_#]$"); } function isnamec1(c) { @@ -3455,7 +3456,8 @@ ExprParser.prototype.parse_dot = function(token, left) { } var pos = this.reader.getpos(); var name = this.reader.read_word(); - if (isnamec(this.reader.p(0))) { + var c = this.reader.p(0); + if (c == ":" || c == "#") { // XXX: foo is str => ok, foo is obj => invalid expression // foo.s:bar or foo.bar#baz return NIL; @@ -3883,7 +3885,16 @@ StringReader.prototype.read_nonwhite = function() { } StringReader.prototype.read_name = function() { - var r = ""; + // We come here for valid names only. + var r = this.getn(1); + // Colon only allowed at 2nd position, with scope identifiers. + var c = this.peekn(1); + if (c == ":") { + if (!viml_eqregh(r, "[vgslabwt]")) { + return r; + } + r += this.getn(1); + } while (isnamec(this.peekn(1))) { r += this.getn(1); } diff --git a/py/vimlfunc.py b/py/vimlfunc.py index 8cc75216..e0f42efb 100644 --- a/py/vimlfunc.py +++ b/py/vimlfunc.py @@ -74,11 +74,12 @@ class AttributeDict(dict): "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$", "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$", "^[A-Za-z_]$" : "^[A-Za-z_]$", - "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$", + "^[0-9A-Za-z_#]$" : "^[0-9A-Za-z_#]$", "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$", "^[A-Z]$" : "^[A-Z]$", "^[a-z]$" : "^[a-z]$", "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$", + "[vgslabwt]" : "[vgslabwt]", "^[0-7]$" : "^[0-7]$", } diff --git a/py/vimlparser.py b/py/vimlparser.py index 760cdc50..29816b72 100644 --- a/py/vimlparser.py +++ b/py/vimlparser.py @@ -74,11 +74,12 @@ class AttributeDict(dict): "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$", "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$", "^[A-Za-z_]$" : "^[A-Za-z_]$", - "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$", + "^[0-9A-Za-z_#]$" : "^[0-9A-Za-z_#]$", "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$", "^[A-Z]$" : "^[A-Z]$", "^[a-z]$" : "^[a-z]$", "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$", + "[vgslabwt]" : "[vgslabwt]", "^[0-7]$" : "^[0-7]$", } @@ -372,7 +373,7 @@ def iswhite(c): return viml_eqregh(c, "^[ \\t]$") def isnamec(c): - return viml_eqregh(c, "^[0-9A-Za-z_:#]$") + return viml_eqregh(c, "^[0-9A-Za-z_#]$") def isnamec1(c): return viml_eqregh(c, "^[A-Za-z_]$") @@ -2752,7 +2753,8 @@ def parse_dot(self, token, left): return NIL pos = self.reader.getpos() name = self.reader.read_word() - if isnamec(self.reader.p(0)): + c = self.reader.p(0) + if c == ":" or c == "#": # XXX: foo is str => ok, foo is obj => invalid expression # foo.s:bar or foo.bar#baz return NIL @@ -3085,7 +3087,14 @@ def read_nonwhite(self): return r def read_name(self): - r = "" + # We come here for valid names only. + r = self.getn(1) + # Colon only allowed at 2nd position, with scope identifiers. + c = self.peekn(1) + if c == ":": + if not viml_eqregh(r, "[vgslabwt]"): + return r + r += self.getn(1) while isnamec(self.peekn(1)): r += self.getn(1) return r diff --git a/test/test_slice_var.ok b/test/test_slice_var.ok new file mode 100644 index 00000000..61176042 --- /dev/null +++ b/test/test_slice_var.ok @@ -0,0 +1,5 @@ +(let = s '123') +(let = a 1) +(let = b (- 1)) +(echo (slice s a b)) +(echo (slice s a b)) diff --git a/test/test_slice_var.vim b/test/test_slice_var.vim new file mode 100644 index 00000000..774cc101 --- /dev/null +++ b/test/test_slice_var.vim @@ -0,0 +1,5 @@ +let s = '123' +let a = 1 +let b = -1 +echo s[a : b] +echo s[a:b]