Comments (3)
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.
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.
@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)
- Ruby parser.c size HOT 3
- Error: Binding arguments in strict mode
- Wrong Ruby indent when entering a `.` before `end` HOT 14
- Parsing fails with wasm version HOT 1
- 0.20.0 is not tagged HOT 3
- Incomplete method definition parses as if it ends on the first line
- `build-wasm` fails to produce working parser HOT 2
- Ruby `...` (triple-dot) syntax not properly handled HOT 1
- Proposal: Adopt YARP HOT 1
- eruby with comments 3 orders of magnitude slower
- Syntax error in one line `def` with a command call as right-hand side
- Add support for *.html.slim filetypes HOT 3
- Parse error in anonymous block arguments HOT 1
- Error `fatal error: 'cstring' file not found` when compiling in MacBook M2 HOT 2
- Request for latest release HOT 3
- bug: Compilation error during tree-sitter-ruby update HOT 2
- bug: highlight tests failing with tree-sitter 0.22.2
- feature: release tree-sitter 0.21 compatible version
- bug: String concatenation using << and without spaces considers it as a heredoc
- bug: can not collapse a ruby lambda function inside a ruby method without collapsing the entire method when using code folds with neovim
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tree-sitter-ruby.