-
Notifications
You must be signed in to change notification settings - Fork 55
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
Top-level expressions cannot be parsed #198
Comments
I think given scala script files with scala-cli are now SIP approved, this is certainly more critical |
I took a look at the test suite errors arising from including class Foo() {} is parsed as
(Now @eed3si9n fyi |
Summary ------- `$.compilation_unit` is now a sequence of top-level stats separated by `$.semicolon` This change has two effects: - Grammar optimization: - ~10% faster generation time - lower number of parser states ([before](https://gist.github.com/susliko/f950b997a98c54bbfd88969a949346fd), [after](https://gist.github.com/susliko/236a85dce46219c5868c494d7f5cf629)) - parser size reduction from 43M to 36M - It seems to me, that handling `$._automatic_semicolon` on the top level is a prerequisite to support top-level expressions (tree-sitter#198) and leading infix operators (tree-sitter#141)
Summary ------- `$.compilation_unit` is now a sequence of top-level stats separated by `$.semicolon` This change has two effects: - Grammar optimization: - ~10% faster generation time - lower number of parser states ([before](https://gist.github.com/susliko/f950b997a98c54bbfd88969a949346fd), [after](https://gist.github.com/susliko/236a85dce46219c5868c494d7f5cf629)) - parser size reduction from 43M to 36M - It seems to me, that handling `$._automatic_semicolon` on the top level is a prerequisite to support top-level expressions (tree-sitter#198) and leading infix operators (tree-sitter#141)
Commit of tree-sitter-scala you tested this on
HEAD
A code sample showing the error
test-plugins.sbt
Show the error node
Run with
npm exec -- tree-sitter parse test-plugins.sbt
What do you expect the tree to look like
Correctly parsed
Where are you experiencing this error?
No response
Notes
This is technically not valid Scala, you can't have top level expressions:
But it's valid in the context of SBT.
@olafurpg patched it in Sourcegraph's fork, but that breaks most tests: sourcegraph@6cd3cb6 so we will likely need to rejig other parts of the grammar.
The question of whether we allow it unconditionally is open, but for the purposes of syntax highlighting IMO we should.
The text was updated successfully, but these errors were encountered: