Commit Graph

514 Commits (70b4fe63c4973b04cc7bd40c6b7646d9c2430db8)
 

Author SHA1 Message Date
Eugene Yokota 2d2e89f92c Repeat pattern
Problem
-------
1. Repeat pattern with `*` doesn't parse.
2. Capture pattern `@` doesn't capture wildcard.

Solution
--------
1. This implements support for `*` in pattern.
2. This also allows using `_@`.
2023-06-06 02:57:38 +07:00
Chris Kipp c09c917c28
Merge pull request #280 from eed3si9n/wip/cargo
Fix typo in Cargo.toml
2023-06-06 08:41:15 +07:00
Eugene Yokota 55126bbadd Fix typo in Cargo.toml
Problem/Solution
----------------
This fixes a typo in Cargo.toml.
2023-06-06 01:53:29 +07:00
Eugene Yokota fc8ac917ab 82% on Dotty 2023-06-06 01:26:06 +07:00
Eugene Yokota 38137ff97f Allow closing paren/bracket to outdent
Problem
-------
Braceless syntax can terminate with closing paren or bracket
of the outer context, but we don't support that.

Solution
--------
This changes the scanner so when an outdent is expected,
closing paren or bracket can inject an outdent.
2023-06-06 00:57:55 +07:00
eugene yokota 236c7b20db
Merge pull request #274 from tree-sitter/generation
chore: generate and sync latest changes
2023-06-01 12:56:27 +07:00
GitHub 141174ac05 chore: generate and sync from 9d71af4641 2023-06-01 05:09:06 +07:00
eugene yokota 9d71af4641
Merge pull request #273 from susliko/using-directive
Support Scala CLI using directives
2023-05-31 22:34:38 +07:00
susliko 5da643806c Support Scala CLI using directives
Summary
-------
Single line `$.comment` is split into a choice of `$._comment_text` and
`$.using_directive` to parse a structure of comments like
```
//> using scala 3.3.0
```
2023-05-31 23:04:52 +07:00
Kasper Kondzielski 2a837f80f3
Enable parser on sbt files (#210) 2023-05-31 14:07:58 +07:00
eugene yokota e7f7d01630
Merge pull request #272 from tree-sitter/generation 2023-05-31 01:51:11 +07:00
GitHub 066863b5c5 chore: generate and sync from 305504c509 2023-05-31 05:07:01 +07:00
eugene yokota 305504c509
Merge pull request #237 from susliko/soft-keyword-identifiers
Allow soft keywords as identifiers
2023-05-30 22:23:43 +07:00
susliko 09b54b93f8 Document relative precedences 2023-05-31 00:53:05 +07:00
susliko 64dff7f7f1 Smoke test accuracy for scala compiler is 87 now 2023-05-30 23:39:38 +07:00
susliko 4da42f4e71 Allow soft keywords as identifiers
Problem
-------
Soft keywords ('open', 'end', 'infix', etc.) are not allowed to be used
as identifiers, e.g. in
```
open()
```
Solution
-------
Introduce `$._soft_identifier` with a lower precedence than modifiers
2023-05-30 23:25:52 +07:00
eugene yokota 4684dd84a9
Merge pull request #271 from susliko/top-level-expressions
Top-level expressions
2023-05-30 11:09:18 +07:00
susliko 03d1848437 Top-level expressions
Problem
-------
Top-level expressions are not supported. However, it's a valid case for
Scala scripts or sbt configurations

Solution
-------
Now that AUTOMATIC_SEMICOLON tokens are handled at the top-level
enabling top-level expressions is done by including `$.expression` into
`$._top_level_definition`
2023-05-30 12:29:35 +07:00
Chris Kipp fad8ec3fca
Merge pull request #269 from susliko/refactor-compilation-unit
Refactor `$.compilation_unit`, optimize grammar
2023-05-30 08:43:07 +07:00
eugene yokota dacd7bdbe2
Merge pull request #270 from tree-sitter/generation 2023-05-30 01:22:27 +07:00
GitHub 9a6d34fe15 chore: generate and sync from 4e59461b19 2023-05-30 05:07:41 +07:00
susliko 4b2cbc2e7c Refactor `$.compilation_unit`, optimize grammar
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 (https://github.com/tree-sitter/tree-sitter-scala/issues/198) and leading infix operators (https://github.com/tree-sitter/tree-sitter-scala/issues/141)
2023-05-30 01:22:14 +07:00
eugene yokota 4e59461b19
Merge pull request #266 from eed3si9n/wip/refinement 2023-05-29 17:31:12 +07:00
eugene yokota 798ec78940
Merge pull request #268 from tree-sitter/generation
chore: generate and sync latest changes
2023-05-29 01:35:16 +07:00
eugene yokota 4b7736c6e3
Merge branch 'master' into wip/refinement 2023-05-29 01:34:08 +07:00
GitHub 856e122af6 chore: generate and sync from 58e25588ae 2023-05-29 05:06:13 +07:00
eugene yokota 551e4eac07
Merge pull request #267 from eed3si9n/wip/smoke_dotty
Use Scala 3.3.0 for smoke test
2023-05-29 01:04:30 +07:00
Eugene Yokota 9725cac29a Use Scala 3.3.0 for smoke test 2023-05-29 00:55:03 +07:00
Eugene Yokota 4801dc8a44 Refinement
Problem
-------
Compound type with refinement (structural type with a parent)
doesn't parse.

Solution
--------
This adds support for it.
It collides with context bounds `A: B: C`, so the precedence is set to
-1.
2023-05-29 00:16:55 +07:00
eugene yokota 58e25588ae
Merge pull request #250 from susliko/self-type-in-braceless-traits
Self-types in braceless trait definitions
2023-05-28 22:10:58 +07:00
susliko 42bab6dc9c Self-types in braceless trait definitions
Problem
-------
Self-types are not parsed in braceless trait definitions:
```scala
trait A:
  this: B =>
````

Solution
-------
Move existing `$.self_type` rule in trait definition into indented scope.
Rebalance `$.self_type` precedence.
Without explicit precedence it looses to `$.call_expression` in
```scala
trait A {
  self: B =>
  def f = ""
}
```
With static precedence instead of dynamic it leads to errors in
definitions like:
```scala
class A
  x: Int // this should be $.ascription_expression
enum B:
  case C
```
2023-05-28 17:43:10 +07:00
Chris Kipp 374709c76a
Merge pull request #255 from tree-sitter/generation
chore: generate and sync latest changes
2023-05-28 10:05:27 +07:00
Chris Kipp bc1a02d9e2
Merge pull request #254 from eed3si9n/wip/identifiers
val defn with ids
2023-05-28 10:04:46 +07:00
GitHub 1053e6d626 chore: generate and sync from 4072a37b9c 2023-05-28 05:06:43 +07:00
Eugene Yokota 3fbdb85522 Scala 2 library now 95% 2023-05-27 21:48:39 +07:00
Eugene Yokota ec70a4503a val defn with ids
Problem
-------
`val` definitions with multiple identifiers are not supported.

Solution
--------
This implements `identifiers`, which acts like a pattern.
2023-05-27 21:27:28 +07:00
eugene yokota 4072a37b9c
Merge pull request #248 from susliko/annotations-on-enums
Annotations on enums
2023-05-27 21:00:15 +07:00
susliko 63493b2f45 Annotations on enums
Problem
-------
Annotations on Scala 3 enums and their cases are not supported, e.g.
```scala
@A enum E:
  @A("") @B case A

```

Solution
-------
Allow annotations in enum definitions
2023-05-28 02:44:45 +07:00
eugene yokota 8ba8016ae5
Merge pull request #251 from susliko/nested-multiline-comments
Nested block comments
2023-05-27 19:29:16 +07:00
susliko 8f1f347918 Add test case for `**` operator identifier 2023-05-28 01:33:46 +07:00
susliko 8686eb3e27 Bump smoke test accuracy for dotty codebase to 81% 2023-05-28 01:17:59 +07:00
susliko 693c651b50 Nested block comments
Problem
-------
Nested block comments are not parsed, e.g.
```
/* /* */ */
```

Solution
-------
Leave $.comment for single-line comments.
Introduce $.block_comment for block-comments.
Make $.block_comment out of several tokens to be able to detect nested
block comments
2023-05-28 01:16:58 +07:00
eugene yokota 5a6fcbdddd
Merge pull request #249 from susliko/class-lazy-params
By-name class parameters
2023-05-27 18:15:30 +07:00
eugene yokota af23f2f68c
Merge pull request #252 from eed3si9n/wip/94
94% for Scala 2 library
2023-05-27 18:14:48 +07:00
Eugene Yokota 33e0c02eef 94% for Scala 2 library 2023-05-27 17:56:34 +07:00
eugene yokota ef0d77e20b
Merge pull request #247 from susliko/correct-type-bounds
Correct type bounds
2023-05-27 17:52:45 +07:00
susliko 2a1c3c9faf By-name class parameters
Problem
-------
By-name parameters in class definitions were not supported:
```
class A(a: => B)
```

Solution
-------
Support by-name parameters by changing the rule describing class
parameter type from `$._type` to `$._param_type`
2023-05-27 23:03:03 +07:00
susliko 4069d72047 Correct type bounds
Problem
-------
The grammar assumes upper type bound to go before lower type bound.
Although, in Scala it's the opposite:
```
TypeBounds ::= [‘>:’ Type] [‘<:’ Type]
```

Solution
-------
Swap type bounds' order in the grammar
2023-05-27 22:30:53 +07:00
susliko 7a89ab1546 Format corpus/types.txt with `tree-sitter test -u` 2023-05-27 22:28:56 +07:00
eugene yokota 17a19b0f05
Merge pull request #244 from eed3si9n/wip/match_type
Match type
2023-05-27 04:12:22 +07:00