Commit Graph

60 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
Eugene Yokota 97c9cffb5d Update tree-sitter to 0.21.0
See the tree-sitter release notes for details
- https://github.com/tree-sitter/tree-sitter/releases/tag/v0.21.0
2024-03-12 03:04:42 +07:00
susliko b80c70f804 Bump dotty to 85 2023-09-20 00:21:33 +07:00
eugene yokota ee2e9ab164
Merge branch 'master' into next-line-derives 2023-09-18 23:14:57 +07:00
susliko 6ada5ca0b8 Raise syntax complexity ceiling to 1400 2023-09-18 22:34:36 +07:00
susliko 5c54434c2a Bump dotty codebase smoke test to 84 2023-09-18 21:59:43 +07:00
Eugene Yokota 3c4276437a Reduce the Dotty percentage to 83 2023-08-27 15:40:10 +07:00
susliko 88501742c3 Bump DOTTY_COMPILER_EXPECTED to 84 2023-08-08 15:57:47 +07:00
s.bazarsadaev 662a3e9957 Closes #260 2023-06-14 19:34:29 +07:00
susliko 16974b4535 Issue OUTDENT with extra spaces before brackets
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
2023-06-11 00:00:13 +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
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
Ondra Pelech d0de6cfeaf
SYNTAX_COMPLEXITY_CEILING=1300 2023-06-09 01:12:24 +07:00
Eugene Yokota cacf8d3668 scalac to 89% 2023-06-07 04:32:32 +07:00
Eugene Yokota fc8ac917ab 82% on Dotty 2023-06-06 01:26:06 +07:00
susliko 64dff7f7f1 Smoke test accuracy for scala compiler is 87 now 2023-05-30 23:39:38 +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 4b7736c6e3
Merge branch 'master' into wip/refinement 2023-05-29 01:34:08 +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 3fbdb85522 Scala 2 library now 95% 2023-05-27 21:48:39 +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 8686eb3e27 Bump smoke test accuracy for dotty codebase to 81% 2023-05-28 01:17:59 +07:00
Eugene Yokota 33e0c02eef 94% for Scala 2 library 2023-05-27 17:56:34 +07:00
susliko f8390893ad Increase smoke_test accuracy to 80% for dotty codebase 2023-05-26 23:43:05 +07:00
Eugene Yokota 6271277c8e Symbolic import
Problem
-------
symbolic import doesn't work.

Solution
--------
This switches a few things to `_identififer`
to fix the import.
2023-05-25 22:33:08 +07:00
eugene yokota 361f45bd37
Merge pull request #240 from eed3si9n/wip/smoke
Fix smoke test
2023-05-25 19:32:54 +07:00
Eugene Yokota dfc9e46ba5 Fix smoke test
Problem
-------
Unfortunately the smoke test hasn't been accurate.
Apparently it's been looking at only the top directories.

Solution
--------
This should fix it.
2023-05-25 19:22:13 +07:00
susliko 2636cd3469 Set 78% accuracy for dotty compiler codebase smoke test 2023-05-25 18:35:31 +07:00
Ondra Pelech 2eb3becc4e lower ceiling 2023-05-25 01:54:26 +07:00
Ondra Pelech 216b2d7105 better message 2023-05-25 01:45:10 +07:00
Ondra Pelech 426910ed55 smoke_test.sh: attribute the definition complexity to proper line 2023-05-25 01:34:43 +07:00
Ondra Pelech f35b1102e7 Add complexity check to smoke_test.sh 2023-05-25 00:37:52 +07:00
Ondra Pelech 28a0d2121c Shellcheck 2023-05-24 23:58:09 +07:00
susliko 36b4696c0a Smoke test is now 84% for Scala and 71% for Dotty compilers 2023-05-24 19:02:20 +07:00
Eugene Yokota c9f004e38b Smoke test is now 66% for Dotty 2023-05-23 22:08:30 +07:00
Anton Sviridov cb34635bca Abstract type definitions 2023-01-28 08:50:35 +07:00
Anton Sviridov 0ca302070e Up the scala compiler success percentage 2023-01-22 16:18:12 +07:00
Eugene Yokota 944196126a Trailing commas
Problem
-------
Trailing commas are not supported.

Solution
--------
This adds support for that.
2023-01-19 01:39:30 +07:00
Eugene Yokota b5fd12eaab Fixes extends clause
Problem
-------
1. In Scala 3, extends clause can be comma separated.
2. In Scala 2 or 3 extends clause can ctor with parameters:
   `class D with E(x) with F(y)`.

Solution
--------
`extends` is now followed by *constructor applications* separated by
either `with` or `,` as opposed to treating them as a compound type.
2023-01-13 14:40:20 +07:00
Eugene Yokota fe6ff49ee8 Fix operator_identifier
Problem
-------
1. Currently `//` ends up matching `operator_identier`
2. There's also a bug in regex.

Solution
--------
1. Implement a workaround to avoid `//`.
2. Escape `-`, copying from the identifier regex.
2023-01-13 04:04:58 +07:00
Eugene Yokota 77ea27edbe Fixes instance_expression
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`.
2023-01-11 19:15:42 +07:00
Anton Sviridov accc6c0132 Output expected % regardless 2023-01-10 10:42:00 +07:00
Eugene Yokota 996b7849eb Fixes for expression
Fixes https://github.com/tree-sitter/tree-sitter-scala/issues/123

Problem
-------
Guard `if something` isn't supported in the for expression.

Solution
--------
This implements it.
2023-01-10 05:18:28 +07:00
Eugene Yokota 57a0e420aa dotty/compiler/: expected 72, but got 71.99 instead 2023-01-10 04:45:01 +07:00
Eugene Yokota 0c6d589a17 Spec-correct identifier
Problem
-------
The `identifier` token is hacked together, so we never quite get the
parsing right.

Solution
--------
My friend Ethan Atkins at some point experimented with generating
tree-sitter grammar out of EBNF (https://github.com/eatkins/tree-sitter-ebnf-generator/tree/master/examples/scala)
and his identifier, as far as I know is spec-correct.
We simplified the regex a bit to fit into the tree-sitter's unsigned
short int count, but it should be comparable.
2023-01-10 04:39:47 +07:00
Eugene Yokota bf4102c863 Include operator-like identifier as simple expression
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.
2023-01-09 18:54:50 +07:00
Anton Sviridov 71e8ac0974 Test and use shadow node
- Bump dotty/scala library percentage
2023-01-09 21:04:58 +07:00