Skip to content

Commit

Permalink
merge parse_constlhs() to parse_letlhs()
Browse files Browse the repository at this point in the history
  • Loading branch information
tyru committed Aug 2, 2019
1 parent e4f8e05 commit a74f173
Showing 1 changed file with 6 additions and 39 deletions.
45 changes: 6 additions & 39 deletions autoload/vimlparser.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ function! s:VimLParser.parse_cmd_let() abort
return
endif

let lhs = self.parse_letlhs()
let lhs = self.parse_letlhs(s:FALSE)
call self.reader.skip_white()
let s1 = self.reader.peekn(1)
let s2 = self.reader.peekn(2)
Expand Down Expand Up @@ -1567,7 +1567,7 @@ function! s:VimLParser.parse_cmd_const() abort
return
endif

let lhs = self.parse_constlhs()
let lhs = self.parse_letlhs(s:TRUE)
call self.reader.skip_white()
let s1 = self.reader.peekn(1)

Expand Down Expand Up @@ -1721,7 +1721,7 @@ function! s:VimLParser.parse_cmd_for() abort
let node.left = s:NIL
let node.right = s:NIL
let node.endfor = s:NIL
let lhs = self.parse_letlhs()
let lhs = self.parse_letlhs(s:FALSE)
let node.left = lhs.left
let node.list = lhs.list
let node.rest = lhs.rest
Expand Down Expand Up @@ -1930,7 +1930,6 @@ function! s:VimLParser.parse_lvalue() abort
throw s:Err('Invalid Expression', node.pos)
endfunction

" TODO: merge with s:VimLParser.parse_lvalue()
function! s:VimLParser.parse_constlvalue() abort
let p = s:LvalueParser.new(self.reader)
let node = p.parse()
Expand Down Expand Up @@ -1970,7 +1969,7 @@ function! s:VimLParser.parse_lvaluelist() abort
endfunction

" FIXME:
function! s:VimLParser.parse_letlhs() abort
function! s:VimLParser.parse_letlhs(is_const) abort
let lhs = {'left': s:NIL, 'list': s:NIL, 'rest': s:NIL}
let tokenizer = s:ExprTokenizer.new(self.reader)
if tokenizer.peek().type ==# s:TOKEN_SQOPEN
Expand All @@ -1997,46 +1996,14 @@ function! s:VimLParser.parse_letlhs() abort
throw s:Err(printf('E475 Invalid argument: %s', token.value), token.pos)
endif
endwhile
elseif a:is_const
let lhs.left = self.parse_constlvalue()
else
let lhs.left = self.parse_lvalue()
endif
return lhs
endfunction

" TODO: merge with s:VimLParser.parse_letlhs() ?
function! s:VimLParser.parse_constlhs() abort
let lhs = {'left': s:NIL, 'list': s:NIL, 'rest': s:NIL}
let tokenizer = s:ExprTokenizer.new(self.reader)
if tokenizer.peek().type ==# s:TOKEN_SQOPEN
call tokenizer.get()
let lhs.list = []
while s:TRUE
let node = self.parse_lvalue()
call add(lhs.list, node)
let token = tokenizer.get()
if token.type ==# s:TOKEN_SQCLOSE
break
elseif token.type ==# s:TOKEN_COMMA
continue
elseif token.type ==# s:TOKEN_SEMICOLON
let node = self.parse_lvalue()
let lhs.rest = node
let token = tokenizer.get()
if token.type ==# s:TOKEN_SQCLOSE
break
else
throw s:Err(printf('E475 Invalid argument: %s', token.value), token.pos)
endif
else
throw s:Err(printf('E475 Invalid argument: %s', token.value), token.pos)
endif
endwhile
else
let lhs.left = self.parse_constlvalue()
endif
return lhs
endfunction

function! s:VimLParser.ends_excmds(c) abort
return a:c ==# '' || a:c ==# '|' || a:c ==# '"' || a:c ==# '<EOF>' || a:c ==# '<EOL>'
endfunction
Expand Down

0 comments on commit a74f173

Please sign in to comment.