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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eec83d1e80ab4d715f85a1e51d57a233995612e323f2729018756cd773b907e2
4
- data.tar.gz: 97f524e2c0cfaae551c79fa48154c58e3ec5c1871f7e3544779fa49bc1333714
3
+ metadata.gz: c44816ef76988ff0fb717b4d8d67eab2525e96341e01292be61b589ad5863c64
4
+ data.tar.gz: '0572478dd329fea60bd37dce6095b188f25c7ede6d3fc8bc9424cbf7a56762d5'
5
5
  SHA512:
6
- metadata.gz: cf29f5ab82c904800ced9c0e4a61672e536fc9ba58c9e30b96b0ed4ffbed6b4b2a9b371a3f5ce6ec5c5fbc9f6af7269a9661aeb45f1f46a5c1a3653316d313f5
7
- data.tar.gz: 32101d550a483bd675f2b350f022357d4784ded6bdc944cc92449f6e6c9aaa53e1a41ea26b6816284d2b96777ade58fad0f75275964089d1e87d83a2b44a89ee
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. Once the namelist format is read as a Hash object, it is easy to modify the contents or convert it to another format such as JSON, YAML, etc. When converting from a Hash object to namelist format, options can be specified to specify the case of variable names and the format of logical values and floating point numbers. The namelist format is often used as a configuration file to control a calculation program using Fortran. This library can be especially useful for batch processing by sequentially changing the settings of a calculation program. It can also improve the appearance of the namelist output from a Fortran program to make it easier to check. Since the namelist format and JSON (or YAML) can be converted to each other, it is also a good idea to use it to create web interfaces that facilitate the configuration of programs.
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
- Description
24
+ Usage
18
25
  -----------
19
26
 
20
- # Reading namelist data
27
+ ### Reading namelist format string
21
28
 
22
- FortIO::Namelist.read(input, name: nil)
29
+ To create a Hash object with Namelist structure by reading a string in namelist format, use the following method.
23
30
 
24
- # Generate namelist format from Hash object
25
- FortIO::Namelist.generate(hash, name: "namelist", array_format: 'stream')
31
+ FortIO::Namelist.read(input, group: nil)
26
32
 
27
- # 複数のデータセットを含むHashからnamelist形式を生成する
28
- FortIO::Namelist.dump(root, **format_options)
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
- # namelistデータを読み込み、blockで評価して、結果をnamelistに変換する
31
- FortIO::Namelist.filter(input, **format_options) { |hash| ... }
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
- # generate, dump, filterが受け付けるオプション
90
+ ### Generating namelist format string from Hash object with namelist structure
34
91
 
35
- array_style: 'index'
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: 'compact'
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: false
53
- true
54
-
55
- slash: true
56
- false
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
+ /
@@ -1,5 +1,5 @@
1
1
  Gem::Specification::new do |s|
2
- version = "1.0.0"
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 = ">= 1.8.1"
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 (name, out={})
76
- name = name.downcase
77
- raise "no definition of namelist '#{name}'" unless nml = @namelist[name]
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, name: "namelist")
95
+ # FortIO::Namelist.dump(hash, group: "namelist")
104
96
  #
105
97
  # hash -> namelist converter
106
98
  #
107
99
 
108
- def self.format_element (value, logical_format: 'normal', float_format: 'normal', uppercase: false)
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
- name: "namelist",
152
+ group: "group",
158
153
  array_style: "stream",
159
154
  alignment: "left",
160
155
  uppercase: false,
161
- comma: false,
162
- slash: true,
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 "unknown array style (should be 'index' or 'stream')"
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
- name = name.upcase
183
+ group = group.upcase
189
184
  end
190
- if comma
185
+ case separator
186
+ when "comma", ","
191
187
  nl = ",\n"
192
- else
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 "unknown enum format (should be 'normal' 'left' 'right' 'stream')"
213
+ raise "invalid keyword argument `alignment` (should be 'normal' 'left' 'right' 'stream')"
216
214
  end
217
- if slash
215
+ case group_end
216
+ when "slash", "/"
218
217
  tail = "/"
219
- else
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 ["&#{name}", body, tail, ""].join("\n")
223
+ return ["&#{group}", body, tail, ""].join("\n")
223
224
  end
224
225
 
225
226
  def self.dump (root, **format_options)
