parsanol 1.3.75-arm-linux → 1.3.77-arm-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4199b78dc8200a8a90795c96bace54501aadb60429056af97862088d582940f5
4
- data.tar.gz: fa8a6a0f2517ea649f9a958ab359ffc6b631074a771f8664d4b1d02ee9c2fa9d
3
+ metadata.gz: 429a4964c85119a64fcbe26e965c0dbb72832243656dcf7adac52af44467123a
4
+ data.tar.gz: e2d9c235c40b39db79f63b3d4f7197bff1dcf396e9c40f304bea267f1ba55b0d
5
5
  SHA512:
6
- metadata.gz: 660a66463a938caf83903dd6478fc855bccc58897ef03620e53298844424cc88ba52f2a2c0fcf11223d7ae5315a1e284f36d73dc0b8d895e6b185801dd18cec8
7
- data.tar.gz: bf43ca3a6d4f8cb67251a2476e4bc89766f9c0b4bc3c39b5cf68289f4163156a9a47754857745f278c85258c8d281dab79bc14c760183c0b3b17586621d8c3dc
6
+ metadata.gz: 855ae1e5ecf70b2e91c77891cf11716c29c9b5ca72ba9493fa59a817e201859a83558b3a6a4bf7813d312456fc489ca15dd59c0995e16635e37bcdaa0e3c26e3
7
+ data.tar.gz: 7b16e9e544408a33a7d7e404b15e2e22b28bfce59b3bd2960f9d6483c42220e25f5f7eb9f2cf72e09a38ebaf289ffa42e654c5aa66104e4ec422c10396f9f064
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: data/lib/parsanol/3.2/parsanol_native.so
3
- size: 33677020 bytes
4
- sha256: 3928db2c191454008cb6054fd30c18c7da73f3005f6c28852ad019ae40af4851
3
+ size: 33849188 bytes
4
+ sha256: ca4c41aa664d038aef54496b5ef3d0e1607614ed2a0fb6dee25d8b70d3d2623c
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: data/lib/parsanol/3.3/parsanol_native.so
3
- size: 33862268 bytes
4
- sha256: d8a313f69bd1b9fe076be6bf20b3daf2e5a1f0a15b8eca6543e278889b9685be
3
+ size: 34034452 bytes
4
+ sha256: d3660cf198539d8155431a55aa11a704a21221300a20efe1fec7d80aa7886bc8
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: data/lib/parsanol/3.4/parsanol_native.so
3
- size: 33855352 bytes
4
- sha256: 393be5df0133e67a220b9ac363d4f2a7f97516c474330f72db3c3abd387897dc
3
+ size: 34027504 bytes
4
+ sha256: 33690f49159bf260583a614afe9d117c646c9fd4bca01f1771ffda635be5dfb5
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: data/lib/parsanol/4.0/parsanol_native.so
3
- size: 33865024 bytes
4
- sha256: a19f585f819cd3c94bf5fb6ba44e1c96a260509df5322e0000689cbf0894e449
3
+ size: 34037320 bytes
4
+ sha256: 026dbe46af30ab84933b280727354c32308c8cdcdb2c77d2fc8501092b0f4c57
@@ -2,30 +2,60 @@
2
2
 
3
3
  module Parsanol
4
4
  module Atoms
5
- # Inspects the byte window behind the current position: the
6
- # previous +count+ bytes must equal +pattern+ (positive) or
7
- # differ (negative). Consumes nothing, yields nil — the
8
- # precedes?/does_not_precede? guard shape (coradoc-markdown
9
- # parity, rs#137 follow-up).
5
+ # Inspects the text behind the current position and consumes
6
+ # nothing, yielding nil.
7
+ #
8
+ # Two forms (rs#137/#163):
9
+ # - Literal: the previous +count+ bytes must equal +pattern+
10
+ # (the precedes?/does_not_precede? fixed-window guard).
11
+ # - Regex: +source+ is searched in the preceding text and must
12
+ # end at the position — the CommonMark flanking form, which is
13
+ # class-based, multibyte and variable-length.
10
14
  class Lookbehind < Base
11
- attr_reader :count, :pattern, :positive
15
+ attr_reader :count, :pattern, :regex_source, :positive
12
16
 
