fortio-namelist 1.0.0 → 1.4.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 +33 -0
- data/README.md +365 -33
- data/fortio-namelist.gemspec +7 -4
- data/lib/fortio-namelist/fortran_namelist.rb +86 -43
- data/lib/fortio-namelist/fortran_namelist.tab.rb +260 -235
- data/lib/fortio-namelist/fortran_namelist.y +103 -70
- data/spec/array_spec.rb +160 -0
- data/spec/dump_spec.rb +51 -0
- data/spec/empty_spec.rb +66 -0
- data/spec/identifier_spec.rb +81 -0
- data/spec/scalar_spec.rb +196 -0
- data/spec/structure_spec.rb +162 -0
- metadata +28 -5
data/fortio-namelist.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Gem::Specification::new do |s|
|
2
|
-
version = "1.
|
2
|
+
version = "1.4.0"
|
3
3
|
files = Dir.glob("**/*") - [
|
4
4
|
Dir.glob("fortio-namelist-*.gem"),
|
5
5
|
Dir.glob("test/**/*"),
|
@@ -10,14 +10,17 @@ Gem::Specification::new do |s|
|
|
10
10
|
s.name = "fortio-namelist"
|
11
11
|
s.summary = "A library for reading/writing fortran namelist file"
|
12
12
|
s.description = <<-HERE
|
13
|
-
|
13
|
+
This is a Ruby library for reading and writing Fortran's namelist.
|
14
|
+
This library allows you to read a namelist string as a Hash object,
|
15
|
+
or dump a Hash object to a namelist string.
|
14
16
|
HERE
|
15
17
|
s.version = version
|
16
|
-
s.
|
18
|
+
s.license = 'MIT'
|
17
19
|
s.author = "Hiroki Motoyoshi"
|
18
20
|
s.email = ""
|
19
21
|
s.homepage = 'https://github.com/himotoyoshi/fortio-namelist'
|
20
22
|
s.files = files
|
21
|
-
s.required_ruby_version = ">=
|
23
|
+
s.required_ruby_version = ">= 2.4.0"
|
24
|
+
s.add_development_dependency "racc", "~> 1.5"
|
22
25
|
end
|
23
26
|
|
@@ -72,24 +72,16 @@ module FortIO::Namelist
|
|
72
72
|
@namelist = FortIO::Namelist::Parser.new.parse(text)
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
76
|
-
|
77
|
-
raise "no definition of namelist '#{
|
75
|
+
def parse (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,19 @@ 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.
|
100
|
+
def self.float_to_string (value, d:)
|
101
|
+
return value.to_s.sub(/e/, d)
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.format_element (value,
|
105
|
+
logical_format: 'normal',
|
106
|
+
float_format: 'normal',
|
107
|
+
uppercase: false)
|
109
108
|
case value
|
110
109
|
when String
|
111
110
|
if value !~ /'/
|
@@ -117,12 +116,13 @@ module FortIO::Namelist
|
|
117
116
|
d = uppercase ? "D" : "d"
|
118
117
|
case float_format
|
119
118
|
when 'normal'
|
120
|
-
|
119
|
+
float_to_string(value, d: d)
|
121
120
|
when 'd0'
|
122
|
-
value = (
|
123
|
-
return ( value =~ /
|
121
|
+
value = float_to_string(value, d: d)
|
122
|
+
return ( value =~ /#{d}/ ) ? value : value + d + "0"
|
124
123
|
when 'exp'
|
125
|
-
|
124
|
+
num,exp = ("%.16e" % value).split(/e/)
|
125
|
+
return ("%.16g" % num) + d + exp
|
126
126
|
else
|
127
127
|
raise "invalid float_format"
|
128
128
|
end
|
@@ -154,12 +154,12 @@ module FortIO::Namelist
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def self.generate (hash,
|
157
|
-
|
157
|
+
group: "group",
|
158
158
|
array_style: "stream",
|
159
159
|
alignment: "left",
|
160
160
|
uppercase: false,
|
161
|
-
|
162
|
-
|
161
|
+
separator: "comma",
|
162
|
+
group_end: "/",
|
163
163
|
indent: ' ',
|
164
164
|
**format_options)
|
165
165
|
format_options[:uppercase] = uppercase
|
@@ -177,7 +177,7 @@ module FortIO::Namelist
|
|
177
177
|
when "stream"
|
178
178
|
list << [ident, value.map{ |e| format_element(e, **format_options) }.join(", ")]
|
179
179
|
else
|
180
|
-
raise "
|
180
|
+
raise "invalid keyword argument `array_style` (should be 'index', 'stream')"
|
181
181
|
end
|
182
182
|
else
|
183
183
|
list << [ident, format_element(value, **format_options)]
|
@@ -185,62 +185,105 @@ module FortIO::Namelist
|
|
185
185
|
end
|
186
186
|
if uppercase
|
187
187
|
list = list.map{|ident,value| [ident.upcase, value]}
|
188
|
-
|
188
|
+
group = group.upcase
|
189
189
|
end
|
190
|
-
|
190
|
+
case separator
|
191
|
+
when "comma", ","
|
191
192
|
nl = ",\n"
|
192
|
-
|
193
|
+
when "nl", "\n"
|
193
194
|
nl = "\n"
|
195
|
+
else
|
196
|
+
raise "invalid keyword argument `separator` (should be 'comma', ',', 'nl', '\n')"
|
194
197
|
end
|
195
198
|
case alignment
|
199
|
+
when /\Astream(:(\d+))?/
|
200
|
+
maxlen = $2 ? $2.to_i : 79 - indent.size
|
201
|
+
elements = list.map { |ident, value|
|
202
|
+
format("%s = %s", ident, value)
|
203
|
+
}
|
204
|
+
body = ""
|
205
|
+
line = []
|
206
|
+
len = indent.size
|
207
|
+
elements.each do |e|
|
208
|
+
if len + e.length >= maxlen
|
209
|
+
body += indent + line.join(", ") + nl
|
210
|
+
line = []
|
211
|
+
len = indent.size
|
212
|
+
end
|
213
|
+
line << e
|
214
|
+
len += e.length + 2
|
215
|
+
end
|
216
|
+
body += indent + line.join(", ") + nl unless line.empty?
|
217
|
+
body = body.chomp
|
196
218
|
when "none"
|
197
219
|
body = list.map { |ident, value|
|
198
220
|
format("%s%s = %s", indent, ident, value)
|
199
221
|
}.join(nl)
|
200
|
-
when
|
201
|
-
|
222
|
+
when /\Aleft(:(\d+))?/
|
223
|
+
if $2
|
224
|
+
ident_maxlen = $2.to_i - indent.size
|
225
|
+
else
|
226
|
+
ident_maxlen = list.map{|ident,value| ident.length}.max
|
227
|
+
end
|
202
228
|
body = list.map { |ident, value|
|
203
229
|
format("%s%-#{ident_maxlen}s = %s", indent, ident, value)
|
204
230
|
}.join(nl)
|
205
|
-
when
|
206
|
-
|
231
|
+
when /\Aright(:(\d+))?/
|
232
|
+
if $2
|
233
|
+
ident_maxlen = $2.to_i - indent.size
|
234
|
+
else
|
235
|
+
ident_maxlen = list.map{|ident,value| ident.length}.max
|
236
|
+
end
|
207
237
|
body = list.map { |ident, value|
|
208
238
|
format("%s%#{ident_maxlen}s = %s", indent, ident, value)
|
209
239
|
}.join(nl)
|
210
|
-
when Integer
|
211
|
-
body = list.map { |ident, value|
|
212
|
-
format("%s%-#{alignment-2}s = %s", indent, ident, value)
|
213
|
-
}.join(nl)
|
214
240
|
else
|
215
|
-
raise "
|
241
|
+
raise "invalid keyword argument `alignment` (should be 'normal' 'left' 'right' 'stream')"
|
216
242
|
end
|
217
|
-
|
243
|
+
case group_end
|
244
|
+
when "slash", "/"
|
218
245
|
tail = "/"
|
219
|
-
|
246
|
+
when "end"
|
220
247
|
tail = "&end"
|
248
|
+
else
|
249
|
+
raise "invalid keyword argument `group_end` (should be 'slash', '/', 'end')"
|
221
250
|
end
|
222
|
-
return ["&#{
|
251
|
+
return ["&#{group}", body, tail, ""].join("\n")
|
223
252
|
end
|
224
253
|
|
225
254
|
def self.dump (root, **format_options)
|
226
|
-
return root.map { |
|
255
|
+
return root.map { |group, hash| generate(hash, group: group, **format_options) }.join
|
227
256
|
end
|
228
257
|
|
229
258
|
#
|
230
259
|
# FortIO::Namelist.read(input, name: nil)
|
231
260
|
#
|
232
|
-
def self.
|
261
|
+
def self.parse (input, group: nil)
|
233
262
|
case input
|
234
263
|
when String
|
235
264
|
text = input
|
236
265
|
else
|
237
266
|
text = input.read
|
238
267
|
end
|
239
|
-
|
240
|
-
|
268
|
+
reader = FortIO::Namelist::Reader.new(text)
|
269
|
+
case group
|
270
|
+
when Array
|
271
|
+
groups = group.map{|s| s.intern }
|
272
|
+
when String, Symbol
|
273
|
+
groups = [group].map{|s| s.intern }
|
274
|
+
when nil
|
275
|
+
groups = reader.namelist.keys
|
241
276
|
else
|
242
|
-
|
277
|
+
raise "invalid keyword arugment `group` '#{group.inspect}'"
|
243
278
|
end
|
279
|
+
return groups.each_with_object({}) { |group, root|
|
280
|
+
root[group] = {}
|
281
|
+
reader.parse(group, root[group])
|
282
|
+
}
|
283
|
+
end
|
284
|
+
|
285
|
+
def self.read (input, group: nil)
|
286
|
+
parse(input, group: group)
|
244
287
|
end
|
245
288
|
|
246
289
|
#
|
@@ -250,7 +293,7 @@ module FortIO::Namelist
|
|
250
293
|
# return value : namelist string
|
251
294
|
#
|
252
295
|
def self.filter (input, **format_options)
|
253
|
-
config =
|
296
|
+
config = parse(input)
|
254
297
|
yield config
|
255
298
|
return dump(config, **format_options)
|
256
299
|
end
|
@@ -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,17 +141,17 @@ 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
|
-
when @s.scan(/\A\.t
|
149
|
+
when @s.scan(/\A\.t[\w\d_]*\.?/i) ### LOGICAL true
|
130
150
|
return [
|
131
151
|
:LOGICAL,
|
132
152
|
true,
|
133
153
|
]
|
134
|
-
when @s.scan(/\A\.f
|
154
|
+
when @s.scan(/\A\.f[\w\d_]*\.?/i) ### LOGICAL false
|
135
155
|
return [
|
136
156
|
:LOGICAL,
|
137
157
|
false,
|
@@ -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', 128)
|
198
218
|
|
199
219
|
def parse (str)
|
200
220
|
@scan = FortIO::Namelist::Scanner.new(str)
|
@@ -223,151 +243,151 @@ 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
|
+
65, 51, 63, 14, 48, 4, 5, 21, 47, 62,
|
247
|
+
18, 39, 15, 41, 66, 42, 43, 46, 49, 48,
|
248
|
+
34, 13, 13, 47, 26, 30, 39, 24, 41, 47,
|
249
|
+
42, 43, 46, 49, 41, 51, 42, 43, 46, 47,
|
250
|
+
4, 5, 56, 55, 41, 47, 42, 43, 46, 13,
|
251
|
+
59, 13, 42, 43, 46, 4, 5, 21, 59, 13,
|
252
|
+
18, 29, 46, 30, 59, 24, 23, 24, 46, 33,
|
253
|
+
7, 57, 4, 5, 10, 13, 10, 13, 58, 61,
|
254
|
+
24, 24, 68, 70, 51, 74, 75 ]
|
241
255
|
|
242
256
|
racc_action_check = [
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
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
|
+
57, 74, 51, 6, 69, 25, 25, 25, 69, 51,
|
258
|
+
25, 69, 7, 69, 57, 69, 69, 69, 69, 28,
|
259
|
+
28, 61, 10, 28, 19, 61, 28, 22, 28, 55,
|
260
|
+
28, 28, 28, 28, 55, 29, 55, 55, 55, 36,
|
261
|
+
0, 0, 36, 36, 36, 58, 36, 36, 36, 30,
|
262
|
+
58, 33, 58, 58, 58, 9, 9, 9, 47, 21,
|
263
|
+
9, 21, 47, 21, 68, 27, 11, 11, 68, 27,
|
264
|
+
1, 37, 1, 1, 16, 16, 3, 3, 41, 50,
|
265
|
+
52, 53, 60, 62, 63, 70, 72 ]
|
258
266
|
|
259
267
|
racc_action_pointer = [
|
260
|
-
|
261
|
-
|
262
|
-
nil,
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
268
|
+
38, 70, nil, 71, nil, nil, -1, 12, nil, 53,
|
269
|
+
16, 61, nil, nil, nil, nil, 69, nil, nil, 20,
|
270
|
+
nil, 53, 21, nil, nil, 3, nil, 59, 15, 22,
|
271
|
+
43, nil, nil, 45, nil, nil, 31, 59, nil, nil,
|
272
|
+
nil, 64, nil, nil, nil, nil, nil, 45, nil, nil,
|
273
|
+
70, -10, 74, 75, nil, 21, nil, -4, 37, nil,
|
274
|
+
70, 15, 70, 71, nil, nil, nil, nil, 51, 0,
|
275
|
+
73, nil, 77, nil, -12, nil, nil ]
|
267
276
|
|
268
277
|
racc_action_default = [
|
269
|
-
|
270
|
-
|
271
|
-
-
|
272
|
-
-
|
273
|
-
-
|
274
|
-
-
|
275
|
-
-
|
278
|
+
-51, -51, -2, -15, -5, -6, -51, -51, -1, -51,
|
279
|
+
-8, -11, -12, -13, -7, 77, -15, -4, -16, -51,
|
280
|
+
-18, -51, -9, -10, -14, -51, -17, -51, -51, -51,
|
281
|
+
-23, -3, -19, -25, -20, -21, -27, -28, -29, -30,
|
282
|
+
-34, -40, -36, -37, -38, -39, -41, -51, -43, -44,
|
283
|
+
-51, -47, -24, -26, -31, -51, -33, -51, -51, -40,
|
284
|
+
-51, -51, -51, -51, -32, -45, -46, -35, -51, -51,
|
285
|
+
-48, -49, -51, -22, -51, -42, -50 ]
|
276
286
|
|
277
287
|
racc_goto_table = [
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
nil, nil, nil, nil, nil, nil, nil,
|
282
|
-
|
288
|
+
22, 50, 35, 60, 28, 20, 54, 2, 8, 9,
|
289
|
+
17, 27, 19, 1, 16, 67, nil, nil, nil, nil,
|
290
|
+
52, 32, 25, 53, 72, 64, 31, nil, 19, nil,
|
291
|
+
nil, nil, nil, nil, nil, 71, nil, nil, nil, nil,
|
292
|
+
nil, nil, nil, 73, 69, nil, 76, nil, nil, nil,
|
293
|
+
nil, 27 ]
|
283
294
|
|
284
295
|
racc_goto_check = [
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
nil, nil, nil, nil, nil, nil, nil,
|
289
|
-
|
296
|
+
8, 13, 12, 18, 11, 10, 16, 2, 2, 4,
|
297
|
+
6, 8, 7, 1, 5, 17, nil, nil, nil, nil,
|
298
|
+
8, 10, 4, 8, 18, 16, 6, nil, 7, nil,
|
299
|
+
nil, nil, nil, nil, nil, 13, nil, nil, nil, nil,
|
300
|
+
nil, nil, nil, 12, 11, nil, 13, nil, nil, nil,
|
301
|
+
nil, 8 ]
|
290
302
|
|
291
303
|
racc_goto_pointer = [
|
292
|
-
nil,
|
293
|
-
-
|
304
|
+
nil, 13, 7, nil, 6, 5, 1, 3, -10, nil,
|
305
|
+
-4, -17, -26, -28, nil, nil, -30, -43, -44, nil ]
|
294
306
|
|
295
307
|
racc_goto_default = [
|
296
|
-
nil, nil,
|
297
|
-
nil,
|
308
|
+
nil, nil, nil, 3, nil, nil, nil, 6, 11, 12,
|
309
|
+
nil, nil, nil, nil, 36, 37, 38, 40, 44, 45 ]
|
298
310
|
|
299
311
|
racc_reduce_table = [
|
300
312
|
0, 0, :racc_error,
|
301
|
-
|
302
|
-
1,
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
1,
|
307
|
-
|
308
|
-
|
309
|
-
2,
|
310
|
-
|
311
|
-
|
313
|
+
2, 21, :_reduce_none,
|
314
|
+
1, 21, :_reduce_none,
|
315
|
+
5, 22, :_reduce_3,
|
316
|
+
3, 22, :_reduce_4,
|
317
|
+
1, 27, :_reduce_none,
|
318
|
+
1, 27, :_reduce_none,
|
319
|
+
2, 23, :_reduce_7,
|
320
|
+
1, 24, :_reduce_none,
|
321
|
+
2, 24, :_reduce_none,
|
322
|
+
2, 24, :_reduce_none,
|
323
|
+
1, 24, :_reduce_none,
|
324
|
+
1, 24, :_reduce_none,
|
325
|
+
1, 28, :_reduce_none,
|
326
|
+
2, 28, :_reduce_none,
|
327
|
+
0, 29, :_reduce_none,
|
312
328
|
1, 26, :_reduce_none,
|
313
|
-
|
314
|
-
1,
|
315
|
-
|
316
|
-
|
317
|
-
3,
|
318
|
-
|
319
|
-
3, 27, :_reduce_19,
|
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,
|
329
|
+
2, 26, :_reduce_17,
|
330
|
+
1, 25, :_reduce_18,
|
331
|
+
3, 25, :_reduce_19,
|
332
|
+
3, 30, :_reduce_20,
|
333
|
+
3, 30, :_reduce_21,
|
334
|
+
6, 30, :_reduce_22,
|
334
335
|
1, 31, :_reduce_none,
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
1,
|
339
|
-
|
340
|
-
1,
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
336
|
+
2, 31, :_reduce_none,
|
337
|
+
2, 31, :_reduce_none,
|
338
|
+
3, 31, :_reduce_none,
|
339
|
+
1, 32, :_reduce_none,
|
340
|
+
1, 32, :_reduce_none,
|
341
|
+
1, 34, :_reduce_none,
|
342
|
+
1, 34, :_reduce_30,
|
343
|
+
2, 34, :_reduce_31,
|
344
|
+
3, 34, :_reduce_32,
|
345
|
+
2, 34, :_reduce_33,
|
346
|
+
1, 36, :_reduce_34,
|
347
|
+
3, 36, :_reduce_35,
|
348
|
+
1, 37, :_reduce_none,
|
349
|
+
1, 37, :_reduce_none,
|
350
|
+
1, 37, :_reduce_none,
|
351
|
+
1, 37, :_reduce_none,
|
352
|
+
1, 38, :_reduce_none,
|
353
|
+
1, 38, :_reduce_none,
|
354
|
+
5, 39, :_reduce_42,
|
355
|
+
1, 35, :_reduce_43,
|
356
|
+
1, 35, :_reduce_44,
|
357
|
+
3, 35, :_reduce_45,
|
358
|
+
3, 35, :_reduce_46,
|
359
|
+
1, 33, :_reduce_47,
|
360
|
+
3, 33, :_reduce_48,
|
361
|
+
3, 33, :_reduce_49,
|
362
|
+
5, 33, :_reduce_50 ]
|
363
|
+
|
364
|
+
racc_reduce_n = 51
|
365
|
+
|
366
|
+
racc_shift_n = 77
|
348
367
|
|
349
368
|
racc_token_table = {
|
350
369
|
false => 0,
|
351
370
|
:error => 1,
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
"
|
358
|
-
|
359
|
-
"
|
360
|
-
|
361
|
-
|
362
|
-
"
|
371
|
+
"&" => 2,
|
372
|
+
"$" => 3,
|
373
|
+
:IDENT => 4,
|
374
|
+
:COMMA => 5,
|
375
|
+
:NL => 6,
|
376
|
+
"/" => 7,
|
377
|
+
"(" => 8,
|
378
|
+
")" => 9,
|
379
|
+
"=" => 10,
|
380
|
+
:NIL => 11,
|
381
|
+
"," => 12,
|
363
382
|
:DIGITS => 13,
|
364
383
|
"*" => 14,
|
365
384
|
:STRING => 15,
|
366
385
|
:LOGICAL => 16,
|
367
386
|
:FLOAT => 17,
|
368
|
-
|
387
|
+
:STRINGLIKE => 18,
|
388
|
+
":" => 19 }
|
369
389
|
|
370
|
-
racc_nt_base =
|
390
|
+
racc_nt_base = 20
|
371
391
|
|
372
392
|
racc_use_result_var = true
|
373
393
|
|
@@ -390,38 +410,44 @@ Racc_arg = [
|
|
390
410
|
Racc_token_to_s_table = [
|
391
411
|
"$end",
|
392
412
|
"error",
|
393
|
-
"COMMA",
|
394
|
-
"NL",
|
395
|
-
"\",\"",
|
396
|
-
"\"=\"",
|
397
413
|
"\"&\"",
|
398
414
|
"\"$\"",
|
399
415
|
"IDENT",
|
416
|
+
"COMMA",
|
417
|
+
"NL",
|
400
418
|
"\"/\"",
|
401
|
-
"NIL",
|
402
419
|
"\"(\"",
|
403
420
|
"\")\"",
|
421
|
+
"\"=\"",
|
422
|
+
"NIL",
|
423
|
+
"\",\"",
|
404
424
|
"DIGITS",
|
405
425
|
"\"*\"",
|
406
426
|
"STRING",
|
407
427
|
"LOGICAL",
|
408
428
|
"FLOAT",
|
429
|
+
"STRINGLIKE",
|
409
430
|
"\":\"",
|
410
431
|
"$start",
|
411
|
-
"namelist_all",
|
412
432
|
"namelist",
|
413
|
-
"
|
414
|
-
"
|
415
|
-
"paramlist",
|
416
|
-
"prefix",
|
433
|
+
"group",
|
434
|
+
"group_header",
|
417
435
|
"separator",
|
418
|
-
"
|
436
|
+
"varlist",
|
437
|
+
"group_end",
|
438
|
+
"group_prefix",
|
439
|
+
"nls",
|
440
|
+
"blank",
|
441
|
+
"vardef",
|
442
|
+
"equal",
|
419
443
|
"rvalues",
|
420
444
|
"array_spec",
|
421
|
-
"
|
445
|
+
"rlist",
|
446
|
+
"ident_list",
|
447
|
+
"element",
|
422
448
|
"constant",
|
423
|
-
"
|
424
|
-
"
|
449
|
+
"real",
|
450
|
+
"complex" ]
|
425
451
|
|
426
452
|
Racc_debug_parser = false
|
427
453
|
|
@@ -433,218 +459,217 @@ Racc_debug_parser = false
|
|
433
459
|
|
434
460
|
# reduce 2 omitted
|
435
461
|
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
def _reduce_4(val, _values, result)
|
440
|
-
@root[val[0]] = []; @scan.in_namelist = nil
|
462
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 24)
|
463
|
+
def _reduce_3(val, _values, result)
|
464
|
+
@root[val[0]] = val[2]; @scan.in_namelist = nil
|
441
465
|
result
|
442
466
|
end
|
443
467
|
.,.,
|
444
468
|
|
445
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
446
|
-
def
|
447
|
-
@root[val[0]] =
|
469
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 26)
|
470
|
+
def _reduce_4(val, _values, result)
|
471
|
+
@root[val[0]] = []; @scan.in_namelist = nil
|
448
472
|
result
|
449
473
|
end
|
450
474
|
.,.,
|
451
475
|
|
452
|
-
# reduce
|
476
|
+
# reduce 5 omitted
|
453
477
|
|
454
|
-
# reduce
|
478
|
+
# reduce 6 omitted
|
455
479
|
|
456
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
457
|
-
def
|
458
|
-
result = val[1].downcase; @scan.in_namelist = val[1].downcase
|
480
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 34)
|
481
|
+
def _reduce_7(val, _values, result)
|
482
|
+
result = val[1].downcase.intern; @scan.in_namelist = val[1].downcase.intern
|
459
483
|
result
|
460
484
|
end
|
461
485
|
.,.,
|
462
486
|
|
487
|
+
# reduce 8 omitted
|
488
|
+
|
463
489
|
# reduce 9 omitted
|
464
490
|
|
465
491
|
# reduce 10 omitted
|
466
492
|
|
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
|
-
.,.,
|
493
|
+
# reduce 11 omitted
|
473
494
|
|
474
495
|
# reduce 12 omitted
|
475
496
|
|
476
497
|
# reduce 13 omitted
|
477
498
|
|
478
|
-
|
479
|
-
def _reduce_14(val, _values, result)
|
480
|
-
result = [val[0]]
|
481
|
-
result
|
482
|
-
end
|
483
|
-
.,.,
|
499
|
+
# reduce 14 omitted
|
484
500
|
|
485
|
-
|
486
|
-
def _reduce_15(val, _values, result)
|
487
|
-
result = val[0] + [val[1]]
|
488
|
-
result
|
489
|
-
end
|
490
|
-
.,.,
|
501
|
+
# reduce 15 omitted
|
491
502
|
|
492
|
-
|
493
|
-
def _reduce_16(val, _values, result)
|
494
|
-
result = val[0]
|
495
|
-
result
|
496
|
-
end
|
497
|
-
.,.,
|
503
|
+
# reduce 16 omitted
|
498
504
|
|
499
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
505
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 52)
|
500
506
|
def _reduce_17(val, _values, result)
|
501
|
-
|
507
|
+
raise Racc::ParseError, "\nparse error (&)" unless val[1] =~ /\Aend\Z/i
|
502
508
|
result
|
503
509
|
end
|
504
510
|
.,.,
|
505
511
|
|
506
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
512
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 55)
|
507
513
|
def _reduce_18(val, _values, result)
|
508
|
-
result =
|
514
|
+
result = [val[0]]
|
509
515
|
result
|
510
516
|
end
|
511
517
|
.,.,
|
512
518
|
|
513
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
519
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 57)
|
514
520
|
def _reduce_19(val, _values, result)
|
515
|
-
result =
|
521
|
+
result = val[0] + [val[2]]
|
516
522
|
result
|
517
523
|
end
|
518
524
|
.,.,
|
519
525
|
|
520
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
526
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 61)
|
521
527
|
def _reduce_20(val, _values, result)
|
522
|
-
result = ParamDef.new(val[0].downcase,
|
528
|
+
result = ParamDef.new(val[0].downcase.intern, nil, "")
|
523
529
|
result
|
524
530
|
end
|
525
531
|
.,.,
|
526
532
|
|
527
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
533
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 63)
|
528
534
|
def _reduce_21(val, _values, result)
|
529
|
-
result = val[0]
|
535
|
+
result = ParamDef.new(val[0].downcase.intern, nil, val[2])
|
530
536
|
result
|
531
537
|
end
|
532
538
|
.,.,
|
533
539
|
|
534
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
540
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 65)
|
535
541
|
def _reduce_22(val, _values, result)
|
536
|
-
result = val[0]
|
542
|
+
result = ParamDef.new(val[0].downcase.intern, val[2], val[5])
|
537
543
|
result
|
538
544
|
end
|
539
545
|
.,.,
|
540
546
|
|
541
|
-
|
542
|
-
|
543
|
-
|
547
|
+
# reduce 23 omitted
|
548
|
+
|
549
|
+
# reduce 24 omitted
|
550
|
+
|
551
|
+
# reduce 25 omitted
|
552
|
+
|
553
|
+
# reduce 26 omitted
|
554
|
+
|
555
|
+
# reduce 27 omitted
|
556
|
+
|
557
|
+
# reduce 28 omitted
|
558
|
+
|
559
|
+
# reduce 29 omitted
|
560
|
+
|
561
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 79)
|
562
|
+
def _reduce_30(val, _values, result)
|
563
|
+
result = [nil, nil]
|
544
564
|
result
|
545
565
|
end
|
546
566
|
.,.,
|
547
567
|
|
548
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
549
|
-
def
|
568
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 81)
|
569
|
+
def _reduce_31(val, _values, result)
|
570
|
+
result = val[0] + val[1]
|
571
|
+
result
|
572
|
+
end
|
573
|
+
.,.,
|
574
|
+
|
575
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 83)
|
576
|
+
def _reduce_32(val, _values, result)
|
550
577
|
result = val[0] + val[2]
|
551
578
|
result
|
552
579
|
end
|
553
580
|
.,.,
|
554
581
|
|
555
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
556
|
-
def
|
582
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 85)
|
583
|
+
def _reduce_33(val, _values, result)
|
557
584
|
result = val[0] + [nil]
|
558
585
|
result
|
559
586
|
end
|
560
587
|
.,.,
|
561
588
|
|
562
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
563
|
-
def
|
564
|
-
result = [
|
589
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 88)
|
590
|
+
def _reduce_34(val, _values, result)
|
591
|
+
result = [val[0]]
|
565
592
|
result
|
566
593
|
end
|
567
594
|
.,.,
|
568
595
|
|
569
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
570
|
-
def
|
571
|
-
result = [
|
596
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 90)
|
597
|
+
def _reduce_35(val, _values, result)
|
598
|
+
result = [val[2]] * val[0]
|
572
599
|
result
|
573
600
|
end
|
574
601
|
.,.,
|
575
602
|
|
576
|
-
|
577
|
-
|
578
|
-
|
603
|
+
# reduce 36 omitted
|
604
|
+
|
605
|
+
# reduce 37 omitted
|
606
|
+
|
607
|
+
# reduce 38 omitted
|
608
|
+
|
609
|
+
# reduce 39 omitted
|
610
|
+
|
611
|
+
# reduce 40 omitted
|
612
|
+
|
613
|
+
# reduce 41 omitted
|
614
|
+
|
615
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 104)
|
616
|
+
def _reduce_42(val, _values, result)
|
617
|
+
result = Complex(val[1],val[3])
|
579
618
|
result
|
580
619
|
end
|
581
620
|
.,.,
|
582
621
|
|
583
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
584
|
-
def
|
585
|
-
result = val[0]
|
622
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 107)
|
623
|
+
def _reduce_43(val, _values, result)
|
624
|
+
result = [val[0]]
|
586
625
|
result
|
587
626
|
end
|
588
627
|
.,.,
|
589
628
|
|
590
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
591
|
-
def
|
629
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 109)
|
630
|
+
def _reduce_44(val, _values, result)
|
592
631
|
result = [val[0]]
|
593
632
|
result
|
594
633
|
end
|
595
634
|
.,.,
|
596
635
|
|
597
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
598
|
-
def
|
599
|
-
result =
|
636
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 111)
|
637
|
+
def _reduce_45(val, _values, result)
|
638
|
+
result = val[0] + [val[2]]
|
600
639
|
result
|
601
640
|
end
|
602
641
|
.,.,
|
603
642
|
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
# reduce 34 omitted
|
609
|
-
|
610
|
-
# reduce 35 omitted
|
611
|
-
|
612
|
-
# reduce 36 omitted
|
613
|
-
|
614
|
-
# reduce 37 omitted
|
615
|
-
|
616
|
-
# reduce 38 omitted
|
617
|
-
|
618
|
-
module_eval(<<'.,.,', 'fortran_namelist.y', 100)
|
619
|
-
def _reduce_39(val, _values, result)
|
620
|
-
result = Complex(val[1],val[3])
|
643
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 113)
|
644
|
+
def _reduce_46(val, _values, result)
|
645
|
+
result = val[0] + [val[2]]
|
621
646
|
result
|
622
647
|
end
|
623
648
|
.,.,
|
624
649
|
|
625
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
626
|
-
def
|
650
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 116)
|
651
|
+
def _reduce_47(val, _values, result)
|
627
652
|
result = [val[0]-1]
|
628
653
|
result
|
629
654
|
end
|
630
655
|
.,.,
|
631
656
|
|
632
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
633
|
-
def
|
657
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 118)
|
658
|
+
def _reduce_48(val, _values, result)
|
634
659
|
result = [(val[0]-1)..(val[2]-1)]
|
635
660
|
result
|
636
661
|
end
|
637
662
|
.,.,
|
638
663
|
|
639
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
640
|
-
def
|
664
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 120)
|
665
|
+
def _reduce_49(val, _values, result)
|
641
666
|
result = [val[0]-1] + val[2]
|
642
667
|
result
|
643
668
|
end
|
644
669
|
.,.,
|
645
670
|
|
646
|
-
module_eval(<<'.,.,', 'fortran_namelist.y',
|
647
|
-
def
|
671
|
+
module_eval(<<'.,.,', 'fortran_namelist.y', 122)
|
672
|
+
def _reduce_50(val, _values, result)
|
648
673
|
result = [(val[0]-1)..(val[2]-1)] + val[4]
|
649
674
|
result
|
650
675
|
end
|