-
Notifications
You must be signed in to change notification settings - Fork 58
The Gordian Knot #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Gordian Knot #277
Conversation
scala> trait A
// defined trait A
scala> foo(new A:
| def x = 1)
val res0: A = anon$1@50df37eb so at least in this case, the closing parenthesis works as an outdent, so maybe we should support that in a situation where the parser is looking for an outdent. |
Here's my PR for the outdent - #279 |
😮 |
fa01307
to
fb9fd67
Compare
@eed3si9n Thank you for the fix of outdents! It helped to solve remaining issues in this PR, it's ready for review
|
fb9fd67
to
a889c3c
Compare
Summary ------- `$.lambda_expression` body was changed from `$._block` to `$._indentable_expression`. This had the following effects: * x10 faster parser generation * parser size reduced from 41M to 24M * conflict with `$.self_type`, which was resolved by matching indent-tokens in `$.template_body`. This change, in its turn required scanner.c to stop emitting INDENT and OUTDENT tokens when encountering comments
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.
Thanks @susliko!
Really great job on this @susliko! |
A startling discovery
changing
$.lambda_expression
body from$._block
to$._indentable_expression
results inHowever, it brings the following problems:
Problem1: conflict of
$.lambda_expression
and$.self_type
Self-type in
is parsed as lambda expression. Seems to be not much of a problem, as it can be resolved by disabling
$.lambda_expression
in$.templabe_body
(that's also how it's in the ebnf)Problem2: multi-line lambdas without newline before closing paren
fails to be parsed, for
$._indent
token is emmitted and$._outdent
is not.is, on contrary, parsed correctly because of the newline before the closing paren.
For this issue - I can't come up with a solution and will be glad of any ideas