Skip to content

Commit be48e0b

Browse files
committed
variable name ":", "#" (disabled)
1 parent 74caeed commit be48e0b

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

autoload/vimlparser.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ let s:TOKEN_OR = 60
191191
let s:TOKEN_SEMICOLON = 61
192192
let s:TOKEN_BACKTICK = 62
193193
let s:TOKEN_DOTDOTDOT = 63
194+
let s:TOKEN_SHARP = 64
194195

195196
let s:MAX_FUNC_ARGS = 20
196197

@@ -2486,6 +2487,9 @@ function! s:ExprTokenizer.get2()
24862487
elseif c ==# ':'
24872488
call r.seek_cur(1)
24882489
return self.token(s:TOKEN_COLON, ':', pos)
2490+
elseif c ==# '#'
2491+
call r.seek_cur(1)
2492+
return self.token(s:TOKEN_SHARP, '#', pos)
24892493
elseif c ==# '('
24902494
call r.seek_cur(1)
24912495
return self.token(s:TOKEN_POPEN, '(', pos)
@@ -3187,6 +3191,10 @@ function! s:ExprParser.parse_expr9()
31873191
elseif token.type == s:TOKEN_IDENTIFIER
31883192
call self.reader.seek_set(pos)
31893193
let node = self.parse_identifier()
3194+
elseif 0 && (token.type == s:TOKEN_COLON || token.type == s:TOKEN_SHARP)
3195+
" XXX: no parse error but invalid expression
3196+
call self.reader.seek_set(pos)
3197+
let node = self.parse_identifier()
31903198
elseif token.type == s:TOKEN_LT && self.reader.peekn(4) ==? 'SID>'
31913199
call self.reader.seek_set(pos)
31923200
let node = self.parse_identifier()

test/test_xxx_colonsharp.ok

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; XXX: no parse error but invalid expression
2+
(echo :)
3+
(echo #)
4+
(echo ::)
5+
(echo ##)
6+
(echo :#:#)
7+
(echo #:#:)
8+
(echo :foo)
9+
(echo #bar)
10+
(echo x:y:z)
11+
(echo x:y:1)
12+
(echo x:1:y)
13+
(echo 1 :x:y)
14+
(echo (slice x nil :))
15+
(echo (slice x nil :y))
16+
(echo (subscript x y:))
17+
(echo (subscript x y:z))
18+
(echo (subscript x #:#))
19+
(echo (subscript x y:#))
20+
(echo (dict ("x" :)))
21+
; NOTE: vim stop parse at first colon because ":" is undefined variable
22+
(echo (dict (: :)))
23+
; NOTE: curly name
24+
(echo {:})
25+
(echo {::})
26+
(echo {x:y})
27+
(echo (?: 0 1 :))
28+
(echo (?: 0 : 1))

test/test_xxx_colonsharp.vim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
" XXX: no parse error but invalid expression
2+
echo :
3+
echo #
4+
echo ::
5+
echo ##
6+
echo :#:#
7+
echo #:#:
8+
echo :foo
9+
echo #bar
10+
echo x:y:z
11+
echo x:y:1
12+
echo x:1:y
13+
echo 1:x:y
14+
echo x[::]
15+
echo x[::y]
16+
echo x[y:]
17+
echo x[y:z]
18+
echo x[#:#]
19+
echo x[y:#]
20+
echo {"x"::}
21+
" NOTE: vim stop parse at first colon because ":" is undefined variable
22+
echo {: : :}
23+
" NOTE: curly name
24+
echo {:}
25+
echo {::}
26+
echo {x:y}
27+
echo (0 ? 1 : :)
28+
echo (0 ? : : 1)

0 commit comments

Comments
 (0)