Problem
-------
```scala
{ x =>
if (a) b.c }
```
is not parsed because OUTDENT token is not emitted in a presense of
space characters before the closing bracket
Solution
-------
Reorder space-handling and outdent-ing logic in external scanner
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
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.
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
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`
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
Problem
-------
Catch-clause is not parsed when case is on the same line as 'catch':
```
try a catch b: C => d
```
Solution
-------
Intoduce `$._expr_case_clause` alternative to the catch-clause
Problem
-------
Scala 3 introduced using clauses to function call expressions:
```scala
f(using A)
```
The grammar did not allow that
Solution
-------
Add `choice` between regular and using-clause argument lists in
`$.arguments`
Problem
-------
Guards in case clauses are thought to be lambda expressions sometimes,
e.g. in
```scala
{case a if b => c}
```
This happens, because `$.lambda_expression` has a higher parsing
precedence than `$._simple_expression`
Solution
-------
Avoid using numeric parsing precedence for `$.lambda_expression`.
Resolve specific conflicts instead
Problem:
-------
Code like
```scala
if true ()
else ()
```
or
```scala
a
.b
// comment
.c
```
is not parsed correctly, for extra `$._automated_semicolon` tokens,
which are produced after newlines
Solution:
-------
Tweak `scanner.c` to stop producing AUTOMATED_SEMICOLON tokens when
encountering comments, else/catch clauses, etc.
Problem
-------
Currently pattern match with guard doesn't parse.
Solution
--------
This implements it by creating an intermediate node called `_case_pattern` with right associativity.
Fixes https://github.com/tree-sitter/tree-sitter-scala/issues/127
Problem
-------
Currently our grammar does not support the fewer braces syntax,
which basically lets us pass the last argument as a block after `:`.
Solution
--------
This implements fewer braces support for call_expression,
infix_expression, with and without the lambda start.
Problem
-------
Current grammar accepts expression immeidately after `new`,
which is not correct, and doesn't work for Scala 3 syntax.
Solution
--------
This fixes it by actually using `$.template_body`.
It does create a tricky conflict between `new A: <block>`
construct and `new A: <type>`.
To deal with that, we are using `prec.dynamic`.
Problem
-------
Currently operator-like identifiers are not part of the simple
expression, so you can't call `::(123)`.
Solution
--------
This includes `$.operator_identifier` into `_simple_expression`,
and further improves the expression hierarchy.
Note that this removes test on double-prefix-expression.
It's not allowed in Scala spec to have double-prefix.
Problem
-------
Currently we use `$.expression` everywhere even though it often
requires much narrower set of expressions.
Solution
--------
Now that we've gained some memory budget, this adds
`_simple_expression`, mirroring the EBNF, and adjusts
`infix_expression` etc to use narrower choice of expression tokens.
With this change, the smoke test for Scala 2 library jumps to 95%.
Problem
-------
Currently Scala 3 optional braces syntax does not work.
Specifically, in this PR I want to address decls/defns not
properly grouped under the right owner in part 1.
Solution
--------
1. This brings in indent/outdent impl by keynmol
2. Introduce `_indentable_expression`.
This allows us to limit where indent/outdent shows up without
confusing tree-sitter too much. To start, val/def/var defn
and if-expressions are given indentable expression.
Fix call expression to allow block as arguments (#21)
Update for comprehension to handle patterns
Fix for comprehension to detect assignment as an enumerator
Add access modifiers
Update trait, object and class parameter to support modifiers
Update scanner to support `with` on a new line
Update function definition/declaration to support operator naming
Update field expression to support operators as methods
Co-authored-by: Stevan Milic <stevan.milic@tradecore.com>
* Fix typo
* Rework literals part of grammar
Introduce hierarchy of literals as it is done in Scala language grammar.
Move existing literal types into hierarcy under `literal` parent.
Add and extend literals for integer and floating point numbers.
Add test cases for integer and floating point numbers in corpus.
Adjust existing test cases to changes.
Also fixes#24
* Apply review comments
Hide `literal` node from appearing in s-expressions and increasing
amount of states.
Update test cases according to grammar change.
* Add automatic changes
Add tree-sitter dependency update by npm.
Add atomatic changes in parser and grammar from building the parser.
* Add supertypes
* Support multi-line case clauses
* Allow definitions in case clauses, expressions in class/object bodies
* Add annotations, infix patterns, implicit parameters
* Add tree-sitter CLI declaration to package.json
* Add annotations on type parameters
* Add type annotations, type projections; fix compound types
* Fix operator_identifier regexp
* Add tuple types and repeated parameter types
* Give infix_pattern higher precedence than capture_pattern
* Make infix_type nestable
* Allow body-less trait_definition
* Allow omitting parens when function_type's input is a single type
* Put all alternatives function_type's parameters under parameter_types
* Give alternative_pattern lower precedence than typed_pattern
* Remove parenthesized_pattern
* Allow empty body in case_clause
* Regenerate parser