tree-sitter-viml
tree-sitter-viml copied to clipboard
Add method call expression support
call F()->G()
seems to generate an error node.
call F()->G()
seems to generate an error node.
From what I understand of :h E132
this is not a supported syntax.
eval F()->G()
Seems to be parsed properly
contrived example of valid vimscipt.
func Hello()
return 'hello'
endfunc
func Print(arg)
echo a:arg
endfunc
call Hello()->Print()
Hmm
I understand why it works but I don't know how we are supposed to handle it.
In the manual, a call statement is call {name}([arguments])
, so the ([args])
is part of the statement.
For method calls, ([args])
seems to also be part of the method_call expression.
We could allow both call_expression
and method_expression
in a call_statement
@vigoux what do you think ?
@ad-chaos This should work properly now, I will just for vigoux to validate
With this PR we are 1 step closer to parse the vim runtime. This code is parsed without error now
func s:DecodeMessage(quotedText)
if a:quotedText[0] != '"'
echoerr 'DecodeMessage(): missing quote in ' . a:quotedText
return
endif
return a:quotedText
\ ->substitute('^"\|".*\|\\n', '', 'g')
\ ->substitute('\\t', "\t", 'g')
\ ->substitute('\\000', s:NullRepl, 'g')
\ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g')
\ ->substitute('\\\\', '\', 'g')
\ ->substitute(s:NullRepl, '\\000', 'g')
endfunc
But adding a comment between the method call lines breaks.
func s:DecodeMessage(quotedText)
return a:quotedText
\ ->substitute('^"\|".*\|\\n', '', 'g')
" this is a comment
\ ->substitute('\\t', "\t", 'g')
endfunc