fortio-namelist 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NOTE.md +29 -0
- data/README.md +105 -23
- data/fortio-namelist.gemspec +2 -2
- data/lib/fortio-namelist/fortran_namelist.rb +41 -30
- data/lib/fortio-namelist/fortran_namelist.tab.rb +229 -217
- data/lib/fortio-namelist/fortran_namelist.y +87 -60
- data/spec/array_spec.rb +160 -0
- data/spec/empty_spec.rb +65 -0
- data/spec/identifier_spec.rb +81 -0
- data/spec/scalar_spec.rb +196 -0
- data/spec/structure_spec.rb +138 -0
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c44816ef76988ff0fb717b4d8d67eab2525e96341e01292be61b589ad5863c64
|
4
|
+
data.tar.gz: '0572478dd329fea60bd37dce6095b188f25c7ede6d3fc8bc9424cbf7a56762d5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6588de0bacd73f1ce582399cea86b97ee820b84cfdcee9ce9531d4292a004294ff1b6495b2e7415f3d57c5b3a36947675c75870a250eb3fc9e3d4e782eb54c
|
7
|
+
data.tar.gz: 34ba922c0b04ef92fa3ed3df09ecf8350233c324675aa8a9a393bb6a641df6c61e19d93f686ca0e4d735c0f0c5a349c505f1ad43aa5edbbd48386eb77696ed6c
|
data/NOTE.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
name
|
2
|
+
----
|
3
|
+
|
4
|
+
### グループ名のプレフィックス
|
5
|
+
|
6
|
+
'&'と'$'が使える。グループの終端を表す'end'のプレフィックスも同様であるが、
|
7
|
+
始端と終端のプレフィックスのペアのチェックはしない。
|
8
|
+
|
9
|
+
### 文字列の配列
|
10
|
+
|
11
|
+
v1 = "a", "b", 'c' ! 引用符あり文字列の配列
|
12
|
+
v2 = a, b, c ! 引用符なし文字列の配列
|
13
|
+
v3 = a, 0_b, _c ! 引用符なし文字列の配列
|
14
|
+
|
15
|
+
ただし、引用符あり文字列と引用符なし文字列を混在させることはできない。
|
16
|
+
|
17
|
+
v4 = "a", b, "c" ! エラー
|
18
|
+
v5 = "a", 0_b, c ! エラー
|
19
|
+
|
20
|
+
### 論理型リテラル
|
21
|
+
|
22
|
+
v1 = .true. ! true
|
23
|
+
v2 = .tabc. ! true
|
24
|
+
v3 = t ! true
|
25
|
+
|
26
|
+
v4 = .false. ! false
|
27
|
+
v5 = .fabc. ! false
|
28
|
+
v6 = f ! false
|
29
|
+
|
data/README.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
fortio-namelist
|
2
2
|
===============
|
3
3
|
|
4
|
-
This is a library for reading and writing data in Fortran namelist format. With this library, you can read Fortran namelist format data from Ruby and convert it to Hash objects, and vice versa.
|
4
|
+
This is a library for reading and writing data in Fortran's namelist format. With this library, you can read Fortran's namelist format data from Ruby and convert it to Hash objects, and vice versa.
|
5
|
+
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
|
9
|
+
* Flexible parsing enables reading of namelists in various formats.
|
10
|
+
* Various options to control the output namelist string in the format of your choice.
|
11
|
+
* Able to convert namelist format to JSON or YAML format using Ruby's standard library
|
5
12
|
|
6
13
|
Installation
|
7
14
|
------------
|
@@ -14,51 +21,126 @@ To use the library in your Ruby script,
|
|
14
21
|
require "fortio-namelist"
|
15
22
|
```
|
16
23
|
|
17
|
-
|
24
|
+
Usage
|
18
25
|
-----------
|
19
26
|
|
20
|
-
|
27
|
+
### Reading namelist format string
|
21
28
|
|
22
|
-
|
29
|
+
To create a Hash object with Namelist structure by reading a string in namelist format, use the following method.
|
23
30
|
|
24
|
-
|
25
|
-
FortIO::Namelist.generate(hash, name: "namelist", array_format: 'stream')
|
31
|
+
FortIO::Namelist.read(input, group: nil)
|
26
32
|
|
27
|
-
|
28
|
-
|
33
|
+
The argument `input` is given as a string, but it also accepts objects with a method `#read` returns a string like an IO object.
|
34
|
+
|
35
|
+
If the keyword argument `group` is omitted, all namelist groups included in `input` will be read. To read only a specific group, give a group name to `group`. To load multiple groups, give an array of group names to `group`.
|
36
|
+
|
37
|
+
The Hash object of the return value has a two-level structure as follows.
|
38
|
+
|
39
|
+
{
|
40
|
+
"group1" => {
|
41
|
+
"var11" => value11,
|
42
|
+
"var12" => value12,
|
43
|
+
: :
|
44
|
+
}
|
45
|
+
"group2" => {
|
46
|
+
"var21" => value21,
|
47
|
+
"var22" => value22,
|
48
|
+
: :
|
49
|
+
}
|
50
|
+
:
|
51
|
+
:
|
52
|
+
}
|
29
53
|
|
30
|
-
|
31
|
-
|
54
|
+
Group names and variable names are given as String objects. The value is Ruby's String, Integer, Float, Complex, TrueClass, or FalseClass objects, depending on the literal in the namelist. In the case of an array, it will be an Array object with the above objects as elements.
|
55
|
+
|
56
|
+
Example:
|
57
|
+
|
58
|
+
require 'fortio-namelist'
|
59
|
+
|
60
|
+
input = %{
|
61
|
+
&group1
|
62
|
+
var1 = 11
|
63
|
+
var2 = 12
|
64
|
+
/
|
65
|
+
&group2
|
66
|
+
var1 = 12
|
67
|
+
var2 = 22
|
68
|
+
/
|
69
|
+
&group3
|
70
|
+
var1 = 31
|
71
|
+
var2 = 32
|
72
|
+
/
|
73
|
+
}
|
74
|
+
|
75
|
+
### read all groups
|
76
|
+
root = FortIO::Namelist.read(input)
|
77
|
+
=> {"group1"=>{"var1"=>11, "var2"=>12},
|
78
|
+
"group2"=>{"var1"=>12, "var2"=>22},
|
79
|
+
"group3"=>{"var1"=>31, "var2"=>32}}
|
80
|
+
|
81
|
+
### read only "group2"
|
82
|
+
root = FortIO::Namelist.read(input, group: "group2")
|
83
|
+
=> {"group2"=>{"var1"=>12, "var2"=>22}}
|
84
|
+
|
85
|
+
### read only "group1" and "group3"
|
86
|
+
root = FortIO::Namelist.read(input, group: ["group1", "group3"])
|
87
|
+
=> {"group1"=>{"var1"=>11, "var2"=>12},
|
88
|
+
"group3"=>{"var1"=>31, "var2"=>32}}
|
32
89
|
|
33
|
-
|
90
|
+
### Generating namelist format string from Hash object with namelist structure
|
34
91
|
|
35
|
-
|
36
|
-
'stream'
|
92
|
+
To generate a namelist format string from a Hash object with a namelist structure, use the following method.
|
37
93
|
|
94
|
+
FortIO::Namelist.dump(root, **format_options)
|
95
|
+
|
96
|
+
The argument `root` is given as a Hash object. The return value is a string in namelist format. You can finely control the output namelist string with the following keyword arguments (the first one is the default).
|
97
|
+
|
98
|
+
array_style: 'stream'
|
99
|
+
'index'
|
100
|
+
|
38
101
|
logical_format: 'normal'
|
39
102
|
'short'
|
40
103
|
|
41
104
|
float_format: 'normal'
|
42
105
|
'd0'
|
43
106
|
|
44
|
-
alignment: '
|
45
|
-
'left'
|
107
|
+
alignment: 'left'
|
46
108
|
'right'
|
109
|
+
'compact'
|
47
110
|
Integer
|
48
111
|
|
49
112
|
uppercase: false
|
50
113
|
true
|
51
114
|
|
52
|
-
comma
|
53
|
-
|
54
|
-
|
55
|
-
slash
|
56
|
-
|
115
|
+
separator: "comma", ","
|
116
|
+
"nl", "\n"
|
117
|
+
|
118
|
+
group_end: "slash", "/"
|
119
|
+
"end"
|
57
120
|
|
58
121
|
indent: ' '*2
|
59
122
|
|
123
|
+
Example:
|
60
124
|
|
61
|
-
|
125
|
+
require 'fortio-namelist'
|
62
126
|
|
63
|
-
|
64
|
-
|
127
|
+
root = {"group1"=>{"var1"=>11, "var2"=>12},
|
128
|
+
"group2"=>{"var1"=>12, "var2"=>22},
|
129
|
+
"group3"=>{"var1"=>31, "var2"=>32}}
|
130
|
+
|
131
|
+
puts FortIO::Namelist.dump(root)
|
132
|
+
|
133
|
+
This script print a namelist format string to stdout.
|
134
|
+
|
135
|
+
&group1
|
136
|
+
var1 = 11,
|
137
|
+
var2 = 12
|
138
|
+
/
|
139
|
+
&group2
|
140
|
+
var1 = 12,
|
141
|
+
var2 = 22
|
142
|
+
/
|
143
|
+
&group3
|
144
|
+
var1 = 31,
|
145
|
+
var2 = 32
|
146
|
+
/
|
data/fortio-namelist.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Gem::Specification::new do |s|
|
2
|
-
version = "1.
|
2
|
+
version = "1.1.0"
|
3
3
|
files = Dir.glob("**/*") - [
|
4
4
|
Dir.glob("fortio-namelist-*.gem"),
|
5
5
|
Dir.glob("test/**/*"),
|
@@ -18,6 +18,6 @@ Gem::Specification::new do |s|
|
|
18
18
|
s.email = ""
|
19
19
|
s.homepage = 'https://github.com/himotoyoshi/fortio-namelist'
|
20
20
|
s.files = files
|
21
|
-
s.required_ruby_version = ">=
|
21
|
+
s.required_ruby_version = ">= 2.4.0"
|
22
22
|
end
|
23
23
|
|
@@ -72,24 +72,16 @@ module FortIO::Namelist
|
|
72
72
|
@namelist = FortIO::Namelist::Parser.new.parse(text)
|
73
73
|
end
|
74
74
|
|
75
|
-
def read (
|
76
|
-
|
77
|
-
raise "no definition of namelist '#{
|
75
|
+
def read (group, out={})
|
76
|
+
group = group.downcase
|
77
|
+
raise "no definition of namelist group '#{group}'" \
|
78
|
+
unless nml = @namelist[group]
|
78
79
|
nml.each do |paramdef|
|
79
80
|
paramdef.set(out)
|
80
81
|
end
|
81
82
|
return out
|
82
83
|
end
|
83
84
|
|
84
|
-
def read_all
|
85
|
-
all = {}
|
86
|
-
@namelist.each do |name, nml|
|
87
|
-
all[name] = {}
|
88
|
-
read(name, all[name])
|
89
|
-
end
|
90
|
-
return all
|
91
|
-
end
|
92
|
-
|
93
85
|
attr_reader :namelist
|
94
86
|
|
95
87
|
end
|
@@ -100,12 +92,15 @@ module FortIO::Namelist
|
|
100
92
|
#
|
101
93
|
|
102
94
|
#
|
103
|
-
# FortIO::Namelist.dump(hash,
|
95
|
+
# FortIO::Namelist.dump(hash, group: "namelist")
|
104
96
|
#
|
105
97
|
# hash -> namelist converter
|
106
98
|
#
|
107
99
|
|
108
|
-
def self.format_element (value,
|
100
|
+
def self.format_element (value,
|
101
|
+
logical_format: 'normal',
|
102
|
+
float_format: 'normal',
|
103
|
+
uppercase: false)
|
109
104
|
case value
|
110
105
|
when String
|
111
106
|
if value !~ /'/
|
@@ -154,12 +149,12 @@ module FortIO::Namelist
|
|
154
149
|
end
|
155
150
|
|
156
151
|
def self.generate (hash,
|
157
|
-
|
152
|
+
group: "group",
|
158
153
|
array_style: "stream",
|
159
154
|
alignment: "left",
|
160
155
|
uppercase: false,
|
161
|
-
|
162
|
-
|
156
|
+
separator: "comma",
|
157
|
+
group_end: "/",
|
163
158
|
indent: ' ',
|
164
159
|
**format_options)
|
165
160
|
format_options[:uppercase] = uppercase
|
@@ -177,7 +172,7 @@ module FortIO::Namelist
|
|
177
172
|
when "stream"
|
178
173
|
list << [ident, value.map{ |e| format_element(e, **format_options) }.join(", ")]
|
179
174
|
else
|
180
|
-
raise "
|
175
|
+
raise "invalid keyword argument `array_style` (should be 'index', 'stream')"
|
181
176
|
end
|
182
177
|
else
|
183
178
|
list << [ident, format_element(value, **format_options)]
|
@@ -185,12 +180,15 @@ module FortIO::Namelist
|
|
185
180
|
end
|
186
181
|
if uppercase
|
187
182
|
list = list.map{|ident,value| [ident.upcase, value]}
|
188
|
-
|
183
|
+
group = group.upcase
|
189
184
|
end
|
190
|
-
|
185
|
+
case separator
|
186
|
+
when "comma", ","
|
191
187
|
nl = ",\n"
|
192
|
-
|
188
|
+
when "nl", "\n"
|
193
189
|
nl = "\n"
|
190
|
+
else
|
191
|
+
raise "invalid keyword argument `separator` (should be 'comma', ',', 'nl', '\n')"
|
194
192
|
end
|
195
193
|
case alignment
|
196
194
|
when "none"
|
@@ -212,35 +210,48 @@ module FortIO::Namelist
|
|
212
210
|
format("%s%-#{alignment-2}s = %s", indent, ident, value)
|
213
211
|
}.join(nl)
|
214
212
|
else
|
215
|
-
raise "
|
213
|
+
raise "invalid keyword argument `alignment` (should be 'normal' 'left' 'right' 'stream')"
|
216
214
|
end
|
217
|
-
|
215
|
+
case group_end
|
216
|
+
when "slash", "/"
|
218
217
|
tail = "/"
|
219
|
-
|
218
|
+
when "end"
|
220
219
|
tail = "&end"
|
220
|
+
else
|
221
|
+
raise "invalid keyword argument `group_end` (should be 'slash', '/', 'end')"
|
221
222
|
end
|
222
|
-
return ["&#{
|
223
|
+
return ["&#{group}", body, tail, ""].join("\n")
|
223
224
|
end
|
224
225
|
|
225
226
|
def self.dump (root, **format_options)
|
226
|
-
return root.map { |
|
227
|
+
return root.map { |group, hash| generate(hash, group: group, **format_options) }.join
|
227
228
|
end
|
228
229
|
|
229
230
|
#
|
230
231
|
# FortIO::Namelist.read(input, name: nil)
|
231
232
|
#
|
232
|
-
def self.read (input,
|
233
|
+
def self.read (input, group: nil)
|
233
234
|
case input
|
234
235
|
when String
|
235
236
|
text = input
|
236
237
|
else
|
237
238
|
text = input.read
|
238
239
|
end
|
239
|
-
|
240
|
-
|
240
|
+
reader = FortIO::Namelist::Reader.new(text)
|
241
|
+
case group
|
242
|
+
when Array
|
243
|
+
groups = group
|
244
|
+
when String
|
245
|
+
groups = [group]
|
246
|
+
when nil
|
247
|
+
groups = reader.namelist.keys
|
241
248
|
else
|
242
|
-
|
249
|
+
raise "invalid keyword arugment `group` '#{group.inspect}'"
|
243
250
|
end
|
251
|
+
return groups.each_with_object({}) { |group, root|
|
252
|
+
root[group] = {}
|
253
|
+
reader.read(group, root[group])
|
254
|
+
}
|
244
255
|
end
|
245
256
|
|
246
257
|
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.
|
3
|
+
# This file is automatically generated by Racc 1.5.2
|
4
4
|
# from Racc grammar file "".
|
5
5
|
#
|
6
6
|
|
@@ -53,6 +53,21 @@ module FortIO::Namelist
|
|
53
53
|
end
|
54
54
|
else
|
55
55
|
case
|
56
|
+
when @s.scan(/\A\(/)
|
57
|
+
return [
|
58
|
+
'(',
|
59
|
+
nil
|
60
|
+
]
|
61
|
+
when @s.scan(/\A\)/)
|
62
|
+
return [
|
63
|
+
')',
|
64
|
+
nil
|
65
|
+
]
|
66
|
+
when @s.scan(/\A\:/)
|
67
|
+
return [
|
68
|
+
':',
|
69
|
+
nil
|
70
|
+
]
|
56
71
|
when @s.scan(/\A[+-]?(\d+)\.(\d+)?([ED][+-]?(\d+))?/i) ### float
|
57
72
|
return [ ### 1.2E+3, 1.E+3, 1.2E3
|
58
73
|
:FLOAT, ### 1.2, 1.
|
@@ -68,9 +83,9 @@ module FortIO::Namelist
|
|
68
83
|
:FLOAT,
|
69
84
|
@s[0].sub(/D/i,'e').to_f
|
70
85
|
]
|
71
|
-
when @s.scan(/\A\d+[a-z_]\w*/i) ### STRING
|
86
|
+
when @s.scan(/\A\d+[a-z_]\w*/i) ### STRING-Like
|
72
87
|
return [
|
73
|
-
:
|
88
|
+
:STRINGLIKE,
|
74
89
|
@s[0]
|
75
90
|
]
|
76
91
|
when @s.scan(/\A[\-\+]?\d+/) ### digits
|
@@ -98,6 +113,11 @@ module FortIO::Namelist
|
|
98
113
|
',',
|
99
114
|
nil
|
100
115
|
]
|
116
|
+
elsif @s.match?(/\A[a-z]\w*\s*,/i)
|
117
|
+
return [
|
118
|
+
',',
|
119
|
+
nil
|
120
|
+
]
|
101
121
|
elsif @s.match?(/\A[a-z]\w*/i) or @s.match?(/\A[\&\$\/\!]/)
|
102
122
|
return [
|
103
123
|
:COMMA,
|
@@ -121,9 +141,9 @@ module FortIO::Namelist
|
|
121
141
|
@s[0],
|
122
142
|
nil
|
123
143
|
]
|
124
|
-
when @s.scan(/\A_\w*/i) ### STRING
|
144
|
+
when @s.scan(/\A_\w*/i) ### STRING-Like
|
125
145
|
return [
|
126
|
-
:
|
146
|
+
:STRINGLIKE,
|
127
147
|
@s[0]
|
128
148
|
]
|
129
149
|
when @s.scan(/\A\.t.*?\./i) ### LOGICAL true
|
@@ -194,7 +214,7 @@ module FortIO
|
|
194
214
|
module Namelist
|
195
215
|
class Parser < Racc::Parser
|
196
216
|
|
197
|
-
module_eval(<<'...end fortran_namelist.y/module_eval...', 'fortran_namelist.y',
|
217
|
+
module_eval(<<'...end fortran_namelist.y/module_eval...', 'fortran_namelist.y', 122)
|
198
218
|
|
199
219
|
def parse (str)
|
200
220
|
@scan = FortIO::Namelist::Scanner.new(str)
|
@@ -223,151 +243,144 @@ module_eval(<<'...end fortran_namelist.y/module_eval...', 'fortran_namelist.y',
|
|
223
243
|
##### State transition tables begin ###
|
224
244
|
|
225
245
|
racc_action_table = [
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
31, nil, 42, 38, nil, 33, 30, 34, 35, 36,
|
236
|
-
31, nil, 42, 38, nil, 33, nil, 34, 35, 36,
|
237
|
-
19, 20, nil, nil, 4, 5, 15, 12, 38, nil,
|
238
|
-
33, nil, 34, 35, 36, 38, nil, 58, nil, 34,
|
239
|
-
35, 36, 38, nil, 33, nil, 34, 35, 36, 11,
|
240
|
-
nil, nil, 4, 5, 15, 12 ]
|
246
|
+
44, 30, 13, 58, 60, 43, 14, 35, 15, 37,
|
247
|
+
57, 38, 39, 42, 45, 44, 22, 22, 61, 54,
|
248
|
+
43, 24, 35, 42, 37, 44, 38, 39, 42, 45,
|
249
|
+
43, 54, 35, 47, 37, 42, 38, 39, 42, 45,
|
250
|
+
43, 52, 51, 50, 37, 43, 38, 39, 42, 37,
|
251
|
+
43, 38, 39, 42, 54, 53, 38, 39, 42, 4,
|
252
|
+
5, 21, 4, 5, 18, 4, 5, 21, 56, 7,
|
253
|
+
18, 4, 5, 10, 13, 10, 13, 25, 26, 63,
|
254
|
+
64, 65, 47, 69, 70, 47 ]
|
241
255
|
|
242
256
|
racc_action_check = [
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
64,
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
42, nil, 42, 42, nil, 42, 60, 42, 42, 42,
|
253
|
-
60, nil, 60, 60, nil, 60, nil, 60, 60, 60,
|
254
|
-
10, 10, nil, nil, 10, 10, 10, 10, 44, nil,
|
255
|
-
44, nil, 44, 44, 44, 48, nil, 48, nil, 48,
|
256
|
-
48, 48, 45, nil, 45, nil, 45, 45, 45, 3,
|
257
|
-
nil, nil, 3, 3, 3, 3 ]
|
257
|
+
25, 25, 25, 47, 52, 25, 6, 25, 7, 25,
|
258
|
+
47, 25, 25, 25, 25, 29, 11, 29, 52, 43,
|
259
|
+
29, 19, 29, 43, 29, 64, 29, 29, 29, 29,
|
260
|
+
64, 63, 64, 26, 64, 63, 64, 64, 64, 64,
|
261
|
+
32, 33, 32, 32, 32, 50, 32, 32, 32, 50,
|
262
|
+
53, 50, 50, 50, 53, 37, 53, 53, 53, 9,
|
263
|
+
9, 9, 0, 0, 9, 23, 23, 23, 46, 1,
|
264
|
+
23, 1, 1, 3, 3, 16, 16, 21, 21, 55,
|
265
|
+
56, 57, 58, 65, 67, 69 ]
|
258
266
|
|
259
267
|
racc_action_pointer = [
|
260
|
-
|
261
|
-
|
262
|
-
nil,
|
263
|
-
|
264
|
-
|
265
|
-
nil,
|
266
|
-
|
268
|
+
60, 69, nil, 68, nil, nil, 2, 8, nil, 57,
|
269
|
+
nil, 10, nil, nil, nil, nil, 70, nil, nil, 17,
|
270
|
+
nil, 69, nil, 63, nil, -4, 20, nil, nil, 11,
|
271
|
+
nil, nil, 31, 29, nil, nil, nil, 41, nil, nil,
|
272
|
+
nil, nil, nil, 6, nil, nil, 58, -9, nil, nil,
|
273
|
+
36, nil, 0, 41, nil, 67, 72, 68, 69, nil,
|
274
|
+
nil, nil, nil, 18, 21, 71, nil, 74, nil, 72,
|
275
|
+
nil, nil ]
|
267
276
|
|
268
277
|
racc_action_default = [
|
269
|
-
|
270
|
-
|
271
|
-
-
|
272
|
-
-
|
273
|
-
-
|
274
|
-
-
|
275
|
-
-
|
278
|
+
-46, -46, -2, -13, -5, -6, -46, -46, -1, -46,
|
279
|
+
-8, -9, -10, -11, -7, 72, -13, -4, -14, -46,
|
280
|
+
-16, -46, -12, -46, -15, -46, -46, -3, -17, -46,
|
281
|
+
-18, -19, -22, -23, -24, -25, -29, -35, -31, -32,
|
282
|
+
-33, -34, -36, -46, -38, -39, -46, -42, -20, -26,
|
283
|
+
-46, -28, -46, -46, -35, -46, -46, -46, -46, -27,
|
284
|
+
-40, -41, -30, -46, -46, -43, -44, -46, -21, -46,
|
285
|
+
-37, -45 ]
|
276
286
|
|
277
287
|
racc_goto_table = [
|
278
|
-
|
279
|
-
1,
|
280
|
-
|
281
|
-
nil, nil, nil, nil, nil, nil, nil,
|
282
|
-
|
288
|
+
46, 31, 55, 49, 17, 48, 19, 2, 8, 20,
|
289
|
+
1, 9, 16, 29, 62, nil, nil, nil, 27, nil,
|
290
|
+
19, 59, 67, 28, 23, nil, nil, nil, nil, nil,
|
291
|
+
nil, nil, 66, nil, nil, nil, nil, nil, nil, nil,
|
292
|
+
68, nil, nil, 71 ]
|
283
293
|
|
284
294
|
racc_goto_check = [
|
285
|
-
|
286
|
-
1,
|
287
|
-
|
288
|
-
nil, nil, nil, nil, nil, nil, nil,
|
289
|
-
|
295
|
+
12, 11, 17, 15, 6, 11, 7, 2, 2, 10,
|
296
|
+
1, 4, 5, 8, 16, nil, nil, nil, 6, nil,
|
297
|
+
7, 15, 17, 10, 4, nil, nil, nil, nil, nil,
|
298
|
+
nil, nil, 12, nil, nil, nil, nil, nil, nil, nil,
|
299
|
+
11, nil, nil, 12 ]
|
290
300
|
|
291
301
|
racc_goto_pointer = [
|
292
|
-
nil, 10,
|
293
|
-
-
|
302
|
+
nil, 10, 7, nil, 8, 3, -5, -3, -12, nil,
|
303
|
+
0, -24, -26, nil, nil, -29, -39, -41, nil ]
|
294
304
|
|
295
305
|
racc_goto_default = [
|
296
|
-
nil, nil,
|
297
|
-
nil,
|
306
|
+
nil, nil, nil, 3, nil, nil, nil, 6, 11, 12,
|
307
|
+
nil, nil, nil, 32, 33, 34, 36, 40, 41 ]
|
298
308
|
|
299
309
|
racc_reduce_table = [
|
300
310
|
0, 0, :racc_error,
|
301
|
-
|
302
|
-
1,
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
1,
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
1,
|
311
|
-
|
311
|
+
2, 21, :_reduce_none,
|
312
|
+
1, 21, :_reduce_none,
|
313
|
+
5, 22, :_reduce_3,
|
314
|
+
3, 22, :_reduce_4,
|
315
|
+
1, 27, :_reduce_none,
|
316
|
+
1, 27, :_reduce_none,
|
317
|
+
2, 23, :_reduce_7,
|
318
|
+
1, 24, :_reduce_none,
|
319
|
+
1, 24, :_reduce_none,
|
320
|
+
1, 24, :_reduce_none,
|
321
|
+
1, 28, :_reduce_none,
|
322
|
+
2, 28, :_reduce_none,
|
323
|
+
0, 29, :_reduce_none,
|
312
324
|
1, 26, :_reduce_none,
|
313
|
-
|
314
|
-
1,
|
315
|
-
|
316
|
-
|
317
|
-
3,
|
318
|
-
|
319
|
-
|
320
|
-
6, 27, :_reduce_20,
|
321
|
-
1, 28, :_reduce_21,
|
322
|
-
2, 28, :_reduce_22,
|
323
|
-
3, 28, :_reduce_23,
|
324
|
-
3, 28, :_reduce_24,
|
325
|
-
2, 28, :_reduce_25,
|
326
|
-
2, 28, :_reduce_26,
|
327
|
-
2, 28, :_reduce_27,
|
328
|
-
2, 28, :_reduce_28,
|
329
|
-
1, 28, :_reduce_29,
|
330
|
-
1, 30, :_reduce_30,
|
331
|
-
3, 30, :_reduce_31,
|
332
|
-
1, 31, :_reduce_none,
|
333
|
-
1, 31, :_reduce_none,
|
325
|
+
2, 26, :_reduce_15,
|
326
|
+
1, 25, :_reduce_16,
|
327
|
+
3, 25, :_reduce_17,
|
328
|
+
3, 30, :_reduce_18,
|
329
|
+
3, 30, :_reduce_19,
|
330
|
+
4, 30, :_reduce_20,
|
331
|
+
6, 30, :_reduce_21,
|
334
332
|
1, 31, :_reduce_none,
|
335
333
|
1, 31, :_reduce_none,
|
336
|
-
1, 31, :_reduce_none,
|
337
|
-
1, 33, :_reduce_none,
|
338
334
|
1, 33, :_reduce_none,
|
339
|
-
|
340
|
-
|
341
|
-
3,
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
335
|
+
1, 33, :_reduce_25,
|
336
|
+
2, 33, :_reduce_26,
|
337
|
+
3, 33, :_reduce_27,
|
338
|
+
2, 33, :_reduce_28,
|
339
|
+
1, 35, :_reduce_29,
|
340
|
+
3, 35, :_reduce_30,
|
341
|
+
1, 36, :_reduce_none,
|
342
|
+
1, 36, :_reduce_none,
|
343
|
+
1, 36, :_reduce_none,
|
344
|
+
1, 36, :_reduce_none,
|
345
|
+
1, 37, :_reduce_none,
|
346
|
+
1, 37, :_reduce_none,
|
347
|
+
5, 38, :_reduce_37,
|
348
|
+
1, 34, :_reduce_38,
|
349
|
+
1, 34, :_reduce_39,
|
350
|
+
3, 34, :_reduce_40,
|
351
|
+
3, 34, :_reduce_41,
|
352
|
+
1, 32, :_reduce_42,
|
353
|
+
3, 32, :_reduce_43,
|
354
|
+
3, 32, :_reduce_44,
|
355
|
+
5, 32, :_reduce_45 ]
|
356
|
+
|
357
|
+
racc_reduce_n = 46
|
358
|
+
|
359
|
+
racc_shift_n = 72
|
348
360
|
|
349
361
|
racc_token_table = {
|
350
362
|
false => 0,
|
351
363
|
:error => 1,
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
"
|
358
|
-
|
359
|
-
"
|
360
|
-
|
361
|
-
|
362
|
-
"
|
364
|
+
"&" => 2,
|
365
|
+
"$" => 3,
|
366
|
+
:IDENT => 4,
|
367
|
+
:COMMA => 5,
|
368
|
+
:NL => 6,
|
369
|
+
"/" => 7,
|
370
|
+
"=" => 8,
|
371
|
+
"(" => 9,
|
372
|
+
")" => 10,
|
373
|
+
:NIL => 11,
|
374
|
+
"," => 12,
|
363
375
|
:DIGITS => 13,
|
364
376
|
"*" => 14,
|
365
377
|
:STRING => 15,
|
366
378
|
:LOGICAL => 16,
|
367
379
|
:FLOAT => 17,
|
368
|
-
|
380
|
+
:STRINGLIKE => 18,
|
381
|
+
":" => 19 }
|
369
382
|
|
370
|
-
racc_nt_base =
|
383
|
+
racc_nt_base = 20
|
371
384
|
|
372
385
|
racc_use_result_var = true
|
373
386
|
|
@@ -390,38 +403,43 @@ Racc_arg = [
|
|
390
403
|
Racc_token_to_s_table = [
|
391
404
|
"$end",
|
392
405
|
"error",
|
393
|
-
"COMMA",
|
394
|
-
"NL",
|
395
|
-
"\",\"",
|
396
|
-
"\"=\"",
|
397
406
|
"\"&\"",
|
398
407
|
"\"$\"",
|
399
408
|
"IDENT",
|
409
|
+
"COMMA",
|
410
|
+
"NL",
|
400
411
|
"\"/\"",
|
401
|
-
"
|
412
|
+
"\"=\"",
|
402
413
|
"\"(\"",
|
403
414
|
"\")\"",
|
415
|
+
"NIL",
|
416
|
+
"\",\"",
|
404
417
|
"DIGITS",
|
405
418
|
"\"*\"",
|
406
419
|
"STRING",
|
407
420
|
"LOGICAL",
|
408
421
|
"FLOAT",
|
422
|
+
"STRINGLIKE",
|
409
423
|
"\":\"",
|
410
424
|
"$start",
|
411
|
-
"namelist_all",
|
412
425
|
"namelist",
|
413
|
-
"
|
414
|
-
"
|
415
|
-
"paramlist",
|
416
|
-
"prefix",
|
426
|
+
"group",
|
427
|
+
"group_header",
|
417
428
|
"separator",
|
418
|
-
"
|
429
|
+
"varlist",
|
430
|
+
"group_end",
|
431
|
+
"group_prefix",
|
432
|
+
"nls",
|
433
|
+
"blank",
|
434
|
+
"vardef",
|
419
435
|
"rvalues",
|
420
436
|
"array_spec",
|
421
|
-
"
|
437
|
+
"rlist",
|
438
|
+
"ident_list",
|
439
|
+
"element",
|
422
440
|
"constant",
|
423
|
-
"
|
424
|
-
"
|
441
|
+
"real",
|
442
|
+
"complex" ]
|
425
443
|
|
426
444
|
Racc_debug_parser = false
|
427
445
|
|
@@ -433,174 +451,144 @@ Racc_debug_parser = false
|
|
433
451
|
|
434
452
|
# reduce 2 omitted
|
435
453
|
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
def _reduce_4(val, _values, result)
|
440
|
-
@root[val[0]] = []; @scan.in_namelist = nil
|
454
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 24)
|
455
|
+
def _reduce_3(val, _values, result)
|
456
|
+
@root[val[0]] = val[2]; @scan.in_namelist = nil
|
441
457
|
result
|
442
458
|
end
|
443
459
|
.,.,
|
444
460
|
|
445
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
446
|
-
def
|
447
|
-
@root[val[0]] =
|
461
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 26)
|
462
|
+
def _reduce_4(val, _values, result)
|
463
|
+
@root[val[0]] = []; @scan.in_namelist = nil
|
448
464
|
result
|
449
465
|
end
|
450
466
|
.,.,
|
451
467
|
|
452
|
-
# reduce
|
468
|
+
# reduce 5 omitted
|
453
469
|
|
454
|
-
# reduce
|
470
|
+
# reduce 6 omitted
|
455
471
|
|
456
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
457
|
-
def
|
472
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 34)
|
473
|
+
def _reduce_7(val, _values, result)
|
458
474
|
result = val[1].downcase; @scan.in_namelist = val[1].downcase
|
459
475
|
result
|
460
476
|
end
|
461
477
|
.,.,
|
462
478
|
|
479
|
+
# reduce 8 omitted
|
480
|
+
|
463
481
|
# reduce 9 omitted
|
464
482
|
|
465
483
|
# reduce 10 omitted
|
466
484
|
|
467
|
-
|
468
|
-
def _reduce_11(val, _values, result)
|
469
|
-
raise Racc::ParseError, "\nparse error (&)" unless val[1] =~ /\Aend\Z/i
|
470
|
-
result
|
471
|
-
end
|
472
|
-
.,.,
|
485
|
+
# reduce 11 omitted
|
473
486
|
|
474
487
|
# reduce 12 omitted
|
475
488
|
|
476
489
|
# reduce 13 omitted
|
477
490
|
|
478
|
-
|
479
|
-
def _reduce_14(val, _values, result)
|
480
|
-
result = [val[0]]
|
481
|
-
result
|
482
|
-
end
|
483
|
-
.,.,
|
491
|
+
# reduce 14 omitted
|
484
492
|
|
485
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
493
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 50)
|
486
494
|
def _reduce_15(val, _values, result)
|
487
|
-
|
495
|
+
raise Racc::ParseError, "\nparse error (&)" unless val[1] =~ /\Aend\Z/i
|
488
496
|
result
|
489
497
|
end
|
490
498
|
.,.,
|
491
499
|
|
492
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
500
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 53)
|
493
501
|
def _reduce_16(val, _values, result)
|
494
|
-
result = val[0]
|
502
|
+
result = [val[0]]
|
495
503
|
result
|
496
504
|
end
|
497
505
|
.,.,
|
498
506
|
|
499
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
507
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 55)
|
500
508
|
def _reduce_17(val, _values, result)
|
501
|
-
result =
|
509
|
+
result = val[0] + [val[2]]
|
502
510
|
result
|
503
511
|
end
|
504
512
|
.,.,
|
505
513
|
|
506
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
514
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 59)
|
507
515
|
def _reduce_18(val, _values, result)
|
508
516
|
result = ParamDef.new(val[0].downcase, nil, "")
|
509
517
|
result
|
510
518
|
end
|
511
519
|
.,.,
|
512
520
|
|
513
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
521
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 61)
|
514
522
|
def _reduce_19(val, _values, result)
|
515
523
|
result = ParamDef.new(val[0].downcase, nil, val[2])
|
516
524
|
result
|
517
525
|
end
|
518
526
|
.,.,
|
519
527
|
|
520
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
528
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 63)
|
521
529
|
def _reduce_20(val, _values, result)
|
522
|
-
result = ParamDef.new(val[0].downcase,
|
530
|
+
result = ParamDef.new(val[0].downcase, nil, val[3])
|
523
531
|
result
|
524
532
|
end
|
525
533
|
.,.,
|
526
534
|
|
527
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
535
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 65)
|
528
536
|
def _reduce_21(val, _values, result)
|
529
|
-
result = val[0]
|
537
|
+
result = ParamDef.new(val[0].downcase, val[2], val[5])
|
530
538
|
result
|
531
539
|
end
|
532
540
|
.,.,
|
533
541
|
|
534
|
-
|
535
|
-
def _reduce_22(val, _values, result)
|
536
|
-
result = val[0] + val[1]
|
537
|
-
result
|
538
|
-
end
|
539
|
-
.,.,
|
542
|
+
# reduce 22 omitted
|
540
543
|
|
541
|
-
|
542
|
-
def _reduce_23(val, _values, result)
|
543
|
-
result = val[0] + val[2]
|
544
|
-
result
|
545
|
-
end
|
546
|
-
.,.,
|
544
|
+
# reduce 23 omitted
|
547
545
|
|
548
|
-
|
549
|
-
def _reduce_24(val, _values, result)
|
550
|
-
result = val[0] + val[2]
|
551
|
-
result
|
552
|
-
end
|
553
|
-
.,.,
|
546
|
+
# reduce 24 omitted
|
554
547
|
|
555
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
548
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 73)
|
556
549
|
def _reduce_25(val, _values, result)
|
557
|
-
result =
|
550
|
+
result = [nil, nil]
|
558
551
|
result
|
559
552
|
end
|
560
553
|
.,.,
|
561
554
|
|
562
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
555
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 75)
|
563
556
|
def _reduce_26(val, _values, result)
|
564
|
-
result = [
|
557
|
+
result = val[0] + val[1]
|
565
558
|
result
|
566
559
|
end
|
567
560
|
.,.,
|
568
561
|
|
569
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
562
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 77)
|
570
563
|
def _reduce_27(val, _values, result)
|
571
|
-
result = [
|
564
|
+
result = val[0] + val[2]
|
572
565
|
result
|
573
566
|
end
|
574
567
|
.,.,
|
575
568
|
|
576
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
569
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 79)
|
577
570
|
def _reduce_28(val, _values, result)
|
578
|
-
result = val[0]
|
571
|
+
result = val[0] + [nil]
|
579
572
|
result
|
580
573
|
end
|
581
574
|
.,.,
|
582
575
|
|
583
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
576
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 82)
|
584
577
|
def _reduce_29(val, _values, result)
|
585
|
-
result = val[0]
|
586
|
-
result
|
587
|
-
end
|
588
|
-
.,.,
|
589
|
-
|
590
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 86)
|
591
|
-
def _reduce_30(val, _values, result)
|
592
578
|
result = [val[0]]
|
593
579
|
result
|
594
580
|
end
|
595
581
|
.,.,
|
596
582
|
|
597
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
598
|
-
def
|
583
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 84)
|
584
|
+
def _reduce_30(val, _values, result)
|
599
585
|
result = [val[2]] * val[0]
|
600
586
|
result
|
601
587
|
end
|
602
588
|
.,.,
|
603
589
|
|
590
|
+
# reduce 31 omitted
|
591
|
+
|
604
592
|
# reduce 32 omitted
|
605
593
|
|
606
594
|
# reduce 33 omitted
|
@@ -611,40 +599,64 @@ module_eval(<<'.,.,', 'fortran_namelist.y', 88)
|
|
611
599
|
|
612
600
|
# reduce 36 omitted
|
613
601
|
|
614
|
-
|
602
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 98)
|
603
|
+
def _reduce_37(val, _values, result)
|
604
|
+
result = Complex(val[1],val[3])
|
605
|
+
result
|
606
|
+
end
|
607
|
+
.,.,
|
615
608
|
|
616
|
-
|
609
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 101)
|
610
|
+
def _reduce_38(val, _values, result)
|
611
|
+
result = [val[0]]
|
612
|
+
result
|
613
|
+
end
|
614
|
+
.,.,
|
617
615
|
|
618
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
616
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 103)
|
619
617
|
def _reduce_39(val, _values, result)
|
620
|
-
result =
|
618
|
+
result = [val[0]]
|
621
619
|
result
|
622
620
|
end
|
623
621
|
.,.,
|
624
622
|
|
625
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
623
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 105)
|
626
624
|
def _reduce_40(val, _values, result)
|
627
|
-
result =
|
625
|
+
result = val[0] + [val[2]]
|
628
626
|
result
|
629
627
|
end
|
630
628
|
.,.,
|
631
629
|
|
632
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
630
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 107)
|
633
631
|
def _reduce_41(val, _values, result)
|
634
|
-
result =
|
632
|
+
result = val[0] + [val[2]]
|
635
633
|
result
|
636
634
|
end
|
637
635
|
.,.,
|
638
636
|
|
639
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
637
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 110)
|
640
638
|
def _reduce_42(val, _values, result)
|
641
|
-
result = [val[0]-1]
|
639
|
+
result = [val[0]-1]
|
642
640
|
result
|
643
641
|
end
|
644
642
|
.,.,
|
645
643
|
|
646
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
644
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 112)
|
647
645
|
def _reduce_43(val, _values, result)
|
646
|
+
result = [(val[0]-1)..(val[2]-1)]
|
647
|
+
result
|
648
|
+
end
|
649
|
+
.,.,
|
650
|
+
|
651
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 114)
|
652
|
+
def _reduce_44(val, _values, result)
|
653
|
+
result = [val[0]-1] + val[2]
|
654
|
+
result
|
655
|
+
end
|
656
|
+
.,.,
|
657
|
+
|
658
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 116)
|
659
|
+
def _reduce_45(val, _values, result)
|
648
660
|
result = [(val[0]-1)..(val[2]-1)] + val[4]
|
649
661
|
result
|
650
662
|
end
|