parsanol 1.3.4 → 1.3.7
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
- data/Cargo.lock +0 -2
- data/Rakefile +48 -48
- data/ext/parsanol_native/Cargo.toml +1 -2
- data/ext/parsanol_native/extconf.rb +4 -4
- data/lib/parsanol/ast_visitor.rb +1 -1
- data/lib/parsanol/atoms/alternative.rb +3 -2
- data/lib/parsanol/atoms/base.rb +12 -6
- data/lib/parsanol/atoms/can_flatten.rb +8 -8
- data/lib/parsanol/atoms/context.rb +23 -16
- data/lib/parsanol/atoms/custom.rb +2 -2
- data/lib/parsanol/atoms/dynamic.rb +1 -1
- data/lib/parsanol/atoms/infix.rb +10 -5
- data/lib/parsanol/atoms/lookahead.rb +7 -4
- data/lib/parsanol/atoms/re.rb +1 -1
- data/lib/parsanol/atoms/repetition.rb +29 -11
- data/lib/parsanol/atoms/sequence.rb +3 -2
- data/lib/parsanol/atoms/str.rb +9 -3
- data/lib/parsanol/atoms.rb +20 -20
- data/lib/parsanol/builder_callbacks.rb +2 -2
- data/lib/parsanol/cause.rb +2 -2
- data/lib/parsanol/context.rb +2 -2
- data/lib/parsanol/error_reporter.rb +5 -5
- data/lib/parsanol/expression/treetop.rb +17 -17
- data/lib/parsanol/expression.rb +1 -1
- data/lib/parsanol/fast_mode.rb +50 -12
- data/lib/parsanol/first_set.rb +1 -1
- data/lib/parsanol/grammar_builder.rb +10 -8
- data/lib/parsanol/incremental_parser.rb +13 -8
- data/lib/parsanol/interval_tree.rb +12 -3
- data/lib/parsanol/lazy_result.rb +2 -2
- data/lib/parsanol/mermaid.rb +12 -9
- data/lib/parsanol/native/batch_decoder.rb +13 -9
- data/lib/parsanol/native/dynamic.rb +7 -6
- data/lib/parsanol/native/parser.rb +12 -4
- data/lib/parsanol/native/serializer.rb +42 -42
- data/lib/parsanol/native/transformer.rb +55 -28
- data/lib/parsanol/native/types.rb +3 -3
- data/lib/parsanol/native.rb +60 -21
- data/lib/parsanol/optimizer.rb +6 -6
- data/lib/parsanol/optimizers/choice_optimizer.rb +1 -1
- data/lib/parsanol/optimizers/cut_inserter.rb +5 -2
- data/lib/parsanol/optimizers/lookahead_optimizer.rb +9 -3
- data/lib/parsanol/optimizers/quantifier_optimizer.rb +5 -5
- data/lib/parsanol/optimizers/sequence_optimizer.rb +1 -1
- data/lib/parsanol/options/zero_copy.rb +1 -1
- data/lib/parsanol/options.rb +1 -1
- data/lib/parsanol/parallel.rb +8 -13
- data/lib/parsanol/parser.rb +51 -13
- data/lib/parsanol/parslet.rb +7 -7
- data/lib/parsanol/pattern/binding.rb +1 -1
- data/lib/parsanol/pattern.rb +4 -1
- data/lib/parsanol/pool.rb +3 -3
- data/lib/parsanol/pools/buffer_pool.rb +2 -2
- data/lib/parsanol/pools/position_pool.rb +2 -2
- data/lib/parsanol/position.rb +1 -1
- data/lib/parsanol/result_builder.rb +4 -4
- data/lib/parsanol/result_stream.rb +10 -5
- data/lib/parsanol/slice.rb +11 -8
- data/lib/parsanol/source.rb +14 -9
- data/lib/parsanol/source_location.rb +1 -1
- data/lib/parsanol/streaming_parser.rb +3 -3
- data/lib/parsanol/string_view.rb +4 -1
- data/lib/parsanol/transform.rb +2 -2
- data/lib/parsanol/version.rb +1 -1
- data/lib/parsanol/wasm_parser.rb +1 -1
- data/lib/parsanol.rb +37 -39
- data/parsanol.gemspec +30 -30
- metadata +1 -1
data/lib/parsanol/parslet.rb
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
# class MyParser < Parsanol::Parslet::Parser
|
|
36
36
|
# include Parsanol::Parslet
|
|
37
37
|
|
|
38
|
-
require
|
|
38
|
+
require "parsanol"
|
|
39
39
|
|
|
40
40
|
module Parsanol
|
|
41
41
|
module Parslet
|
|
@@ -90,16 +90,16 @@ module Parsanol
|
|
|
90
90
|
Parsanol.any
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
def scope(&
|
|
94
|
-
Parsanol.scope(&
|
|
93
|
+
def scope(&)
|
|
94
|
+
Parsanol.scope(&)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
def dynamic(&
|
|
98
|
-
Parsanol.dynamic(&
|
|
97
|
+
def dynamic(&)
|
|
98
|
+
Parsanol.dynamic(&)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
def infix_expression(element, *operations, &
|
|
102
|
-
Parsanol.infix_expression(element, *operations, &
|
|
101
|
+
def infix_expression(element, *operations, &)
|
|
102
|
+
Parsanol.infix_expression(element, *operations, &)
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
# Parses a treetop-style expression string and returns the corresponding atom.
|
data/lib/parsanol/pattern.rb
CHANGED
|
@@ -51,7 +51,10 @@ module Parsanol
|
|
|
51
51
|
#
|
|
52
52
|
def match(subtree, bindings = nil)
|
|
53
53
|
current_bindings = bindings ? bindings.dup : {}
|
|
54
|
-
check_match(subtree, @pattern_def,
|
|
54
|
+
if check_match(subtree, @pattern_def,
|
|
55
|
+
current_bindings)
|
|
56
|
+
current_bindings
|
|
57
|
+
end
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
private
|
data/lib/parsanol/pool.rb
CHANGED
|
@@ -67,7 +67,7 @@ module Parsanol
|
|
|
67
67
|
created: 0,
|
|
68
68
|
reused: 0,
|
|
69
69
|
released: 0,
|
|
70
|
-
discarded: 0
|
|
70
|
+
discarded: 0,
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
# Pre-allocate objects for efficiency if requested
|
|
@@ -154,7 +154,7 @@ module Parsanol
|
|
|
154
154
|
reused: @stats[:reused],
|
|
155
155
|
released: @stats[:released],
|
|
156
156
|
discarded: @stats[:discarded],
|
|
157
|
-
utilization: utilization.round(2)
|
|
157
|
+
utilization: utilization.round(2),
|
|
158
158
|
}
|
|
159
159
|
end
|
|
160
160
|
|
|
@@ -174,7 +174,7 @@ module Parsanol
|
|
|
174
174
|
created: 0,
|
|
175
175
|
reused: 0,
|
|
176
176
|
released: 0,
|
|
177
|
-
discarded: 0
|
|
177
|
+
discarded: 0,
|
|
178
178
|
}
|
|
179
179
|
end
|
|
180
180
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative "../buffer"
|
|
4
4
|
|
|
5
5
|
module Parsanol
|
|
6
6
|
module Pools
|
|
@@ -124,7 +124,7 @@ module Parsanol
|
|
|
124
124
|
reused: stats[:reused],
|
|
125
125
|
released: stats[:released],
|
|
126
126
|
discarded: stats[:discarded],
|
|
127
|
-
utilization: utilization.round(2)
|
|
127
|
+
utilization: utilization.round(2),
|
|
128
128
|
}
|
|
129
129
|
end
|
|
130
130
|
result
|
|
@@ -48,7 +48,7 @@ module Parsanol
|
|
|
48
48
|
if @available.empty?
|
|
49
49
|
@stats[:created] += 1
|
|
50
50
|
# Create Position with default values since it requires arguments
|
|
51
|
-
Parsanol::Position.new(
|
|
51
|
+
Parsanol::Position.new("", 0, 0)
|
|
52
52
|
else
|
|
53
53
|
@stats[:reused] += 1
|
|
54
54
|
@available.pop
|
|
@@ -81,7 +81,7 @@ module Parsanol
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
# Reset position state with default values before returning to pool
|
|
84
|
-
pos.reset!(
|
|
84
|
+
pos.reset!("", 0, 0)
|
|
85
85
|
|
|
86
86
|
@stats[:released] += 1
|
|
87
87
|
@available.push(pos)
|
data/lib/parsanol/position.rb
CHANGED
|
@@ -45,7 +45,7 @@ module Parsanol
|
|
|
45
45
|
|
|
46
46
|
def calculate_charpos
|
|
47
47
|
# Calculate it based on platform
|
|
48
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE ==
|
|
48
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "opal"
|
|
49
49
|
# In Opal, convert byte position to character position.
|
|
50
50
|
# We need to calculate how many characters occupy the first @bytepos bytes.
|
|
51
51
|
`
|
|
@@ -27,14 +27,14 @@ module Parsanol
|
|
|
27
27
|
# @param options [Hash] Builder options
|
|
28
28
|
# @return [ResultBuilder] Appropriate builder instance
|
|
29
29
|
#
|
|
30
|
-
def self.for(type, context, **
|
|
30
|
+
def self.for(type, context, **)
|
|
31
31
|
case type
|
|
32
32
|
when :repetition
|
|
33
|
-
RepetitionBuilder.new(context, **
|
|
33
|
+
RepetitionBuilder.new(context, **)
|
|
34
34
|
when :sequence
|
|
35
|
-
SequenceBuilder.new(context, **
|
|
35
|
+
SequenceBuilder.new(context, **)
|
|
36
36
|
when :hash
|
|
37
|
-
HashBuilder.new(context, **
|
|
37
|
+
HashBuilder.new(context, **)
|
|
38
38
|
else
|
|
39
39
|
raise ArgumentError, "Unknown builder type: #{type}"
|
|
40
40
|
end
|
|
@@ -86,10 +86,10 @@ module Parsanol
|
|
|
86
86
|
# enum = stream.each # Returns Enumerator
|
|
87
87
|
# enum.next # Get next node
|
|
88
88
|
#
|
|
89
|
-
def each(&
|
|
89
|
+
def each(&)
|
|
90
90
|
return enum_for(:each) unless block_given?
|
|
91
91
|
|
|
92
|
-
traverse(@tree, &
|
|
92
|
+
traverse(@tree, &)
|
|
93
93
|
self
|
|
94
94
|
end
|
|
95
95
|
|
|
@@ -206,7 +206,10 @@ module Parsanol
|
|
|
206
206
|
# @return [Enumerator]
|
|
207
207
|
#
|
|
208
208
|
def depth_traverse(node, current_depth, target_depth, &block)
|
|
209
|
-
|
|
209
|
+
unless block
|
|
210
|
+
return enum_for(:depth_traverse, node, current_depth,
|
|
211
|
+
target_depth)
|
|
212
|
+
end
|
|
210
213
|
|
|
211
214
|
# Check if we're at target depth
|
|
212
215
|
return [node].to_enum if current_depth == target_depth && yield(node)
|
|
@@ -217,13 +220,15 @@ module Parsanol
|
|
|
217
220
|
case node
|
|
218
221
|
when Array
|
|
219
222
|
node.each do |item|
|
|
220
|
-
depth_traverse(item, current_depth + 1, target_depth,
|
|
223
|
+
depth_traverse(item, current_depth + 1, target_depth,
|
|
224
|
+
&block).each do |result|
|
|
221
225
|
results << result
|
|
222
226
|
end
|
|
223
227
|
end
|
|
224
228
|
when Hash
|
|
225
229
|
node.each_value do |value|
|
|
226
|
-
depth_traverse(value, current_depth + 1, target_depth,
|
|
230
|
+
depth_traverse(value, current_depth + 1, target_depth,
|
|
231
|
+
&block).each do |result|
|
|
227
232
|
results << result
|
|
228
233
|
end
|
|
229
234
|
end
|
data/lib/parsanol/slice.rb
CHANGED
|
@@ -12,14 +12,14 @@ module Parsanol
|
|
|
12
12
|
|
|
13
13
|
attr_reader :content, :input
|
|
14
14
|
|
|
15
|
-
def initialize(byte_offset = 0, string_content =
|
|
15
|
+
def initialize(byte_offset = 0, string_content = "", input = nil)
|
|
16
16
|
@byte_position = byte_offset
|
|
17
17
|
@content = string_content
|
|
18
18
|
@input = input
|
|
19
19
|
@line_and_column = nil
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def reset!(new_offset = 0, new_content =
|
|
22
|
+
def reset!(new_offset = 0, new_content = "", new_input = nil)
|
|
23
23
|
@byte_position = new_offset
|
|
24
24
|
@content = new_content
|
|
25
25
|
@input = new_input
|
|
@@ -44,6 +44,7 @@ module Parsanol
|
|
|
44
44
|
def ==(other)
|
|
45
45
|
return content == other if other.is_a?(String)
|
|
46
46
|
return content == other.content if other.is_a?(Parsanol::Slice)
|
|
47
|
+
|
|
47
48
|
content == other
|
|
48
49
|
end
|
|
49
50
|
|
|
@@ -72,7 +73,8 @@ module Parsanol
|
|
|
72
73
|
|
|
73
74
|
# Lazy line/column — computed once and cached.
|
|
74
75
|
def line_and_column
|
|
75
|
-
raise ArgumentError,
|
|
76
|
+
raise ArgumentError, "Line/column requires input" unless @input
|
|
77
|
+
|
|
76
78
|
@line_and_column ||= compute_line_and_column
|
|
77
79
|
end
|
|
78
80
|
|
|
@@ -109,11 +111,11 @@ module Parsanol
|
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
def as_json(_options = {})
|
|
112
|
-
result = {
|
|
114
|
+
result = { "value" => content, "offset" => offset, "length" => length }
|
|
113
115
|
if @input
|
|
114
116
|
line, column = line_and_column
|
|
115
|
-
result[
|
|
116
|
-
result[
|
|
117
|
+
result["line"] = line
|
|
118
|
+
result["column"] = column
|
|
117
119
|
end
|
|
118
120
|
result
|
|
119
121
|
end
|
|
@@ -123,7 +125,8 @@ module Parsanol
|
|
|
123
125
|
line, column = line_and_column
|
|
124
126
|
end_line, end_column = line_and_column_at(offset + length)
|
|
125
127
|
start_pos = SourcePosition.new(offset: offset, line: line, column: column)
|
|
126
|
-
end_pos = SourcePosition.new(offset: offset + length, line: end_line,
|
|
128
|
+
end_pos = SourcePosition.new(offset: offset + length, line: end_line,
|
|
129
|
+
column: end_column)
|
|
127
130
|
SourceSpan.new(start_pos: start_pos, end_pos: end_pos)
|
|
128
131
|
end
|
|
129
132
|
|
|
@@ -142,7 +145,7 @@ module Parsanol
|
|
|
142
145
|
@input.line_and_column(pos)
|
|
143
146
|
else
|
|
144
147
|
# String input
|
|
145
|
-
prefix = @input.byteslice(0, pos) ||
|
|
148
|
+
prefix = @input.byteslice(0, pos) || ""
|
|
146
149
|
line = 1 + prefix.count("\n")
|
|
147
150
|
last_nl = prefix.rindex("\n")
|
|
148
151
|
column = last_nl ? pos - last_nl : pos + 1
|
data/lib/parsanol/source.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "stringio"
|
|
4
|
+
require "strscan"
|
|
5
5
|
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
6
|
+
require "parsanol/position"
|
|
7
|
+
require "parsanol/source/line_cache"
|
|
8
|
+
require "parsanol/pools/slice_pool"
|
|
9
|
+
require "parsanol/pools/position_pool"
|
|
10
10
|
|
|
11
11
|
module Parsanol
|
|
12
12
|
# Encapsulates input source for parsing operations. Provides position tracking,
|
|
@@ -33,14 +33,19 @@ module Parsanol
|
|
|
33
33
|
# @raise [ArgumentError] if input doesn't respond to to_str
|
|
34
34
|
#
|
|
35
35
|
def initialize(input)
|
|
36
|
-
|
|
36
|
+
unless input.respond_to?(:to_str)
|
|
37
|
+
raise ArgumentError,
|
|
38
|
+
"Source requires a string-like object (responds to to_str)"
|
|
39
|
+
end
|
|
37
40
|
|
|
38
41
|
# Core scanner for input traversal
|
|
39
42
|
@scanner = StringScanner.new(input)
|
|
40
43
|
@raw_string = input.to_str
|
|
41
44
|
|
|
42
45
|
# Regex cache: maps count n to /(.|$){n}/m pattern
|
|
43
|
-
@regex_cache = Hash.new
|
|
46
|
+
@regex_cache = Hash.new do |h, count|
|
|
47
|
+
h[count] = Regexp.new("(.|$){#{count}}", Regexp::MULTILINE)
|
|
48
|
+
end
|
|
44
49
|
|
|
45
50
|
# Line ending cache for position-to-line/column mapping
|
|
46
51
|
@line_data = LineCache.new
|
|
@@ -173,7 +178,7 @@ module Parsanol
|
|
|
173
178
|
@position_pool.acquire_with(
|
|
174
179
|
string: @raw_string,
|
|
175
180
|
bytepos: effective,
|
|
176
|
-
charpos: char_pos
|
|
181
|
+
charpos: char_pos,
|
|
177
182
|
)
|
|
178
183
|
end
|
|
179
184
|
end
|
|
@@ -37,7 +37,7 @@ module Parsanol
|
|
|
37
37
|
@native_parser = nil
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
@buffer =
|
|
40
|
+
@buffer = +""
|
|
41
41
|
@position = 0
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -65,7 +65,7 @@ module Parsanol
|
|
|
65
65
|
else
|
|
66
66
|
# Pure Ruby fallback - not supported
|
|
67
67
|
raise NotImplementedError,
|
|
68
|
-
|
|
68
|
+
"Streaming parser requires native extension for full functionality."
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -106,7 +106,7 @@ module Parsanol
|
|
|
106
106
|
|
|
107
107
|
# Reset the parser for reuse
|
|
108
108
|
def reset
|
|
109
|
-
@buffer =
|
|
109
|
+
@buffer = +""
|
|
110
110
|
@position = 0
|
|
111
111
|
|
|
112
112
|
return unless @native_parser
|
data/lib/parsanol/string_view.rb
CHANGED
|
@@ -146,7 +146,10 @@ module Parsanol
|
|
|
146
146
|
#
|
|
147
147
|
def slice(start, len)
|
|
148
148
|
# Handle edge cases
|
|
149
|
-
|
|
149
|
+
if len <= 0 || start >= @length
|
|
150
|
+
return self.class.new(@string, offset: @offset,
|
|
151
|
+
length: 0)
|
|
152
|
+
end
|
|
150
153
|
|
|
151
154
|
# Clamp start to valid range [0, @length)
|
|
152
155
|
clamped_start = [[start, 0].max, @length].min
|
data/lib/parsanol/transform.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "parsanol/pattern"
|
|
4
4
|
|
|
5
5
|
# Tree transformation engine for converting parse trees into abstract syntax trees.
|
|
6
6
|
#
|
|
@@ -223,4 +223,4 @@ module Parsanol
|
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
-
require
|
|
226
|
+
require "parsanol/context"
|
data/lib/parsanol/version.rb
CHANGED
data/lib/parsanol/wasm_parser.rb
CHANGED
data/lib/parsanol.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'set'
|
|
4
|
-
|
|
5
3
|
# Parsanol - A high-performance PEG parser construction library for Ruby.
|
|
6
4
|
#
|
|
7
5
|
# Typical usage:
|
|
@@ -148,7 +146,7 @@ module Parsanol
|
|
|
148
146
|
#
|
|
149
147
|
# @return [Parsanol::Atoms::Re] regex atom matching '.'
|
|
150
148
|
def any
|
|
151
|
-
Atoms::Re.new(
|
|
149
|
+
Atoms::Re.new(".")
|
|
152
150
|
end
|
|
153
151
|
module_function :any
|
|
154
152
|
|
|
@@ -179,8 +177,8 @@ module Parsanol
|
|
|
179
177
|
# @param operators [Array<Array>] operator definitions
|
|
180
178
|
# @yield optional block to customize result tree structure
|
|
181
179
|
# @return [Parsanol::Atoms::Infix] infix parser
|
|
182
|
-
def infix_expression(operand, *operators, &
|
|
183
|
-
Atoms::Infix.new(operand, operators, &
|
|
180
|
+
def infix_expression(operand, *operators, &)
|
|
181
|
+
Atoms::Infix.new(operand, operators, &)
|
|
184
182
|
end
|
|
185
183
|
module_function :infix_expression
|
|
186
184
|
|
|
@@ -237,44 +235,44 @@ module Parsanol
|
|
|
237
235
|
end
|
|
238
236
|
module_function :exp
|
|
239
237
|
|
|
240
|
-
autoload :Expression,
|
|
238
|
+
autoload :Expression, "parsanol/expression"
|
|
241
239
|
end
|
|
242
240
|
|
|
243
|
-
require
|
|
244
|
-
require
|
|
245
|
-
require
|
|
246
|
-
require
|
|
247
|
-
require
|
|
248
|
-
require
|
|
249
|
-
require
|
|
250
|
-
require
|
|
251
|
-
require
|
|
252
|
-
require
|
|
253
|
-
require
|
|
254
|
-
require
|
|
255
|
-
require
|
|
256
|
-
require
|
|
257
|
-
require
|
|
258
|
-
require
|
|
259
|
-
require
|
|
260
|
-
require
|
|
261
|
-
require
|
|
262
|
-
require
|
|
263
|
-
require
|
|
264
|
-
require
|
|
265
|
-
require
|
|
266
|
-
require
|
|
267
|
-
require
|
|
268
|
-
require
|
|
269
|
-
require
|
|
241
|
+
require "parsanol/version"
|
|
242
|
+
require "parsanol/resettable"
|
|
243
|
+
require "parsanol/result"
|
|
244
|
+
require "parsanol/slice"
|
|
245
|
+
require "parsanol/string_view"
|
|
246
|
+
require "parsanol/rope"
|
|
247
|
+
require "parsanol/pool"
|
|
248
|
+
require "parsanol/pools/slice_pool"
|
|
249
|
+
require "parsanol/pools/array_pool"
|
|
250
|
+
require "parsanol/pools/position_pool"
|
|
251
|
+
require "parsanol/buffer"
|
|
252
|
+
require "parsanol/pools/buffer_pool"
|
|
253
|
+
require "parsanol/lazy_result"
|
|
254
|
+
require "parsanol/result_builder"
|
|
255
|
+
require "parsanol/first_set"
|
|
256
|
+
require "parsanol/cause"
|
|
257
|
+
require "parsanol/source"
|
|
258
|
+
require "parsanol/atoms"
|
|
259
|
+
require "parsanol/pattern"
|
|
260
|
+
require "parsanol/pattern/binding"
|
|
261
|
+
require "parsanol/transform"
|
|
262
|
+
require "parsanol/parser"
|
|
263
|
+
require "parsanol/error_reporter"
|
|
264
|
+
require "parsanol/scope"
|
|
265
|
+
require "parsanol/optimizer"
|
|
266
|
+
require "parsanol/options"
|
|
267
|
+
require "parsanol/native"
|
|
270
268
|
|
|
271
269
|
# New features (require native extension for full functionality)
|
|
272
|
-
require
|
|
273
|
-
require
|
|
274
|
-
require
|
|
275
|
-
require
|
|
276
|
-
require
|
|
277
|
-
require
|
|
270
|
+
require "parsanol/source_location"
|
|
271
|
+
require "parsanol/grammar_builder"
|
|
272
|
+
require "parsanol/streaming_parser"
|
|
273
|
+
require "parsanol/incremental_parser"
|
|
274
|
+
require "parsanol/builder_callbacks"
|
|
275
|
+
require "parsanol/parallel"
|
|
278
276
|
|
|
279
277
|
# Add GrammarBuilder DSL to Parsanol module
|
|
280
278
|
Parsanol.extend(Parsanol::GrammarBuilderDSL)
|
data/parsanol.gemspec
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative "lib/parsanol/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
6
|
+
spec.name = "parsanol"
|
|
7
7
|
spec.version = Parsanol::VERSION
|
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
|
9
9
|
|
|
10
|
-
spec.authors = [
|
|
11
|
-
spec.email = [
|
|
10
|
+
spec.authors = ["Ribose Inc."]
|
|
11
|
+
spec.email = ["open.source@ribose.com"]
|
|
12
12
|
|
|
13
|
-
spec.summary =
|
|
14
|
-
spec.description =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
spec.homepage =
|
|
18
|
-
spec.license =
|
|
13
|
+
spec.summary = "Parser construction library with great error reporting in Ruby."
|
|
14
|
+
spec.description = "A small Ruby library for constructing parsers in the PEG (Parsing Expression Grammar) fashion. " \
|
|
15
|
+
"Parsanol provides Parslet-compatible API with additional features including " \
|
|
16
|
+
"static frozen parsers and dynamic parsers, with optional Rust native extension for improved performance."
|
|
17
|
+
spec.homepage = "https://github.com/parsanol/parsanol-ruby"
|
|
18
|
+
spec.license = "MIT"
|
|
19
19
|
|
|
20
20
|
spec.metadata = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
"bug_tracker_uri" => "https://github.com/parsanol/parsanol-ruby/issues",
|
|
22
|
+
"changelog_uri" => "https://github.com/parsanol/parsanol-ruby/blob/main/HISTORY.txt",
|
|
23
|
+
"documentation_uri" => "https://parsanol.github.io/parsanol-ruby/",
|
|
24
|
+
"homepage_uri" => "https://github.com/parsanol/parsanol-ruby",
|
|
25
|
+
"source_code_uri" => "https://github.com/parsanol/parsanol-ruby",
|
|
26
|
+
"rubygems_mfa_required" => "true",
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
# Rust extension
|
|
30
|
-
spec.extensions = [
|
|
30
|
+
spec.extensions = ["ext/parsanol_native/extconf.rb"]
|
|
31
31
|
|
|
32
|
-
spec.files = Dir.glob(
|
|
32
|
+
spec.files = Dir.glob("{lib,ext}/**/*") + %w[
|
|
33
33
|
HISTORY.txt
|
|
34
34
|
LICENSE
|
|
35
35
|
Rakefile
|
|
@@ -40,28 +40,28 @@ Gem::Specification.new do |spec|
|
|
|
40
40
|
]
|
|
41
41
|
spec.files.reject! { |f| File.directory?(f) }
|
|
42
42
|
spec.files.reject! { |f| f =~ /\.(dll|so|dylib|lib|bundle)\Z/ }
|
|
43
|
-
spec.require_paths = [
|
|
43
|
+
spec.require_paths = ["lib"]
|
|
44
44
|
|
|
45
|
-
spec.required_ruby_version =
|
|
45
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
46
46
|
|
|
47
47
|
# Required for Rust extension
|
|
48
|
-
spec.add_dependency
|
|
48
|
+
spec.add_dependency "rb_sys", "~> 0.9.39"
|
|
49
49
|
|
|
50
|
-
spec.add_development_dependency
|
|
51
|
-
spec.add_development_dependency
|
|
52
|
-
spec.add_development_dependency
|
|
53
|
-
spec.add_development_dependency
|
|
50
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
51
|
+
spec.add_development_dependency "rake-compiler", "~> 1.2.0"
|
|
52
|
+
spec.add_development_dependency "rdoc", "~> 6.0"
|
|
53
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
54
54
|
|
|
55
55
|
# For code style checking
|
|
56
|
-
spec.add_development_dependency
|
|
56
|
+
spec.add_development_dependency "rubocop", "~> 1.0"
|
|
57
57
|
|
|
58
58
|
# For Parslet compatibility verification
|
|
59
|
-
spec.add_development_dependency
|
|
59
|
+
spec.add_development_dependency "parslet", "~> 2.0.0"
|
|
60
60
|
|
|
61
61
|
# For benchmarking
|
|
62
|
-
spec.add_development_dependency
|
|
62
|
+
spec.add_development_dependency "benchmark-ips", "~> 2.0"
|
|
63
63
|
|
|
64
64
|
# For type checking
|
|
65
|
-
spec.add_development_dependency
|
|
66
|
-
spec.add_development_dependency
|
|
65
|
+
spec.add_development_dependency "rbs", "~> 3.0"
|
|
66
|
+
spec.add_development_dependency "steep", "~> 1.0"
|
|
67
67
|
end
|