tree_haver 4.0.5 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +144 -1
- data/README.md +497 -356
- data/lib/tree_haver/backends/citrus.rb +98 -114
- data/lib/tree_haver/backends/ffi.rb +76 -13
- data/lib/tree_haver/backends/java.rb +99 -14
- data/lib/tree_haver/backends/mri.rb +25 -1
- data/lib/tree_haver/backends/parslet.rb +560 -0
- data/lib/tree_haver/backends/prism.rb +1 -1
- data/lib/tree_haver/backends/psych.rb +1 -1
- data/lib/tree_haver/backends/rust.rb +1 -1
- data/lib/tree_haver/base/node.rb +8 -1
- data/lib/tree_haver/language.rb +44 -13
- data/lib/tree_haver/parser.rb +128 -38
- data/lib/tree_haver/parslet_grammar_finder.rb +224 -0
- data/lib/tree_haver/point.rb +6 -44
- data/lib/tree_haver/rspec/dependency_tags.rb +40 -1
- data/lib/tree_haver/version.rb +1 -1
- data/lib/tree_haver.rb +100 -13
- data.tar.gz.sig +0 -0
- metadata +15 -14
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c483d5a811ccb8c64191bc8341e94ecc41996d1aab8a78ef81fea2833231a048
|
|
4
|
+
data.tar.gz: 0c0e1ef09ac515f0faf00d8d5f88568acd573007bd31a94d04706f8016cedf86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98548924f413e5ee8c39bd35af68debb5f3463c088768d991635ad50f2dc649231c60ff8cae12efce4569bfbfbdd61ed2873a225fbcbb6289930490a7ec6a195
|
|
7
|
+
data.tar.gz: edaa9affbcc349cf59dd57b02821345e4319d6666fcf01fcbfb8bd0eb490010545ff38aa175b108f0178aa24c8ca0573f653a5adc91449cd834b71aff7ac9acc
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,147 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
30
30
|
|
|
31
31
|
### Security
|
|
32
32
|
|
|
33
|
+
## [5.0.0] - 2026-01-11
|
|
34
|
+
|
|
35
|
+
- TAG: [v5.0.0][5.0.0t]
|
|
36
|
+
- COVERAGE: 92.04% -- 2289/2487 lines in 30 files
|
|
37
|
+
- BRANCH COVERAGE: 79.33% -- 929/1171 branches in 30 files
|
|
38
|
+
- 96.21% documented
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- **Shared Example Groups for Backend API Compliance Testing**
|
|
43
|
+
- `node_api_examples.rb` - Tests for Node API compliance:
|
|
44
|
+
- `"node api compliance"` - Core Node interface (type, start_byte, end_byte, children)
|
|
45
|
+
- `"node position api"` - Position API (start_point, end_point, start_line, end_line, source_position)
|
|
46
|
+
- `"node children api"` - Children traversal (#child, #first_child, #last_child)
|
|
47
|
+
- `"node enumerable behavior"` - Enumerable methods (#each, #map, #select, #find)
|
|
48
|
+
- `"node comparison behavior"` - Comparison and equality (#==, #<=>, #hash)
|
|
49
|
+
- `"node text extraction"` - Text content (#text, #to_s)
|
|
50
|
+
- `"node inspection"` - Debug output (#inspect)
|
|
51
|
+
- `tree_api_examples.rb` - Tests for Tree API compliance:
|
|
52
|
+
- `"tree api compliance"` - Core Tree interface (root_node, source, errors, warnings, comments)
|
|
53
|
+
- `"tree error handling"` - Error detection (#has_error?, #errors)
|
|
54
|
+
- `"tree traversal"` - Depth-first traversal via root_node
|
|
55
|
+
- `parser_api_examples.rb` - Tests for Parser API compliance:
|
|
56
|
+
- `"parser api compliance"` - Core Parser interface (#parse, #parse_string, #language=)
|
|
57
|
+
- `"parser incremental parsing"` - Incremental parsing support
|
|
58
|
+
- `"parser error handling"` - Error recovery behavior
|
|
59
|
+
- `language_api_examples.rb` - Tests for Language API compliance:
|
|
60
|
+
- `"language api compliance"` - Core Language interface (#backend, #name/#language_name)
|
|
61
|
+
- `"language comparison"` - Comparison and equality
|
|
62
|
+
- `"language factory methods"` - Factory methods (.from_library, .from_path)
|
|
63
|
+
- `backend_api_examples.rb` - Tests for Backend module API compliance:
|
|
64
|
+
- `"backend module api"` - Backend availability and capabilities
|
|
65
|
+
- `"backend class structure"` - Nested class verification
|
|
66
|
+
- `"backend integration"` - Full parse cycle testing
|
|
67
|
+
- `spec/support/shared_examples.rb` - Master loader for all shared examples
|
|
68
|
+
- `spec/integration/backend_api_compliance_spec.rb` - Integration tests using all shared examples
|
|
69
|
+
- **Parslet Backend**: New pure Ruby PEG parser backend (`TreeHaver::Backends::Parslet`)
|
|
70
|
+
- Wraps Parslet-based parsers (like the `toml` gem) to provide a pure Ruby alternative to tree-sitter
|
|
71
|
+
- `Parslet.available?` - Check if parslet gem is available
|
|
72
|
+
- `Parslet.capabilities` - Returns `{ backend: :parslet, query: false, bytes_field: true, incremental: false, pure_ruby: true }`
|
|
73
|
+
- `Parslet::Language` - Wrapper for Parslet grammar classes
|
|
74
|
+
- `Language.new(grammar_class)` - Create from a Parslet::Parser subclass
|
|
75
|
+
- `Language.from_library(path, symbol:, name:)` - API-compatible lookup via LanguageRegistry
|
|
76
|
+
- `#language_name` / `#name` - Derive language name from grammar class
|
|
77
|
+
- `Parslet::Parser` - Wrapper that creates parser instances from grammar classes
|
|
78
|
+
- Accepts both raw grammar class and Language wrapper (normalized API)
|
|
79
|
+
- `Parslet::Tree` - Wraps Parslet parse results, inherits from `Base::Tree`
|
|
80
|
+
- `Parslet::Node` - Unified node interface, inherits from `Base::Node`
|
|
81
|
+
- Supports both Hash nodes (with named children) and Array nodes (with indexed children)
|
|
82
|
+
- `#type` - Returns the node type (key name or "array"/"document")
|
|
83
|
+
- `#children` - Returns child nodes
|
|
84
|
+
- `#child_by_field_name(name)` - Access named children in Hash nodes
|
|
85
|
+
- `#text` - Returns the matched text from Parslet::Slice
|
|
86
|
+
- `#start_byte`, `#end_byte` - Byte positions from Parslet::Slice
|
|
87
|
+
- `#start_point`, `#end_point` - Line/column positions (computed from source)
|
|
88
|
+
- Registered with `BackendRegistry.register_availability_checker(:parslet)`
|
|
89
|
+
- **RSpec Dependency Tags**: Added `parslet_available?` method
|
|
90
|
+
- Checks if parslet gem is installed via `BackendRegistry.available?(:parslet)`
|
|
91
|
+
- `:parslet_backend` tag for specs requiring Parslet
|
|
92
|
+
- `:not_parslet_backend` negated tag for specs that should skip when Parslet is available
|
|
93
|
+
- **RSpec Dependency Tags**: Added `toml_gem_available?` method and updated `any_toml_backend_available?`
|
|
94
|
+
- `:toml_gem` tag for specs requiring the `toml` gem to be available
|
|
95
|
+
- `:not_toml_gem` negated tag for specs that should skip when the `toml` gem is not available
|
|
96
|
+
- **ParsletGrammarFinder**: Utility for discovering and registering Parslet grammar gems
|
|
97
|
+
- `ParsletGrammarFinder.new(language:, gem_name:, grammar_const:, require_path:)` - Find Parslet grammars
|
|
98
|
+
- `#available?` - Check if the Parslet grammar gem is installed and functional
|
|
99
|
+
- `#grammar_class` - Get the resolved Parslet::Parser subclass
|
|
100
|
+
- `#register!` - Register the grammar with TreeHaver
|
|
101
|
+
- Auto-loads via `TreeHaver::PARSLET_DEFAULTS` for known languages (toml)
|
|
102
|
+
- **TreeHaver.register_language**: Extended with `grammar_class:` parameter for Parslet grammars
|
|
103
|
+
- **TreeHaver.parser_for**: Extended with `parslet_config:` parameter for explicit Parslet configuration
|
|
104
|
+
- `MRI::Language#language_name` / `#name` - Derive language name from symbol or path
|
|
105
|
+
- `FFI::Language#language_name` / `#name` - Derive language name from symbol or path
|
|
106
|
+
- **spec_helper.rb**: Added `require "toml"` to load the toml gem for Parslet backend tests
|
|
107
|
+
|
|
108
|
+
### Changed
|
|
109
|
+
|
|
110
|
+
- **BREAKING: `TreeHaver::Language` converted from class to module**
|
|
111
|
+
- Previously `TreeHaver::Language` was a class that wrapped backend language objects
|
|
112
|
+
- Now `TreeHaver::Language` is a module providing factory methods (`method_missing` for dynamic language loading)
|
|
113
|
+
- Backend-specific language classes (e.g., `TreeHaver::Backends::MRI::Language`) are now the concrete implementations
|
|
114
|
+
- Code that instantiated `TreeHaver::Language.new(...)` directly must be updated to use backend-specific classes or the factory methods
|
|
115
|
+
- **BREAKING: `TreeHaver::Tree` now inherits from `TreeHaver::Base::Tree`**
|
|
116
|
+
- `TreeHaver::Tree` is now a proper subclass of `TreeHaver::Base::Tree`
|
|
117
|
+
- Inherits `inner_tree`, `source`, `lines` attributes from base class
|
|
118
|
+
- Base class provides default implementations; subclass documents divergence
|
|
119
|
+
- **BREAKING: `TreeHaver::Node` now inherits from `TreeHaver::Base::Node`**
|
|
120
|
+
- `TreeHaver::Node` is now a proper subclass of `TreeHaver::Base::Node`
|
|
121
|
+
- Inherits `inner_node`, `source`, `lines` attributes from base class
|
|
122
|
+
- Base class documents the API contract; subclass documents divergence
|
|
123
|
+
- **BREAKING: `Citrus::Node` and `Citrus::Tree` now inherit from Base classes**
|
|
124
|
+
- `Citrus::Node` now inherits from `TreeHaver::Base::Node`
|
|
125
|
+
- `Citrus::Tree` now inherits from `TreeHaver::Base::Tree`
|
|
126
|
+
- Removes duplicated methods, uses inherited implementations
|
|
127
|
+
- Adds `#language_name` / `#name` methods for API compliance
|
|
128
|
+
- **BREAKING: `Parslet::Node` and `Parslet::Tree` now inherit from Base classes**
|
|
129
|
+
- `Parslet::Node` now inherits from `TreeHaver::Base::Node`
|
|
130
|
+
- `Parslet::Tree` now inherits from `TreeHaver::Base::Tree`
|
|
131
|
+
- Removes duplicated methods, uses inherited implementations
|
|
132
|
+
- **Base::Node#child now returns nil for negative indices** (tree-sitter API compatibility)
|
|
133
|
+
- **Citrus::Parser#language= now accepts Language wrapper or raw grammar module**
|
|
134
|
+
- Both patterns now work: `parser.language = TomlRB::Document` or `parser.language = Citrus::Language.new(TomlRB::Document)`
|
|
135
|
+
- **Parslet::Parser#language= now accepts Language wrapper or raw grammar class**
|
|
136
|
+
- Both patterns now work: `parser.language = TOML::Parslet` or `parser.language = Parslet::Language.new(TOML::Parslet)`
|
|
137
|
+
- **TreeHaver::Parser#unwrap_language** now passes Language wrappers directly to Citrus/Parslet backends
|
|
138
|
+
- Previously unwrapped to raw grammar; now backends handle their own Language wrappers
|
|
139
|
+
- **Language.method_missing**: Now recognizes `:parslet` backend type and creates `Parslet::Language` instances
|
|
140
|
+
- **Parser**: Updated to recognize Parslet languages and switch to Parslet parser automatically
|
|
141
|
+
- `#backend` now returns `:parslet` for Parslet-based parsers
|
|
142
|
+
- `#language=` detects `Parslet::Language` and switches implementation
|
|
143
|
+
- `handle_parser_creation_failure` tries Parslet as fallback after Citrus
|
|
144
|
+
- `unwrap_language` extracts `grammar_class` for Parslet languages
|
|
145
|
+
|
|
146
|
+
### Fixed
|
|
147
|
+
|
|
148
|
+
- **FFI Backend Compliance Tests**: Fixed tests to use `TreeHaver::Parser` wrapper instead of raw `FFI::Parser`
|
|
149
|
+
- Raw FFI classes (`FFI::Tree`, `FFI::Node`) don't have full API (missing `#children`, `#text`, `#source`, etc.)
|
|
150
|
+
- TreeHaver wrapper classes (`TreeHaver::Tree`, `TreeHaver::Node`) provide the complete unified API
|
|
151
|
+
- Tests now properly test the wrapped API that users actually interact with
|
|
152
|
+
- **Parslet TOML Sources**: Fixed test sources to be valid for the `toml` gem's Parslet grammar
|
|
153
|
+
- Grammar requires table sections (not bare key-value pairs at root)
|
|
154
|
+
- Grammar requires trailing newlines
|
|
155
|
+
- **Examples**: Fixed broken markdown examples that referenced non-existent TreeHaver backends
|
|
156
|
+
- `commonmarker_markdown.rb` - Rewrote to use commonmarker gem directly (not a TreeHaver backend)
|
|
157
|
+
- `markly_markdown.rb` - Rewrote to use markly gem directly with correct `source_position` API
|
|
158
|
+
- `commonmarker_merge_example.rb` - Fixed to use `commonmarker/merge` gem properly
|
|
159
|
+
- `markly_merge_example.rb` - Fixed to use `markly/merge` gem properly
|
|
160
|
+
- `parslet_toml.rb` - Rewrote to properly use TreeHaver's Parslet backend with language registration
|
|
161
|
+
- **Examples**: Fixed `run_all.rb` test runner
|
|
162
|
+
- Added parslet example to the test list
|
|
163
|
+
- Changed markdown examples to use `backend: "standalone"` (they're not TreeHaver backends)
|
|
164
|
+
- Added MRI+TOML to known incompatibilities (parse returns nil)
|
|
165
|
+
- Added proper skip reason messages for all known incompatibilities
|
|
166
|
+
- **Examples**: Updated `examples/README.md` documentation
|
|
167
|
+
- Added Parslet backend section with usage examples
|
|
168
|
+
- Renamed "Commonmarker Backend" and "Markly Backend" to "Commonmarker (Standalone)" and "Markly (Standalone)"
|
|
169
|
+
- Clarified that commonmarker and markly are standalone parsers, not TreeHaver backends
|
|
170
|
+
- **Duplicate Constants**: Removed duplicate `CITRUS_DEFAULTS` and `PARSLET_DEFAULTS` definitions
|
|
171
|
+
- Constants were defined twice in `tree_haver.rb` (lines 170 and 315)
|
|
172
|
+
- This was causing "already initialized constant" warnings on every require
|
|
173
|
+
|
|
33
174
|
## [4.0.5] - 2026-01-09
|
|
34
175
|
|
|
35
176
|
- TAG: [v4.0.5][4.0.5t]
|
|
@@ -1070,7 +1211,9 @@ Despite the major version bump to 3.0.0 (following semver due to the breaking `L
|
|
|
1070
1211
|
|
|
1071
1212
|
- Initial release
|
|
1072
1213
|
|
|
1073
|
-
[Unreleased]: https://github.com/kettle-rb/tree_haver/compare/
|
|
1214
|
+
[Unreleased]: https://github.com/kettle-rb/tree_haver/compare/v5.0.0...HEAD
|
|
1215
|
+
[5.0.0]: https://github.com/kettle-rb/tree_haver/compare/v4.0.5...v5.0.0
|
|
1216
|
+
[5.0.0t]: https://github.com/kettle-rb/tree_haver/releases/tag/v5.0.0
|
|
1074
1217
|
[4.0.5]: https://github.com/kettle-rb/tree_haver/compare/v4.0.4...v4.0.5
|
|
1075
1218
|
[4.0.5t]: https://github.com/kettle-rb/tree_haver/releases/tag/v4.0.5
|
|
1076
1219
|
[4.0.4]: https://github.com/kettle-rb/tree_haver/compare/v4.0.3...v4.0.4
|