lrama 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yaml +5 -3
- data/lib/lrama/command.rb +7 -3
- data/lib/lrama/output.rb +21 -12
- data/lib/lrama/states.rb +1 -1
- data/lib/lrama/version.rb +1 -1
- data/lrama.gemspec +1 -1
- data/template/bison/yacc.c +1 -1
- data/template/bison/yacc.h +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8a1b04a3e761af04029af3e3b74aaaf4fe9a9e2741205f430264ee3399f66c
|
4
|
+
data.tar.gz: a97ec2c2b2007f3bad6cbe5d1b37baa87d520cc3025e82403a9d8a70cddccc8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820bce06aefc235c02995cc957f9e0d9b2e8d588ce7748225896f0d63c319135068da39977be860815276c360a66e3dd6c2132802aa30e3292d706bc6ae7ef9d
|
7
|
+
data.tar.gz: d5c4ec405196bca888c78bf8a16cc9aef47da0f9943d7eee2bf9033c104f9a07fcb07c4cb6aabb3bb49f0e3665bf37932e2206cd9acad925702c30c7124210fb
|
data/.github/workflows/test.yaml
CHANGED
@@ -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', '2.7']
|
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
|
@@ -40,10 +40,12 @@ jobs:
|
|
40
40
|
bundler-cache: true
|
41
41
|
- run: git clone --depth=1 https://github.com/ruby/ruby.git -b ${{ matrix.ruby_branch }} ../ruby
|
42
42
|
working-directory:
|
43
|
-
- run: mkdir tool/lrama
|
43
|
+
- run: mkdir -p tool/lrama
|
44
44
|
working-directory: ../ruby
|
45
45
|
- name: Copy Lrama to ruby/tool
|
46
|
-
run: cp -r exe lib
|
46
|
+
run: cp -r exe lib ../ruby/tool/lrama
|
47
|
+
# TODO: Consider how to manage changes on ruby/ruby master and ruby/lrama
|
48
|
+
# run: cp -r exe lib template ../ruby/tool/lrama
|
47
49
|
working-directory:
|
48
50
|
- run: tree tool/lrama
|
49
51
|
working-directory: ../ruby
|
data/lib/lrama/command.rb
CHANGED
@@ -57,14 +57,18 @@ module Lrama
|
|
57
57
|
end
|
58
58
|
|
59
59
|
if !grammar_file
|
60
|
-
|
61
|
-
exit 1
|
60
|
+
abort "File should be specified\n"
|
62
61
|
end
|
63
62
|
|
64
63
|
Report::Duration.enable if trace_opts[:time]
|
65
64
|
|
66
65
|
warning = Lrama::Warning.new
|
67
|
-
|
66
|
+
if grammar_file == '-'
|
67
|
+
grammar_file = argv.shift or abort "File name for STDIN should be specified\n"
|
68
|
+
y = STDIN.read
|
69
|
+
else
|
70
|
+
y = File.read(grammar_file)
|
71
|
+
end
|
68
72
|
grammar = Lrama::Parser.new(y).parse
|
69
73
|
states = Lrama::States.new(grammar, warning, trace_state: (trace_opts[:automaton] || trace_opts[:closure]))
|
70
74
|
states.compute
|
data/lib/lrama/output.rb
CHANGED
@@ -25,26 +25,35 @@ 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
|
-
|
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
|
-
|
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
|
44
55
|
else
|
45
|
-
File.
|
46
|
-
f << tmp
|
47
|
-
end
|
56
|
+
File.write(@header_file_path, tmp)
|
48
57
|
end
|
49
58
|
end
|
50
59
|
end
|
@@ -141,7 +150,7 @@ module Lrama
|
|
141
150
|
|
142
151
|
<<-STR
|
143
152
|
#{comment}
|
144
|
-
|
153
|
+
#line #{@grammar.initial_action.line} "#{@grammar_file_path}"
|
145
154
|
#{@grammar.initial_action.translated_code}
|
146
155
|
STR
|
147
156
|
end
|
data/lib/lrama/states.rb
CHANGED
data/lib/lrama/version.rb
CHANGED
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(">= 2.
|
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)/}) }
|
data/template/bison/yacc.c
CHANGED
data/template/bison/yacc.h
CHANGED
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.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2023-05-15 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: 2.
|
61
|
+
version: 2.5.0
|
62
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - ">="
|