226
- return root.map { |name, hash| generate(hash, name: name, **format_options) }.join
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, name: nil)
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
- if name
240
- return FortIO::Namelist::Reader.new(text).read(name)
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
- return FortIO::Namelist::Reader.new(text).read_all()
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.4.16
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
- :STRING,
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
- :STRING,
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', 115)
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
- 19, 20, 30, 49, 54, 40, 31, 50, 27, 38,
227
- 48, 33, 40, 34, 35, 36, 45, 44, 53, 4,
228
- 5, 24, 23, 46, 38, 45, 33, 25, 34, 35,
229
- 36, 59, 46, 38, 60, 33, 61, 34, 35, 36,
230
- 45, 44, 49, 4, 5, 40, 50, 46, 38, 17,
231
- 33, 16, 34, 35, 36, 45, 44, 65, 66, 7,
232
- 52, nil, 46, 38, nil, 33, 30, 34, 35, 36,
233
- 31, nil, 42, 38, nil, 33, 30, 34, 35, 36,
234
- 31, nil, 42, 38, nil, 33, 30, 34, 35, 36,
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
- 24, 24, 24, 38, 40, 65, 24, 38, 24, 24,
244
- 33, 24, 25, 24, 24, 24, 64, 64, 40, 0,
245
- 0, 15, 13, 64, 64, 47, 64, 15, 64, 64,
246
- 64, 51, 47, 47, 52, 47, 53, 47, 47, 47,
247
- 28, 28, 59, 2, 2, 54, 59, 28, 28, 7,
248
- 28, 6, 28, 28, 28, 41, 41, 61, 63, 1,
249
- 39, nil, 41, 41, nil, 41, 27, 41, 41, 41,
250
- 27, nil, 27, 27, nil, 27, 30, 27, 27, 27,
251
- 30, nil, 30, 30, nil, 30, 42, 30, 30, 30,
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
- 13, 59, 37, 136, nil, nil, 43, 49, nil, nil,
261
- 108, nil, nil, 14, nil, 16, nil, nil, nil, nil,
262
- nil, nil, nil, nil, -2, -1, nil, 62, 37, nil,
263
- 72, nil, nil, -4, nil, nil, nil, nil, -10, 48,
264
- 0, 52, 82, nil, 107, 121, nil, 22, 114, nil,
265
- nil, 27, 29, 23, 32, nil, nil, nil, nil, 29,
266
- 92, 53, nil, 46, 13, -8, nil, nil ]
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
- -1, -44, -1, -44, -6, -7, -44, -44, -3, -4,
270
- -44, -9, -10, -44, -14, -44, -8, 68, -5, -12,
271
- -13, -15, -16, -11, -44, -44, -17, -18, -19, -21,
272
- -44, -29, -30, -34, -32, -33, -35, -36, -44, -44,
273
- -40, -26, -44, -22, -44, -28, -25, -27, -44, -37,
274
- -38, -44, -44, -44, -44, -23, -24, -31, -34, -44,
275
- -44, -41, -42, -44, -20, -44, -39, -43 ]
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
- 39, 43, 28, 51, 14, 22, 9, 57, 47, 13,
279
- 1, 21, 8, 18, 43, 10, 13, 55, 56, 26,
280
- 43, nil, nil, nil, 63, nil, nil, nil, nil, 62,
281
- nil, nil, nil, nil, nil, nil, nil, 43, 64, nil,
282
- 67 ]
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
- 10, 11, 9, 14, 8, 7, 4, 12, 9, 6,
286
- 1, 8, 1, 4, 11, 5, 6, 11, 11, 7,
287
- 11, nil, nil, nil, 14, nil, nil, nil, nil, 10,
288
- nil, nil, nil, nil, nil, nil, nil, 11, 9, nil,
289
- 10 ]
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, nil, nil, 3, 12, 6, -5, 1, -22,
293
- -25, -27, -41, nil, -35 ]
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, 2, 3, nil, nil, 6, nil, nil, 41,
297
- nil, 29, 32, 37, 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
- 0, 20, :_reduce_none,
302
- 1, 20, :_reduce_none,
303
- 2, 20, :_reduce_none,
304
- 2, 21, :_reduce_4,
305
- 3, 21, :_reduce_5,
306
- 1, 25, :_reduce_none,
307
- 1, 25, :_reduce_none,
308
- 2, 22, :_reduce_8,
309
- 2, 22, :_reduce_none,
310
- 1, 23, :_reduce_none,
311
- 2, 23, :_reduce_11,
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
- 1, 26, :_reduce_none,
314
- 1, 24, :_reduce_14,
315
- 2, 24, :_reduce_15,
316
- 2, 24, :_reduce_16,
317
- 3, 27, :_reduce_17,
318
- 3, 27, :_reduce_18,
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,
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
- 5, 32, :_reduce_39,
340
- 1, 29, :_reduce_40,
341
- 3, 29, :_reduce_41,
342
- 3, 29, :_reduce_42,
343
- 5, 29, :_reduce_43 ]
344
-
345
- racc_reduce_n = 44
346
-
347
- racc_shift_n = 68
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
- :COMMA => 2,
353
- :NL => 3,
354
- "," => 4,
355
- "=" => 5,
356
- "&" => 6,
357
- "$" => 7,
358
- :IDENT => 8,
359
- "/" => 9,
360
- :NIL => 10,
361
- "(" => 11,
362
- ")" => 12,
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
- ":" => 18 }
380
+ :STRINGLIKE => 18,
381
+ ":" => 19 }
369
382
 
370
- racc_nt_base = 19
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
- "NIL",
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
- "header",
414
- "tailer",
415
- "paramlist",
416
- "prefix",
426
+ "group",
427
+ "group_header",
417
428
  "separator",
