Skip to content

Conversation

@keynmol
Copy link
Collaborator

@keynmol keynmol commented Feb 2, 2022

Same as #44 - I'm still figuring out Tree Sitter (reading docs) so please do tell how to do this better.
I think adding two conflicts severely affected the parser build time (which wasn't fast before).

Code:

inline def test(inline c: Char) = 
  inline c match {
    case 'a' => 1
    case 'b' => 2
  }

inline def test1(inline c: Char) = 
  inline if (c == 'h') {}
Before

ERROR [0, 0] - [0, 6]
  identifier [0, 0] - [0, 6]
function_definition [0, 7] - [8, 6]
  name: identifier [0, 11] - [0, 15]
  parameters: parameters [0, 15] - [0, 31]
    parameter [0, 16] - [0, 30]
      name: identifier [0, 16] - [0, 22]
      ERROR [0, 23] - [0, 24]
        identifier [0, 23] - [0, 24]
      type: type_identifier [0, 26] - [0, 30]
  body: postfix_expression [0, 35] - [8, 6]
    block [0, 35] - [6, 1]
      assignment_expression [1, 2] - [1, 21]
        left: infix_expression [1, 2] - [1, 14]
          left: identifier [1, 2] - [1, 8]
          operator: identifier [1, 9] - [1, 12]
          right: identifier [1, 13] - [1, 14]
        right: boolean_literal [1, 17] - [1, 21]
      match_expression [2, 2] - [5, 3]
        value: postfix_expression [2, 2] - [2, 10]
          identifier [2, 2] - [2, 8]
          identifier [2, 9] - [2, 10]
        body: case_block [2, 17] - [5, 3]
          case_clause [3, 4] - [4, 4]
            pattern: character_literal [3, 9] - [3, 12]
            body: integer_literal [3, 16] - [3, 17]
          case_clause [4, 4] - [5, 2]
            pattern: character_literal [4, 9] - [4, 12]
            body: integer_literal [4, 16] - [4, 17]
    identifier [8, 0] - [8, 6]
function_definition [8, 7] - [9, 25]
  name: identifier [8, 11] - [8, 16]
  parameters: parameters [8, 16] - [8, 32]
    parameter [8, 17] - [8, 31]
      name: identifier [8, 17] - [8, 23]
      ERROR [8, 24] - [8, 25]
        identifier [8, 24] - [8, 25]
      type: type_identifier [8, 27] - [8, 31]
  body: infix_expression [9, 2] - [9, 25]
    left: identifier [9, 2] - [9, 8]
    operator: identifier [9, 9] - [9, 11]
    right: call_expression [9, 12] - [9, 25]
      function: parenthesized_expression [9, 12] - [9, 22]
        infix_expression [9, 13] - [9, 21]
          left: identifier [9, 13] - [9, 14]
          operator: operator_identifier [9, 15] - [9, 17]
          right: character_literal [9, 18] - [9, 21]
      arguments: block [9, 23] - [9, 25]

After

(compilation_unit [0, 0] - [10, 0]
  (function_definition [0, 0] - [6, 1]
    (inline_modifier [0, 0] - [0, 6])
    name: (identifier [0, 11] - [0, 15])
    parameters: (parameters [0, 15] - [0, 31]
      (parameter [0, 16] - [0, 30]
        (inline_modifier [0, 16] - [0, 22])
        name: (identifier [0, 23] - [0, 24])
        type: (type_identifier [0, 26] - [0, 30])))
    body: (block [0, 35] - [6, 1]
      (val_definition [1, 2] - [1, 21]
        (inline_modifier [1, 2] - [1, 8])
        pattern: (identifier [1, 13] - [1, 14])
        value: (boolean_literal [1, 17] - [1, 21]))
      (match_expression [2, 2] - [5, 3]
        (inline_modifier [2, 2] - [2, 8])
        value: (identifier [2, 9] - [2, 10])
        body: (case_block [2, 17] - [5, 3]
          (case_clause [3, 4] - [4, 4]
            pattern: (character_literal [3, 9] - [3, 12])
            body: (integer_literal [3, 16] - [3, 17]))
          (case_clause [4, 4] - [5, 2]
            pattern: (character_literal [4, 9] - [4, 12])
            body: (integer_literal [4, 16] - [4, 17]))))))
  (function_definition [8, 0] - [9, 25]
    (inline_modifier [8, 0] - [8, 6])
    name: (identifier [8, 11] - [8, 16])
    parameters: (parameters [8, 16] - [8, 32]
      (parameter [8, 17] - [8, 31]
        (inline_modifier [8, 17] - [8, 23])
        name: (identifier [8, 24] - [8, 25])
        type: (type_identifier [8, 27] - [8, 31])))
    body: (if_expression [9, 2] - [9, 25]
      (inline_modifier [9, 2] - [9, 8])
      condition: (parenthesized_expression [9, 12] - [9, 22]
        (infix_expression [9, 13] - [9, 21]
          left: (identifier [9, 13] - [9, 14])
          operator: (operator_identifier [9, 15] - [9, 17])
          right: (character_literal [9, 18] - [9, 21])))
      consequence: (block [9, 23] - [9, 25]))))

@keynmol
Copy link
Collaborator Author

keynmol commented Dec 22, 2022

I decided to not wait for a whole year before closing this, please consider adding more maintainers who are interested in reviewing PRs

#63

@keynmol keynmol closed this Dec 22, 2022
@keynmol keynmol deleted the scala3-inline branch December 22, 2022 14:07
@sideeffffect
Copy link
Contributor

@keynmol would you like to reopen the PR in light of #63 (comment) ?

@sideeffffect sideeffffect mentioned this pull request Jan 3, 2023
@keynmol keynmol restored the scala3-inline branch January 4, 2023 09:10
@keynmol keynmol reopened this Jan 4, 2023
@eed3si9n eed3si9n added the area/scala3 Scala 3 syntax label Jan 5, 2023
@eed3si9n eed3si9n mentioned this pull request Jan 5, 2023
Copy link
Collaborator

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @keynmol!

@eed3si9n eed3si9n merged commit 32b400e into tree-sitter:master Jan 9, 2023
@keynmol keynmol deleted the scala3-inline branch January 10, 2023 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scala3 Scala 3 syntax

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants