Code Monkey home page Code Monkey logo

Comments (3)

rewinfrey avatar rewinfrey commented on June 1, 2024

@clojj, thanks for filing this issue. I apologize for the delay. I was heads down reworking a large chunk of the grammar to better delineate between left-hand side patterns from right-hand side patterns. I hope those changes have not added significant effort to your atom language plugin.

I also updated the external scanner, and would like to verify that this problem persists or not for you. Locally, I'm not seeing the same range issue now that you've reported here.

Given the Haskell example:

f = let {y = x
        ;z = 2
        ;x = 1} in y

f = let y = x
        z = 2
        x = 1
      in y

The tree-sitter parse output with ranges is:

(module [0, 0] - [8, 0]
  (function_declaration [0, 0] - [2, 20]
    (variable_identifier [0, 0] - [0, 1])
    (function_body [0, 4] - [2, 20]
      (let_expression [0, 4] - [2, 20]
        (function_declaration [0, 9] - [0, 14]
          (variable_identifier [0, 9] - [0, 10])
          (function_body [0, 13] - [0, 14]
            (variable_identifier [0, 13] - [0, 14])))
        (function_declaration [1, 9] - [1, 14]
          (variable_identifier [1, 9] - [1, 10])
          (function_body [1, 13] - [1, 14]
            (integer [1, 13] - [1, 14])))
        (function_declaration [2, 9] - [2, 14]
          (variable_identifier [2, 9] - [2, 10])
          (function_body [2, 13] - [2, 14]
            (integer [2, 13] - [2, 14])))
        (in_clause [2, 16] - [2, 20]
          (variable_identifier [2, 19] - [2, 20])))))
  (function_declaration [4, 0] - [7, 10]
    (variable_identifier [4, 0] - [4, 1])
    (function_body [4, 4] - [7, 10]
      (let_expression [4, 4] - [7, 10]
        (function_declaration [4, 8] - [4, 13]
          (variable_identifier [4, 8] - [4, 9])
          (function_body [4, 12] - [4, 13]
            (variable_identifier [4, 12] - [4, 13])))
        (function_declaration [5, 8] - [5, 13]
          (variable_identifier [5, 8] - [5, 9])
          (function_body [5, 12] - [5, 13]
            (integer [5, 12] - [5, 13])))
        (function_declaration [6, 8] - [6, 13]
          (variable_identifier [6, 8] - [6, 9])
          (function_body [6, 12] - [6, 13]
            (integer [6, 12] - [6, 13])))
        (in_clause [7, 6] - [7, 10]
          (variable_identifier [7, 9] - [7, 10]))))))

The parse output with ranges indicates each of the function declarations is enclosed within a single line for both the explicit ({...}) and implicit let statements. Assuming you're using those ranges, this should fix the mismatch you've seen.

from tree-sitter-haskell.

clojj avatar clojj commented on June 1, 2024

It is fixed, nice!
range-fixed

How did you produce that output... is there an option to include ranges in corpus tests ?

from tree-sitter-haskell.

rewinfrey avatar rewinfrey commented on June 1, 2024

How did you produce that output... is there an option to include ranges in corpus tests ?

@clojj you can see the range info by using the tree-sitter parse command. It's available through tree-sitter-cli and is a node package that will be available in node_modules/.bin within the tree-sitter-haskell repository. An example invocation is:

node_modules/.bin/tree-sitter parse example.hs

Currently corpus tests are used to verify the structure of the ASTs produced by tree-sitter grammars. Maybe in the future ranges can be included in corpus tests but that's not supported today.

from tree-sitter-haskell.

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.