418
- "paramdef",
429
+ "varlist",
430
+ "group_end",
431
+ "group_prefix",
432
+ "nls",
433
+ "blank",
434
+ "vardef",
419
435
  "rvalues",
420
436
  "array_spec",
421
- "abbreb",
437
+ "rlist",
438
+ "ident_list",
439
+ "element",
422
440
  "constant",
423
- "complex",
424
- "real" ]
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
- # reduce 3 omitted
437
-
438
- module_eval(<<'.,.,', 'fortran_namelist.y', 31)
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', 33)
446
- def _reduce_5(val, _values, result)
447
- @root[val[0]] = val[1]; @scan.in_namelist = nil
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 6 omitted
468
+ # reduce 5 omitted
453
469
 
454
- # reduce 7 omitted
470
+ # reduce 6 omitted
455
471
 
456
- module_eval(<<'.,.,', 'fortran_namelist.y', 39)
457
- def _reduce_8(val, _values, result)
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
- module_eval(<<'.,.,', 'fortran_namelist.y', 44)
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
- module_eval(<<'.,.,', 'fortran_namelist.y', 50)
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', 52)
493
+ module_eval(<<'.,.,', 'fortran_namelist.y', 50)
486
494
  def _reduce_15(val, _values, result)
487
- result = val[0] + [val[1]]
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', 54)
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', 58)
507
+ module_eval(<<'.,.,', 'fortran_namelist.y', 55)
500
508
  def _reduce_17(val, _values, result)
501
- result = ParamDef.new(val[0].downcase, nil, "")
509
+ result = val[0] + [val[2]]
502
510
  result
503
511
  end
504
512
  .,.,
505
513
 
506
- module_eval(<<'.,.,', 'fortran_namelist.y', 60)
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', 62)
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', 64)
528
+ module_eval(<<'.,.,', 'fortran_namelist.y', 63)
521
529
  def _reduce_20(val, _values, result)
522
- result = ParamDef.new(val[0].downcase, val[2], val[5])
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', 67)
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
- module_eval(<<'.,.,', 'fortran_namelist.y', 69)
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
- module_eval(<<'.,.,', 'fortran_namelist.y', 71)
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
- module_eval(<<'.,.,', 'fortran_namelist.y', 73)
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', 75)
548
+ module_eval(<<'.,.,', 'fortran_namelist.y', 73)
556
549
  def _reduce_25(val, _values, result)
557
- result = val[0] + [nil]
550
+ result = [nil, nil]
558
551
  result
559
552
  end
560
553
  .,.,
561
554
 
562
- module_eval(<<'.,.,', 'fortran_namelist.y', 77)
555
+ module_eval(<<'.,.,', 'fortran_namelist.y', 75)
563
556
  def _reduce_26(val, _values, result)
564
- result = [nil] + val[1]
557
+ result = val[0] + val[1]
565
558
  result
566
559
  end
567
560
  .,.,
568
561
 
569
- module_eval(<<'.,.,', 'fortran_namelist.y', 79)
562
+ module_eval(<<'.,.,', 'fortran_namelist.y', 77)
570
563
  def _reduce_27(val, _values, result)
571
- result = [nil] + val[1]
564
+ result = val[0] + val[2]
572
565
  result
573
566
  end
574
567
  .,.,
575
568
 
576
- module_eval(<<'.,.,', 'fortran_namelist.y', 81)
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', 83)
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', 88)
598
- def _reduce_31(val, _values, result)
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
- # reduce 37 omitted
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
- # reduce 38 omitted
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', 100)
616
+ module_eval(<<'.,.,', 'fortran_namelist.y', 103)
619
617
  def _reduce_39(val, _values, result)
620
- result = Complex(val[1],val[3])
618
+ result = [val[0]]
621
619
  result
622
620
  end
623
621
  .,.,
624
622
 
625
- module_eval(<<'.,.,', 'fortran_namelist.y', 103)
623
+ module_eval(<<'.,.,', 'fortran_namelist.y', 105)
626
624
  def _reduce_40(val, _values, result)
627
- result = [val[0]-1]
625
+ result = val[0] + [val[2]]
628
626
  result
629
627
  end
630
628
  .,.,
631
629
 
632
- module_eval(<<'.,.,', 'fortran_namelist.y', 105)
630
+ module_eval(<<'.,.,', 'fortran_namelist.y', 107)
633
631
  def _reduce_41(val, _values, result)
634
- result = [(val[0]-1)..(val[2]-1)]
632
+ result = val[0] + [val[2]]
635
633
  result
636
634
  end
637
635
  .,.,
638
636
 
639
- module_eval(<<'.,.,', 'fortran_namelist.y', 107)
637
+ module_eval(<<'.,.,', 'fortran_namelist.y', 110)
640
638
  def _reduce_42(val, _values, result)
641
- result = [val[0]-1] + val[2]
639
+ result = [val[0]-1]
642
640
  result
643
641
  end
644
642
  .,.,
645
643
 
646
- module_eval(<<'.,.,', 'fortran_namelist.y', 109)
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