Commit Graph

179 Commits (d3eb6b2382f3051cca164f4cc41cdb5bf0876e10)

Author SHA1 Message Date
Eugene Yokota 91529e9157 Exclude colon, at, and equal from single opchar
**Problem**
Currently operator_identifier includes characters
like colon at and equal even though they cannot be a legal
operator without backticks.
Having equal etc pushes tree-sitter into thinking some
construct to be an infix operation when they are `=`.

Another compilication is Unicode Math symbols,
which includes equal sign.

**Solution**
Remove colon, at, equal sign, and Math symbols from the
single-char operator_identifier.
This adds back back a few Math symbol unicodes.
2024-04-14 14:08:25 +07:00
GitHub 2914b02236 chore: generate and sync from 71ee31cd21 2024-03-12 05:04:15 +07:00
eugene yokota 3007ed523e
Fix character literal (#383)
Previously the character literal was updated
mimicking that of Rust apparently,
but Scala doesn't have curly braces in the character literal.

We do, however, support two 'u' characters.
2024-03-11 07:14:34 +07:00
Vasili Markoukin f8a4c1399f Allow $.function_declaration as extension body
Fixes #374
2024-02-11 12:43:02 +07:00
GitHub 6d84c41373 chore: generate and sync from 0c63ada18d 2024-01-19 05:03:38 +07:00
Vasil Markoukin a95d787eee Allow for abstract givens
Fixes #336
2024-01-17 23:58:14 +07:00
GitHub f59a8bb04c chore: generate and sync from 2b79741be7 2023-12-27 05:03:42 +07:00
susliko 6c99c83424 Allow infix inline modifier
Fixes #366

Rebalance precedences of `match_expression` (which can contain "inline") and `modifiers`
2023-12-27 00:22:18 +07:00
GitHub 3894c16a64 chore: generate and sync from 1d3a1f9f18 2023-09-24 05:03:56 +07:00
antosha417 526d3b148c
Support shebang.
Fixes #351
2023-09-23 17:52:21 +07:00
GitHub 2b2b82838a chore: generate and sync from 8f070fe470 2023-09-20 05:03:50 +07:00
susliko fed5476126 Allow semicolons before 'else'
Fixes #299

Add optional semicolon in alternative branch of `if_expression` and remove right precedence of `if_expression`
2023-09-20 00:16:32 +07:00
susliko cd5d3a248f Allow semicolons as only content of blocks
Fixes #300
2023-09-19 23:07:15 +07:00
eugene yokota 27a40cf3cd
Merge pull request #352 from susliko/next-line-derives
Fix `derives` clause on a new line
2023-09-19 01:12:04 +07:00
eugene yokota 5fa09e9838
Merge pull request #353 from susliko/trait-derives
Derives clause for traits
2023-09-19 01:11:40 +07:00
GitHub ef639d4f35 chore: generate and sync from 045ce59575 2023-09-19 05:03:49 +07:00
eugene yokota ee2e9ab164
Merge branch 'master' into next-line-derives 2023-09-18 23:14:57 +07:00
eugene yokota c13de90a34
Merge branch 'master' into fix-parenthesized-expr-in-braceless-if 2023-09-18 23:08:48 +07:00
susliko 28666b1581 Wildcards in tuple bindings
Fixes #303
Now binding is a choice from identifier and wildcard
2023-09-18 23:18:57 +07:00
susliko 3054b9b596 Derives clause for traits
Fixes #348
`trait_definition` now includes `_class_definition` which is comprised
of extends-clause, derives-clause, and body. This also slightly reduces
parser size (from ~890Kb to ~780Kb)
2023-09-18 22:44:40 +07:00
susliko 276429290b Fix `derives` clause on a new line
Fixes #349

Now `automatic_semicolon` is not emmited when newline is followed by "derives"
2023-09-18 22:29:59 +07:00
susliko f8d3848919 Fix parenthesized expressions in braceless `if` conditions
Fixes #263 and #342
`_if_condition` extracted from `if_expression` and given a magic dynamic
precedence of 4
2023-09-18 21:48:31 +07:00
Eugene Yokota d72cdd4032 Fixes anonymous givens
Problem
-------
Currently given uses `_function_constructor`, which expects an
identifier.
This doesn't work for anonymous given definition that has function-ish
things like `using` parameters.

Solution
--------
Create a new `_given_constructor` node with an optional name.
2023-08-27 14:47:43 +07:00
Max Smirnov 2d6795cb79
Use indentable_expression in given def 2023-08-16 07:00:13 +07:00
Chris Kipp f086fb0c9c
Merge pull request #333 from susliko/newline-before-return-type
Allow return types on new lines in definitions
2023-08-09 08:28:24 +07:00
GitHub 991180ff2d chore: generate and sync from 46e08442cd 2023-08-09 05:03:48 +07:00
susliko ce7e098a0b Allow return types on new lines in definitions
Resolves #318

Summary
----
Optional trailing `$._automatic_semicolon` in `$._function_cunstructor`.
This enables correct parsing of the code like:
```scala
def foo()
  : Int = 42
given foo(using foo: Foo)
  : Foo = foo
```
2023-08-09 00:42:33 +07:00
Vasil Markoukin 46e08442cd
Allow `$.stable_type_identifier` in `derives_clause` (#331)
Resolves #323

Summary
----
Support for dot-separated type references in derives clause
```scala
case class A() derives B.C
```
2023-08-08 16:38:19 +07:00
susliko c14e2d4aad feat: `given` pattern
Resolves #322

Summary
----
- `given_pattern` now handles cases like:
```scala
for
  given Int <- Some(1)
yield summon[Int]
```
- `corpus/patterns.txt` reformatted with `tree-sitter test -u`
2023-08-07 22:27:27 +07:00
GitHub ac08834b29 chore: generate and sync from 8137adbfba 2023-07-24 08:42:32 +07:00
Chris Kipp 8137adbfba
Merge pull request #325 from eed3si9n/wip/macros
Scala 2 macros
2023-07-24 09:24:30 +07:00
GitHub ebe8596fa3 chore: generate and sync from 8cdd8bdd7f 2023-07-24 05:04:02 +07:00
Eugene Yokota 7afd059843 Scala 2 macros
Problem
-------
Scala 2 macro definition is not supported.

Solution
--------
This adds macro_body as an expression.
2023-07-23 14:15:57 +07:00
Johannes Coetzee 6f9683bbfb Handle quote dollar escape case as well 2023-07-21 10:01:38 +07:00
Johannes Coetzee 9e30051ef7 Alias interpolation_identifier to identifier to avoid query badness 2023-07-20 23:22:12 +07:00
Johannes Coetzee dda875eae9 Rename interpolation_identifier 2023-07-20 14:42:40 +07:00
Johannes Coetzee 3aa86705b4 Fix double dollar escapes 2023-07-20 14:20:54 +07:00
Johannes Coetzee aa5907747b Fix interpolated string identifiers 2023-07-19 23:40:59 +07:00
Karan Ahlawat 61aa6534b2 correct result_type to return_type 2023-06-21 11:51:21 +07:00
Karan Ahlawat 2db441828f Add type lambda rule and related tests 2023-06-21 11:46:42 +07:00
s.bazarsadaev 662a3e9957 Closes #260 2023-06-14 19:34:29 +07:00
susliko 0e89e94d5f Better comments
Problem
-------
The following comment combinations are not parsed:
1. ```
// /*
// *
// */
```
2. ```
/* // */
```
Solution
-------
- set higher lexing priority for `$._comment_text` token
- include "//" as an alternative to the contents of `$.block_comment`
2023-06-12 15:51:10 +07:00
GitHub b8bd6e67d8 chore: generate and sync from 3573bf75fe 2023-06-11 05:04:25 +07:00
susliko bc9fb988bf Structural types in declarations
Problem
-------
Structural types in declarations are not parsed:
```
val x: F { val y: Int }
```

Solution
-------
Remove -1 precedence for `$._structural_type` branch of  `$.compount_type`, resolve conflict with `$._type` explicitly

Extra changes
-------
Removed some unused conflict resolutions
2023-06-10 22:01:47 +07:00
GitHub 4f188b08e0 chore: generate and sync from b2dd83f635 2023-06-10 03:25:47 +07:00
susliko 917cf8c54d Multi-line parameter lists
Problem
-------
Parameter lists spreading multiple lines are not handled:
```
class A
():
  def b
    (): Int = 1
```

Solution
-------
Match `$._automatic_semicolon` in `$._function_constructor` and
`$.class_parameters`

Side-change: reuse `$._function_declaration` in `$.function_definition`
2023-06-09 19:42:43 +07:00
eugene yokota d84b23fda3
Merge pull request #292 from susliko/multi-valvar-definitions 2023-06-09 08:10:17 +07:00
susliko 9d53ab25cb Multi-val/var definitions
Problem
-------
Definitions like the following are not supported:
```scala
val a,b,c: Int = 1
var d,e = ""
```

Solution
-------
Add `$.identifiers` as a choice option along with `$._pattern` to
`$.var_definition`.
Remove `prec(-1)` in `$.identifiers` definitions so that parser wouldn't
on declarations with more than two identifiers.
Resolve a conflict between `$.identifiers` and `$.val_declaration`
2023-06-09 13:09:23 +07:00
GitHub 757dbd6977 chore: generate and sync from 359cfcb136 2023-06-09 05:03:42 +07:00
susliko a889c3c749 Rework lambda expressions
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
2023-06-08 17:20:52 +07:00