- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 22
Add method call expression support #125
base: master
Are you sure you want to change the base?
Conversation
ecc2792
to
c174b20
Compare
@@ -103,6 +103,7 @@ module.exports = grammar({ | |||
[$.binary_operation, $.unary_operation, $.field_expression], | |||
[$.binary_operation, $.field_expression], | |||
[$.list, $._pattern_atom], | |||
[$._ident, $.lambda_expression], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this 'eeded now and was not needed before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, I get a conflict
Unresolved conflict for symbol sequence:
_function '{' identifier • '->' …
Possible interpretations:
1: _function '{' (_ident identifier) • '->' …
2: _function (lambda_expression '{' identifier • '->' _expression '}')
I don't exactly know where a '{' identifier '->'
is allowed elsewhere than in lambda, but it doesn't know if it should consider the identifier as part of lambda expression or the name
of the method expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it might be because of the braces expansions then.
There must be another place where this kind of conflict is handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need double braces in a brace expansion if we use a lambda within it
let Function_name = {-> 'hello'}
echo Function_{{-> 'name'}()}()
also an identifier needs to immediately follow a ->
for it to be considered part of the method call. :h E274
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found where the conflict was coming from and why we didn't get it before.
By adding method_expression
, we allowed the syntax
'{' _ident -> ... '}'
twice for an expression. One in lamda_expression
and the other as a single curly_brace expression identifier
_ident (identifier (_curly_brace_name_expression '{' (method_expression _ident '->' _expression '}' ))
782fffe
to
3a63629
Compare
Allow only lambda and identifier in method
3a63629
to
bdc3772
Compare
|
From what I understand of 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() |
81a1ae8
to
485a500
Compare
485a500
to
0bd25f8
Compare
Hmm We could allow both |
@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. 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 |
No description provided.