Comments (6)
Same thing happens for class
and instance
patterns, for example:
instance Class Data where
f = a
-- | haddock
g = a
class Class where
f :: Data
-- | haddock
g = a
(class) @class.around
(instance (where)? . _ @class.inside) @class.around
from tree-sitter-haskell.
I'm not sure that it's feasible to implement this, since comments are allowed to break indentation:
f = do
g
-- foo
pure 1
so in order to decide whether the comment should terminate the do
layout, we'd need to parse the indent of the following line, which would require us to either
- jump back to after
g
if indentation decreases to terminate thedo
node - jump back to after
foo
if indentation stays the same so that the leading spaces of the next line won't be included in the comment (and we need them to determine the indent again for the next node)
and this won't work since we can't store two positions at once
(in case that is unclear: comments and indent are parsed manually in the C extension)
The only way I can imagine now would be to compromise and use -- |
as an indicator, but since that isn't Haskell syntax, but Haddock, it could break valid code. Though it's probably unlikely to occur in an invalid position.
I'll think a bit more about this but I'm fairly pessimistic.
from tree-sitter-haskell.
@414owen do you have an idea maybe?
from tree-sitter-haskell.
I guess I'm unsure why it works without the do block. I would have thought the lexer would only detect the end of f
when it sees function g
, which would be after the comment.
from tree-sitter-haskell.
indeed, that's curious
from tree-sitter-haskell.
ok so in the case without do
the function is entirely contained in the range a = b
, so tree-sitter is conservative and uses the smallest tree that works, leaving the comment on its own since there's no reason to associate it with any neighboring node more than the others.
for the do
case, the layout end is part of the function rhs, so the comment cannot escape that tree.
from tree-sitter-haskell.
Related Issues (20)
- Combining characters in identifiers are not parsed correctly HOT 1
- Include . from qualified modules and variables HOT 6
- Segfault on large files (in Neovim) HOT 1
- Upgrade node-gyp dependency HOT 2
- Components parser as type when they are not HOT 1
- Include ! from strictness annotations
- exp_section_right not parsed when containing a hash HOT 3
- Incorrect parse for function with where-clause and comments HOT 4
- Can't npm install tree-sitter-haskell on Mac M3 Node.js v20.10? HOT 1
- Incorrect parse due to top-level splices HOT 11
- Failed builds due to very big file(s). HOT 3
- Qualified/unqualified module paths colored differently HOT 3
- Typed Template Haskell quotations / splices not handled correctly HOT 3
- "finally" is highlighted like a language keyword HOT 1
- Hangs when highlighting/parsing `data Aa = Bb | Cc | ` HOT 3
- Update package for tree-sitter 0.21 HOT 3
- UnicodeSyntax support HOT 10
- "undefined symbol: tree_sitter_haskell_external_scanner_create" when running "tree-sitter test" HOT 7
- Support `OverloadedRecordDot` HOT 8
- I added three more symbols for built-in syntax.
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-haskell.