Giter VIP home page Giter VIP logo

Comments (3)

aegarbutt-stripe avatar aegarbutt-stripe commented on September 10, 2024 1

I've run into this issue when trying to run semgrep on a ruby file with nested heredocs. (semgrep/semgrep#3151)

When I paste the following into https://tree-sitter.github.io/tree-sitter/playground:

output =
  <<~ABC
    Top
    #{
      <<~DEF
        Middle
      DEF
    }
    Bottom
  ABC

puts output

I get the following output:

program [0, 0] - [13, 0])
  assignment [0, 0] - [1, 8])
    left: identifier [0, 0] - [0, 6])
    right: heredoc_beginning [1, 2] - [1, 8])
  heredoc_body [1, 8] - [9, 5])
    heredoc_content [1, 8] - [3, 4])
    interpolation [3, 4] - [7, 5])
      heredoc_beginning [4, 6] - [4, 12])
      constant [5, 8] - [5, 14])
      constant [6, 6] - [6, 9]). <-- This is the closing DEF of the HEREDOC string
    heredoc_content [7, 5] - [9, 2])
    heredoc_end [9, 2] - [9, 5])
  heredoc_body [9, 5] - [13, 0])
    heredoc_content [9, 5] - [13, 0])
    heredoc_end [13, 0] - [13, 0])

from tree-sitter-ruby.

dumblob avatar dumblob commented on September 10, 2024

I have the same issue with bourne shell. Nested heredocs are totally wrongly parsed and thus wrongly highlighted e.g. by neovim.

Do you have any news on the state of heredocs in treesitter?

from tree-sitter-ruby.

aibaars avatar aibaars commented on September 10, 2024

@dumblob heredocs are not a treesitter feature. Support for special lexcical things such as heredocs are implemented by scanner.cc. I guess the scanner used tree-sitter-bash has a similar bug as the one of tree-sitter-ruby.

from tree-sitter-ruby.

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.