13
17
  def initialize(count, pattern, positive: true)
14
18
  super()
15
19
  @count = count
16
20
  @pattern = pattern
21
+ @regex_source = nil
22
+ @compiled = nil
17
23
  @positive = positive
18
24
  end
19
25
 
26
+ # Class-based flanking guard: +source+ must match the text
27
+ # ending at the position.
28
+ def self.regex(source, positive: true)
29
+ atom = new(0, "", positive: positive)
30
+ atom.instance_variable_set(:@regex_source, source)
31
+ atom
32
+ end
33
+
34
+ def regex?
35
+ !@regex_source.nil?
36
+ end
37
+
20
38
  def try(source, _context, _consume_all)
21
39
  start = source.bytepos
22
- behind = start >= @count ? source.input.byteslice(start - @count, @count) : nil
23
- matched = !behind.nil? && behind == @pattern.b
40
+ if regex?
41
+ @compiled ||= Regexp.new("(?:#{@regex_source})\\z")
42
+ matched = @compiled.match?(source.input.byteslice(0, start))
43
+ else
44
+ behind =
45
+ if start >= @count
46
+ source.input.byteslice(start - @count, @count)
47
+ end
48
+ matched = !behind.nil? && behind == @pattern.b
49
+ end
24
50
  [matched == @positive, nil]
25
51
  end
26
52
 
27
53
  def to_s_inner(_prec)
28
- "lookbehind(#{@count}, #{@pattern.inspect}, #{@positive ? '+' : '-'})"
54
+ if regex?
55
+ "lookbehind(/#{@regex_source}/, #{@positive ? '+' : '-'})"
56
+ else
57
+ "lookbehind(#{@count}, #{@pattern.inspect}, #{@positive ? '+' : '-'})"
58
+ end
29
59
  end
30
60
  end
31
61
  end
Binary file
@@ -103,15 +103,17 @@ module Parsanol
103
103
  # atoms — empty match yielding a wire constant.
104
104
  { "Constant" => { "value" => serialize_constant_value(atom.value) } }
105
105
  when Parsanol::Atoms::Lookbehind
106
- # rs#137 follow-up: the precedes?/does_not_precede?
107
- # guards — inspect the bytes behind the position.
108
- {
109
- "Lookbehind" => {
110
- "count" => atom.count,
111
- "pattern" => atom.pattern,
112
- "positive" => atom.positive,
113
- },
114
- }
106
+ # rs#137/#163: the behind-window test — a fixed
107
+ # literal window or an end-anchored regex (the
108
+ # CommonMark flanking form).
109
+ look = if atom.regex?
110
+ { "Regex" => { "source" => atom.regex_source } }
111
+ else
112
+ { "Literal" => { "count" => atom.count,
113
+ "pattern" => atom.pattern } }
114
+ end
115
+ { "Lookbehind" => { "look" => look,
116
+ "positive" => atom.positive } }
115
117
  when Parsanol::Atoms::Ignored
116
118
  serialize_ignored(atom)
117
119
  else
@@ -65,8 +65,16 @@ module Parsanol
65
65
  def parse(entry_name, input, mode: :native)
66
66
  case mode
67
67
  when :native
68
- if !envelope["dynamic"] && Native.available?
69
- return Native.parse(JSON.generate(entry(entry_name).fetch("grammar")), input)
68
+ if Native.available? && !envelope["dynamic"]
69
+ # Fast lane (parsanol-ruby#162): the per-instance atom
70
+ # tree rides the DSL serialization/registration caches
71
+ # (GRAMMAR_CACHE / HANDLE_CACHE keyed on the stable root
72
+ # atom), so an artifact parses at compiled speed after
73
+ # the first call. The old path re-serialized the whole
74
+ # grammar JSON and re-registered it per parse (~8x).
75
+ # Dynamic artifacts carry ruby-tier atoms their wire
76
+ # cannot express — they keep the interpreter.
77
+ return root_atom(entry_name).parse(input, mode: :native)
70
78
  end
71
79
 
72
80
  root_atom(entry_name).parse(input)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.75"
4
+ VERSION = "1.3.77"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsanol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.75
4
+ version: 1.3.77
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.