lrama 0.2.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e279f380f56a925432b87cf93d98bb852bbddc5c28fdebec637d8102c68cc4ff
4
- data.tar.gz: 0fd9f28b2cd2b8a5594ea03c34ac568b601feac3ac9f469de4b1c0cd127af923
3
+ metadata.gz: ef1a46b0de83840d8353cf0e832898b7567a6a546b5ab8402cee59be5178d3af
4
+ data.tar.gz: 81e546a5f907ed2a1a2ca4e1028f5be05df8251bd59fb8c7d8a3a7565e0f9dce
5
5
  SHA512:
6
- metadata.gz: a628efc1fb3a8a3087bc6c2712254e9fb09827fcec8b62a6dc1b4c15456418c5df302a12e54b6136a223a1113c353f557006c38e7ae21708cdea50a2d5dd85a0
7
- data.tar.gz: af7b9c45be3e53de86a2cbcaac647915bee3f0d87a41e2268d40b933d8080b755f1016429cba41632e99789a093f4458db5193335ba8e8bb368084831ce58013
6
+ metadata.gz: d388d548999a8e96d08698d191a44ea5c71893060eef624a1fd7845cfe23f96f27720646897fc12930f948f3dc27771a0e69ec26f57b604711ebe537984cb752
7
+ data.tar.gz: afe54b54f3852fd65c243bff4a800a2186bc89cdfc92a83bae85eabf10aae7b4989d9daea9904477bff109fd48ae38af0aefaf1e10d245cb74f107397db5ae55
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: ['head', '3.2', '3.1', '3.0']
16
+ ruby: ['head', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5']
17
17
  steps:
18
18
  - uses: actions/checkout@v3
19
19
  - uses: ruby/setup-ruby@v1
data/lib/lrama/output.rb CHANGED
@@ -25,19 +25,30 @@ module Lrama
25
25
  @grammar = grammar
26
26
  end
27
27
 
28
+ if ERB.instance_method(:initialize).parameters.last.first == :key
29
+ def self.erb(input)
30
+ ERB.new(input, trim_mode: '-')
31
+ end
32
+ else
33
+ def self.erb(input)
34
+ ERB.new(input, nil, '-')
35
+ end
36
+ end
37
+
38
+ def eval_template(file, path)
39
+ erb = self.class.erb(File.read(file))
40
+ erb.filename = file
41
+ tmp = erb.result_with_hash(context: @context, output: self)
42
+ replace_special_variables(tmp, path)
43
+ end
44
+
28
45
  def render
29
46
  report_duration(:render) do
30
- erb = ERB.new(File.read(template_file), trim_mode: '-')
31
- erb.filename = template_file
32
- tmp = erb.result_with_hash(context: @context, output: self)
33
- tmp = replace_special_variables(tmp, @output_file_path)
47
+ tmp = eval_template(template_file, @output_file_path)
34
48
  @out << tmp
35
49
 
36
50
  if @header_file_path
37
- erb = ERB.new(File.read(header_template_file), trim_mode: '-')
38
- erb.filename = header_template_file
39
- tmp = erb.result_with_hash(context: @context, output: self)
40
- tmp = replace_special_variables(tmp, @header_file_path)
51
+ tmp = eval_template(header_template_file, @header_file_path)
41
52
 
42
53
  if @header_out
43
54
  @header_out << tmp
@@ -141,7 +152,7 @@ module Lrama
141
152
 
142
153
  <<-STR
143
154
  #{comment}
144
- #line #{@grammar.initial_action.line} "#{@grammar_file_path}"
155
+ #line #{@grammar.initial_action.line} "#{@grammar_file_path}"
145
156
  #{@grammar.initial_action.translated_code}
146
157
  STR
147
158
  end
data/lib/lrama/states.rb CHANGED
@@ -776,7 +776,7 @@ module Lrama
776
776
  state.reduces.each do |reduce|
777
777
  next if reduce.look_ahead.nil?
778
778
 
779
- intersection = a.intersection(reduce.look_ahead)
779
+ intersection = a & reduce.look_ahead
780
780
  a += reduce.look_ahead
781
781
 
782
782
  if !intersection.empty?
data/lib/lrama/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lrama
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
data/lrama.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = "https://github.com/yui-knk/lrama"
12
12
  # See LEGAL.md file for detail
13
13
  spec.license = "GNU GPLv3"
14
- spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
15
15
 
16
16
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
17
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lrama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichiro Kaneko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-10 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: LALR (1) parser generator written by Ruby
14
14
  email:
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0
61
+ version: 2.5.0
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="