Giter Club home page Giter Club logo

Comments (2)

fzxen avatar fzxen commented on August 16, 2024

I found the cause of the problem. tree-sitter-kotlin regards return/break/continue as expressions instead of statement.

{
  jump_expression: $ => choice(
      prec.left(PREC.RETURN_OR_THROW, seq("throw", $._expression)),
      prec.left(PREC.RETURN_OR_THROW, seq(choice("return", $._return_at), optional($._expression))),
      "continue",
      $._continue_at,
      "break",
      $._break_at
    ),
}

It hit the definition of infix expression.

{
  infix_expression: $ => prec.left(PREC.INFIX, seq($._expression, $.simple_identifier, $._expression)),
}

I think "return/break/continue/throw" should be converted to statement.

A distinction is often made between statements, which are executed, and expressions, which are evaluated. Expressions always evaluate to a value, which statements do not. However, expressions are often used as part of a larger statement. - copy from wikipedia

from tree-sitter-kotlin.

ObserverOfTime avatar ObserverOfTime commented on August 16, 2024

This has been fixed.

(source_file [0, 0] - [4, 0]
  (function_declaration [0, 0] - [3, 1]
    (simple_identifier [0, 4] - [0, 8])
    (function_value_parameters [0, 8] - [0, 16]
      (parameter [0, 9] - [0, 15]
        (simple_identifier [0, 9] - [0, 10])
        (user_type [0, 12] - [0, 15]
          (type_identifier [0, 12] - [0, 15]))))
    (function_body [0, 17] - [3, 1]
      (statements [1, 4] - [2, 17]
        (property_declaration [1, 4] - [1, 23]
          (variable_declaration [1, 8] - [1, 14]
            (simple_identifier [1, 8] - [1, 14]))
          (additive_expression [1, 17] - [1, 23]
            (simple_identifier [1, 17] - [1, 18])
            (integer_literal [1, 21] - [1, 23])))
        (jump_expression [2, 4] - [2, 17]
          (additive_expression [2, 11] - [2, 17]
            (simple_identifier [2, 11] - [2, 12])
            (integer_literal [2, 15] - [2, 17])))))))

from tree-sitter-kotlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.