tdparser 1.5.0 → 1.5.1

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: 0b0d873d5eee490ac295ad3a31d7df50c8477335aeac7f94d1614e429de40b05
4
- data.tar.gz: 4e247c68e1d59d4931d97a32990cda0f0d708a291d09a50ba4b8ac0dffb777d1
3
+ metadata.gz: 25d5372580072f4703947c061df7b6d2cb5f85c3c073ef130747f211671a04e4
4
+ data.tar.gz: 94d335eb747dfe643cc5e488c15b22cc0bd3936bf2a76ed2bbec9008e30e2c6f
5
5
  SHA512:
6
- metadata.gz: 80fd063170357063e7c2bc1ad0479246cd3ffd85b5f08586403b7523f42dc2d974d21f9f398d71553bc2848f9bc425461e1cf1696dfdf218e87e2aae26ef38fc
7
- data.tar.gz: dbecb62bcc8104bc21fa5c08dd6bd6896c6430d473617f0b171df379e707939d0266718abaa8271cfda7244ac8a7fda1586a64e0b5ea2216c02cb0c0858e1bce
6
+ metadata.gz: 48e4f42bb49c592021fd4fb4455a5120a8087f639ab9f21cf2986d90a2d0f87b1f108bd6315197934769f738064828e372b10ea1dba2495266486c58a5f56dff
7
+ data.tar.gz: 34cf78b68bf980d9814f1b02ba6bfbe3b9a8a9167bb6b84d8d0a598b060f496d9805a5eca42314fb3c66fcd70b0ceb0cbfd409273f445ffcf3750e99a8c88e71
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## 1.5.1 - 2024-11-10
4
+
5
+ This is a maintenance release, no user facing changes.
6
+
7
+ * Lint codes: remove unused local variables.
8
+ * Use the string scanner's eos check method instead of the empty check one.
9
+ * Simplify grammar class implementation.
10
+ * Add links about this gem.
11
+
3
12
  ## [1.5.0] - 2024-11-08
4
13
 
5
14
  * Support Ruby 3.1 or later.
@@ -41,7 +41,7 @@ module TDParser
41
41
  def generate(str)
42
42
  scanner = StringScanner.new(str)
43
43
  TDParser::TokenGenerator.new do |x|
44
- until scanner.empty?
44
+ until scanner.eos?
45
45
  if @ignore_pattern
46
46
  while scanner.scan(@ignore_pattern)
47
47
  end
@@ -52,7 +52,6 @@ module TDParser
52
52
  next unless reg =~ sstr
53
53
 
54
54
  x.yield(Token.new(kind, sstr))
55
- yielded = true
56
55
  break
57
56
  end
58
57
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TDParser
4
- VERSION = '1.5.0'
4
+ VERSION = '1.5.1'
5
5
  end
data/lib/tdparser.rb CHANGED
@@ -455,7 +455,7 @@ module TDParser
455
455
  if act1
456
456
  r = if act2
457
457
  r >> proc do |x|
458
- y0, y1, *ys = x.pop
458
+ y0, y1, *_ = x.pop
459
459
  if y0
460
460
  act1.call(x.push(*y0))
461
461
  else
@@ -464,13 +464,13 @@ module TDParser
464
464
  end
465
465
  else
466
466
  r >> proc do |x|
467
- y0, y1, *ys = x.pop
467
+ y0, = x.pop
468
468
  act1.call(x.push(*y0)) if y0
469
469
  end
470
470
  end
471
471
  elsif act2
472
472
  r = r >> proc do |x|
473
- y0, y1, *ys = x.pop
473
+ _, y1, = x.pop
474
474
  act2.call(x.push(*y1)) if y1
475
475
  end
476
476
  end
@@ -863,29 +863,16 @@ module TDParser
863
863
  class Grammar
864
864
  include TDParser
865
865
 
866
- def define(&block)
867
- instance_eval do
868
- alias method_missing g_method_missing
869
- block.call(self)
870
- ensure
871
- undef method_missing
872
- end
873
- end
866
+ alias define instance_eval
874
867
 
875
- def g_method_missing(sym, *args)
876
- arg0 = args[0]
877
- sym = sym.to_s
868
+ def method_missing(sym, *args)
878
869
  if sym[-1, 1] == '='
879
- case arg0
880
- when Parser
881
- self.class.instance_eval do
882
- define_method(sym[0..-2]) { arg0 }
883
- end
884
- else
885
- t = token(arg0)
886
- self.class.instance_eval do
887
- define_method(sym[0..-2]) { t }
888
- end
870
+ parser, = args
871
+ name = sym[0..-2]
872
+ parser.is_a?(Parser) or parser = token(parser)
873
+ self.class.instance_eval do
874
+ instance_methods.include?(name.intern) or
875
+ define_method(name) { parser }
889
876
  end
890
877
  elsif args.empty?
891
878
  rule(sym)
@@ -893,8 +880,6 @@ module TDParser
893
880
  raise(NoMethodError, "undefined method `#{sym}' for #{inspect}")
894
881
  end
895
882
  end
896
-
897
- alias method_missing g_method_missing
898
883
  end
899
884
 
900
885
  def self.define(*_args, &)
@@ -906,10 +891,6 @@ module TDParser
906
891
  else
907
892
  g.instance_eval(&)
908
893
  end
909
- ensure
910
- g.instance_eval do
911
- undef method_missing
912
- end
913
894
  end
914
895
  g
915
896
  end
data/samples/sample4.rb CHANGED
@@ -24,7 +24,6 @@ class Sample4Parser
24
24
 
25
25
  def expr2
26
26
  (rule(:prim) - (((token('*') | token('/')) - rule(:prim)) * 0)) >> proc { |x|
27
- n = x[0]
28
27
  x[1].inject(x[0]) do |n, y|
29
28
  case y[0]
30
29
  when '*'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takaaki Tateishi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-11-08 00:00:00.000000000 Z
12
+ date: 2024-11-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: TDParser (formerly TDP4R) is a top-down parser library that consists
15
15
  of parser combinators and utility functions.
@@ -43,11 +43,17 @@ files:
43
43
  - samples/sample_list.rb
44
44
  - samples/sample_optimize.rb
45
45
  - samples/sample_xml.rb
46
- homepage:
46
+ homepage: https://git.disroot.org/gemmaro/tdparser
47
47
  licenses:
48
48
  - BSD-3-Clause
49
49
  metadata:
50
50
  rubygems_mfa_required: 'true'
51
+ bug_tracker_uri: https://git.disroot.org/gemmaro/tdparser/issues
52
+ changelog_uri: https://git.disroot.org/gemmaro/tdparser/src/branch/main/CHANGELOG.md
53
+ documentation_uri: https://www.rubydoc.info/gems/tcepsni
54
+ homepage_uri: https://git.disroot.org/gemmaro/tdparser
55
+ source_code_uri: https://git.disroot.org/gemmaro/tdparser
56
+ wiki_uri: https://git.disroot.org/gemmaro/tdparser//wiki
51
57
  post_install_message:
52
58
  rdoc_options: []
53
59
  require_paths: