Commit Graph

143 Commits (3aa86705b4f2379b51cfa7b9639208bebc6b8b35)

Author SHA1 Message Date
Anton Sviridov 0d94e6ee2a Handle backquoted identifiers [grammar and tests] 2023-01-04 08:07:55 +07:00
Eugene Yokota 8c358ddf37 Scala 3 for expression 2022-12-20 11:38:51 +07:00
Eugene Yokota f440283f4f Scala 3 while expression 2022-12-20 11:38:51 +07:00
Eugene Yokota 5d129d3bd9 Scala 3 match expression 2022-12-20 11:38:51 +07:00
Eugene Yokota debb382b38 Scala 3 try-catch support 2022-12-20 11:38:51 +07:00
Eugene Yokota 83aaa6020e Fix indent/outdent tracking
Problem
-------
Given something like
    class A:
      def a() =
        ()

    def a() = 1
the scanner only outdents once, so it fails to parse the above.

Solution
--------
Track `last_indentation_size` in the payload to indicate last
outdent (default: -1). If it's not -1 that means there was an outdent.
This then checks if the last_indentation_size qualified for another
outdent.
2022-12-20 11:38:50 +07:00
Eugene Yokota fa8d64b77e Optional braces, part 2
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.
2022-12-17 21:10:45 +07:00
Anton Sviridov 0002b5f094 Indent/Outdent external parser 2022-12-15 13:09:29 +07:00
Eugene Yokota 43d8c3b80b Optional braces, part 1
Problem
-------
Currently Scala 3 optional braces syntax does not work.

Solution
--------
This implements initial attempt on dealing with colon
instead of braces.
Note that this does not implement any indent/outdent tracking
so the second `val` onwards will not be added in `template_body`
but it should improve the highlighting a bit.
2022-12-14 22:58:38 +07:00
Stuart Mashaal 7609d81bd7 replace conflict with precedence 2022-05-22 18:44:53 +07:00
Stuart Mashaal 542a1e8e78 lambda_expression can have _block as body 2022-05-22 18:29:49 +07:00
Anton Sviridov 8599058ef2
Fix wildcard Scala 3 imports (#44) 2022-05-09 16:17:13 +07:00
Stevan Milic 0a3dd53a7f
Fix pattern definition (#38) (#39) 2021-10-10 10:34:22 +07:00
Stevan Milic 98f703493d
Add lambda expression (#34)
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>
2021-10-07 09:03:08 +07:00
Stevan Milic e79f8cd2d0
Update expression rule (#33)
* add postfix expression

* add ascription expression
2021-08-31 13:41:54 +07:00
Stevan Milic 60c3afcdea
Allow `extends` to be on a new line (#31)
Co-authored-by: Stevan Milic <stevan.milic@tradecore.com>
2021-08-29 11:14:12 +07:00
Stuart Mashaal ec38674996
add while/do loops and for-comprehension (#30) 2021-08-08 14:43:30 +07:00
Denis Pyshev f80daaa212
Miscallleneous stuff (#27)
* Null literal

* Unit expression, required for `for {...} ()` case

* Add `return` expression

* Add `throw` expression

* Apply changes per review

Remove redundant token fun call.
2021-07-19 13:26:02 +07:00
Denis Pyshev bfa2a81388
Feature/literals (#25)
* 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.
2021-06-23 15:37:27 +07:00
Chris Kipp fb23ed9a99
Add in support for boolean, character, and symbol literals. (#22)
* This adds in support for boolean, character, and symbol literals.

Previously we would just handle boolean literals and character literals
as identifiers, and wouldn't handle symbol literals.

* Fix CI
2021-04-01 10:11:15 +07:00
Chris Kipp f7721fd339
Enhance string interpolation model (#20) 2021-03-12 10:13:24 +07:00
Chris Kipp 63f103cc87
Allow for catch and finally in try expression to be on a new line (#16)
* Allow for catch and finally in try expression to be on a new line

* Fix actions to run on all pull requests
2021-03-12 09:41:49 +07:00
Tuấn-Anh Nguyễn 211bb726bb
Various improvements (#13)
* 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
2020-07-13 13:31:00 +07:00
Tuấn-Anh Nguyễn 55c9803ce6
Add node fields to grammar (#12)
* Update binding.cc to latest template

* ⬆️ tree-sitter-cli

* Add node fields to the grammar
2020-07-06 09:17:58 +07:00
Sebastián Gurin 0789f300f4 Add basic floating point literal parsing (#7)
* fix floating point numbers

* floating point numbers

* travis node 11

* npm test
2019-06-17 11:56:52 +07:00
Max Brunsfeld fbb6813633 ⬆️ tree-sitter-cli, add word token 2018-06-15 14:22:58 +07:00
Mads Hartmann 9f67a58cff Add support for bounds on type parameters 2018-02-24 17:19:34 +07:00
Mads Hartmann 65a4ee33f9 Support comma separated import declarations 2018-02-24 17:19:34 +07:00
Mads Hartmann c92323ddf5 Improve grammar for package declarations
Adds support for package blocks and package objects
2018-02-24 17:19:26 +07:00
Mads Hartmann 7265c8f855 Allow objects to have extend clauses
This doesn't adhere to the full object declaration specification yet
but it's a very small step in the right direction
2018-02-24 13:35:03 +07:00
Mads Hartmann a481a6bd34 Make type variance nodes visible 2018-02-24 11:09:13 +07:00
Mads Hartmann cc7a8c1492 Basic support for specifying variance of type parameters 2018-02-23 08:42:15 +07:00
Max Brunsfeld 5a17adfe39 Add try expressions 2018-02-22 17:06:29 +07:00
Max Brunsfeld a8b0acb96c Refine semicolon insertion, add arguments in extends clause 2018-02-22 17:00:13 +07:00
Max Brunsfeld 37269678d3 Add capture patterns, multiple expressions in case clauses 2018-02-22 16:40:33 +07:00
Max Brunsfeld d85f4043fa Add modifiers and case blocks in more places 2018-02-22 16:27:15 +07:00
Max Brunsfeld fb6af52272 Add string transform expressions, case class patterns 2018-02-22 16:11:36 +07:00
Max Brunsfeld cfdfe47282 Don't allow square brackets in operator names 2018-02-22 16:05:45 +07:00
Max Brunsfeld 2dcb6b04b2 Add interpolated strings, modifiers, tuple patterns 2018-02-22 16:02:12 +07:00
Max Brunsfeld 094fb0d3ba Add extends clauses 2018-02-22 15:00:34 +07:00
Max Brunsfeld ce75e0497e Add import declarations and comments 2018-02-22 13:16:27 +07:00
Max Brunsfeld f731b1d798 Add type annotations in patterns 2018-02-22 11:05:57 +07:00
Max Brunsfeld dc4c0d4963 Initial commit 2018-02-22 10:58:11 +07:00