Comments (3)
The exposed token is ", but the underlying source text has the full original token.
Yes, the token has a correct range that allows to access a correct piece in an original input.
But with predicates that is much slower because they work outside of a query engine as post filtering and require access to an input.
If there will be correct terminals then queries like bellow would work without predicates:
; Strings with only triple single quotes
(string "'''" @quote) @str
; Strings with triple quotes
(string [ "'''" "\"\"\"" ] @quote) @str
And in a visual tree representation there will be no misunderstanding:
I think it should become a bad practice to hide actual terminals that define syntax structure and replace them to something another. But for now this exist in this grammar for historical reasons.
from tree-sitter-python.
I'm not sure I see what the problem is. The exposed token is "
, but the underlying source text has the full original token.
For instance, the following query can be used to match only strings delimited with triple (single) quotes:
(
(string "\"" @quote) @str
(#match? @quote "'''")
)
from tree-sitter-python.
Have a similar problem, I'm looking for a query to target only the quote characters, not the entire string. For many languages this works with (_ "\"" "\"")
or similar, but not for python. Is there an easy query like this?
from tree-sitter-python.
Related Issues (20)
- Not working on Windows with latest nvim-treesitter version HOT 1
- Unable to parse match statements HOT 1
- Dedent regression in valid ternary expression in f-string
- Parsing python code failed with, ValueError: Parsing Failed. HOT 2
- `Error during compilation: cannot execute ‘cc1plus’: execvp: No such file or directory` HOT 2
- Missing git tag for v0.20.2 HOT 2
- Two nodes with kind "lambda" in 0.20.2 HOT 1
- Parsing error in while loop HOT 3
- Cannot compile due to call to undeclared function 'static_assert' HOT 7
- Comment parsing HOT 2
- 3.12 "`type`" soft keyword (PEP 0695) HOT 1
- Extra indent when using an open bracket/parenthesis in string literal HOT 1
- Helping injected languages parse docstrings HOT 1
- Parameter highlight group doesn't capture references in body HOT 6
- Trailing comma in Annotated causes an error
- bug: Bad parse/behavior with docstring containing extraneous "-character HOT 1
- feature: doctest support HOT 2
- bug: Fail to parse type expression
- bug: Fail to parse from here but the online playground is fine HOT 1
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-python.