Comments (3)
@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.
How did you produce that output... is there an option to include ranges in corpus tests ?
from tree-sitter-haskell.
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)
- 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
- Native and WASM parsers behave differently HOT 11
- How do I generate a valid WASM file HOT 9
- Grammar defines trailing whitespace as part of lambda case statement HOT 4
- Parse errors when using DerivingVia HOT 4
- infixr and infixl not respected HOT 4
- Crashing (possibly while editing markdown) HOT 7
- Comments following function included in function pattern HOT 6
- Update to latest tree-sitter version
- Outermost function when using $ operator isn't parsed as a function HOT 8
- Instance with associated type, following TH top level splice, misparsed as function HOT 2
- Misparse of explicit-braced code
- 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.