tla2dot 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +125 -0
- data/bin/tla2dot.rb +5 -0
- data/lib/cli/cli.rb +114 -0
- data/lib/tla2dot/parser.tab.rb +712 -0
- data/lib/tla2dot/parser.y +415 -0
- data/lib/tla2dot/template.rb +184 -0
- data/lib/tla2dot.rb +10 -0
- data/lib/utils/logger.rb +70 -0
- data/mustache/defaults.mustache +19 -0
- data/mustache/root.mustache +20 -0
- data/mustache/stateOutput.mustache +1 -0
- metadata +135 -0
@@ -0,0 +1,712 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.12
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
class Tla2DotParser < Racc::Parser
|
9
|
+
|
10
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 89)
|
11
|
+
|
12
|
+
class Node
|
13
|
+
|
14
|
+
include TLA2DOT::Utils::MyLogger # mix logger
|
15
|
+
|
16
|
+
@@logger = nil; # common logger for all nodes
|
17
|
+
@@options = {}; # common logger for all nodes
|
18
|
+
|
19
|
+
|
20
|
+
# ------------------------------------------------------------------
|
21
|
+
# Attributes
|
22
|
+
|
23
|
+
# instance
|
24
|
+
attr_accessor :name #
|
25
|
+
attr_accessor :variables # hash of name=>
|
26
|
+
attr_accessor :edges # list of nodes reachable
|
27
|
+
|
28
|
+
# ------------------------------------------------------------------
|
29
|
+
# constructore
|
30
|
+
def initialize( name, variables )
|
31
|
+
@name = name
|
32
|
+
@variables = variables
|
33
|
+
@edges = []
|
34
|
+
@filter_render_variables = []
|
35
|
+
end
|
36
|
+
|
37
|
+
def myLogger
|
38
|
+
return @@logger if @@logger
|
39
|
+
@@logger = getLogger( "Node", getOptions )
|
40
|
+
@@logger.info( "#{__method__} created" )
|
41
|
+
@@logger
|
42
|
+
end
|
43
|
+
|
44
|
+
def setOptions( options )
|
45
|
+
@@options = options
|
46
|
+
end
|
47
|
+
|
48
|
+
def getOptions
|
49
|
+
@@options
|
50
|
+
end
|
51
|
+
|
52
|
+
def name
|
53
|
+
@name
|
54
|
+
end
|
55
|
+
|
56
|
+
def variables=( variables )
|
57
|
+
@variables = variables
|
58
|
+
end
|
59
|
+
|
60
|
+
def variables
|
61
|
+
@variables
|
62
|
+
end
|
63
|
+
|
64
|
+
def ==( node )
|
65
|
+
node.respond_to?( :name) && self.name == node.name
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_edge( node )
|
69
|
+
@edges << node unless @edges.include?( node )
|
70
|
+
end
|
71
|
+
|
72
|
+
def successor_cnt
|
73
|
+
@edges.size
|
74
|
+
end
|
75
|
+
|
76
|
+
# array of successors for the node
|
77
|
+
def successors
|
78
|
+
@edges
|
79
|
+
end
|
80
|
+
|
81
|
+
# array tranitions (from_state->to_state) from this node to another
|
82
|
+
def transitions
|
83
|
+
myLogger.debug( "#{__method__} starting" )
|
84
|
+
successors.select{ |n| n.name != name }.map{ |n| { :to_state => n.name, :from_state => self.name } }
|
85
|
+
end
|
86
|
+
|
87
|
+
# array of variable names to render
|
88
|
+
def filter_render_variables
|
89
|
+
myLogger.debug( "#{__method__} filter_render_variables=#{@filter_render_variables} #{@filter_render_variables.class}" )
|
90
|
+
@filter_render_variables
|
91
|
+
end
|
92
|
+
|
93
|
+
# called when added to graph
|
94
|
+
def filter_render_variables=( variables )
|
95
|
+
|
96
|
+
@filter_render_variables = variables
|
97
|
+
end
|
98
|
+
|
99
|
+
# return true is state should show variable
|
100
|
+
def include_variable( variable )
|
101
|
+
|
102
|
+
return filter_render_variables.include?( variable ) if
|
103
|
+
filter_render_variables.kind_of?( Array )
|
104
|
+
|
105
|
+
# assume boolean
|
106
|
+
return filter_render_variables
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# node variable to render as key/state hash (including 'id')
|
112
|
+
def content
|
113
|
+
myLogger.debug( "#{__method__} starting" )
|
114
|
+
vars = variables;
|
115
|
+
vars['ID'] = name
|
116
|
+
vars.select{ |k,v| include_variable( k ) }.
|
117
|
+
map { |k,v|
|
118
|
+
{:key =>k, :val => v, :state => render_value(v) }
|
119
|
+
}
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
# escape for mustache rendering
|
124
|
+
def render_value( v )
|
125
|
+
return v.to_s.
|
126
|
+
gsub( /\{/, "\\{" ).
|
127
|
+
gsub( /\}/, "\\}" ).
|
128
|
+
gsub( /=>/, "=" ).
|
129
|
+
# gsub( /\{/, "" ).
|
130
|
+
# gsub( /\}/, "" ).
|
131
|
+
# gsub( /\[/, "" ).
|
132
|
+
# gsub( /\]/, "" ).
|
133
|
+
# gsub( /\[/, "\\[" ).
|
134
|
+
# gsub( /\]/, "\\]" ).
|
135
|
+
gsub( /"/, '\\"' )
|
136
|
+
# case
|
137
|
+
# when v.kind_of?( Hash )
|
138
|
+
# return v.to_s.gsub( /\{/, "\\{" ).gsub( /\}/, "\\}" )
|
139
|
+
# else
|
140
|
+
# return v
|
141
|
+
# end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
class Graph
|
150
|
+
|
151
|
+
include TLA2DOT::Utils::MyLogger # mix logger
|
152
|
+
|
153
|
+
|
154
|
+
attr_reader :nodes #
|
155
|
+
|
156
|
+
def initialize( filter_render_variables, options )
|
157
|
+
@nodes = {}
|
158
|
+
# filter_render_variables passed to node
|
159
|
+
@filter_render_variables = filter_render_variables
|
160
|
+
setOptions( options )
|
161
|
+
end
|
162
|
+
|
163
|
+
def myLogger
|
164
|
+
return @logger if @logger
|
165
|
+
@logger = getLogger( "Graph", getOptions )
|
166
|
+
@logger.info( "#{__method__} created" )
|
167
|
+
@logger
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
def setOptions( options )
|
172
|
+
@options = options
|
173
|
+
end
|
174
|
+
|
175
|
+
def getOptions
|
176
|
+
@options
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_node(node)
|
180
|
+
node.filter_render_variables=( @filter_render_variables )
|
181
|
+
node.setOptions( getOptions )
|
182
|
+
myLogger.debug( "#{__method__} added node #{node}, @filter_render_variables=#{@filter_render_variables} #{@filter_render_variables.class}" )
|
183
|
+
@nodes[node.name] = node
|
184
|
+
self
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def nodes
|
189
|
+
@nodes
|
190
|
+
end
|
191
|
+
|
192
|
+
def states
|
193
|
+
@nodes.values
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
def node_cnt
|
198
|
+
@nodes.size
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
def add_edge(predecessor_name, successor_name)
|
203
|
+
|
204
|
+
predecessor_node = @nodes[predecessor_name]
|
205
|
+
raise "Unknown precessor node #{predecessor_name}" unless predecessor_node
|
206
|
+
successor_node = @nodes[successor_name]
|
207
|
+
raise "Unknown precessor node #{successor_name}" unless successor_node
|
208
|
+
@nodes[predecessor_name].add_edge(@nodes[successor_name])
|
209
|
+
end
|
210
|
+
|
211
|
+
def [](name)
|
212
|
+
@nodes[name]
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# ------------------------------------------------------------------
|
217
|
+
|
218
|
+
include TLA2DOT::Utils::MyLogger # mix logger
|
219
|
+
PROGNAME = "parser" # progname for logger
|
220
|
+
|
221
|
+
def initialize( options = {} )
|
222
|
+
@logger = getLogger( PROGNAME, options )
|
223
|
+
@logger.debug( "#{__method__} initialized" )
|
224
|
+
setOptions( options )
|
225
|
+
end
|
226
|
+
|
227
|
+
def setOptions( options )
|
228
|
+
@options = options
|
229
|
+
end
|
230
|
+
|
231
|
+
def getOptions
|
232
|
+
@options
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
# entry point
|
238
|
+
def parse(str, filter_render_variables = [] )
|
239
|
+
@logger.info( "#{__method__} parsing started" )
|
240
|
+
@graph = Graph.new( filter_render_variables, getOptions )
|
241
|
+
@line = 0
|
242
|
+
return @graph if str.nil? || str.empty?
|
243
|
+
@str = str.kind_of?( Array ) ? str : [ str ]
|
244
|
+
begin
|
245
|
+
ret = yyparse self, :scan
|
246
|
+
@logger.info( "#{__method__} parsing done" )
|
247
|
+
return ret
|
248
|
+
rescue Exception => e
|
249
|
+
puts "Error on line #{@line} near #{@current}"
|
250
|
+
@logger.error( "#{__method__} error #{e}" )
|
251
|
+
# puts e
|
252
|
+
return nil
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
private
|
257
|
+
|
258
|
+
# return next line for scanner
|
259
|
+
def next_str
|
260
|
+
@current = @str.any? ? @str.shift : nil
|
261
|
+
@line += 1
|
262
|
+
@current
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
# racc token scanner
|
267
|
+
def scan
|
268
|
+
while true
|
269
|
+
str = next_str
|
270
|
+
break if str.nil?
|
271
|
+
until str.empty?
|
272
|
+
case str
|
273
|
+
when /\A\s+/
|
274
|
+
str = $'
|
275
|
+
when /\AState (\d+):/
|
276
|
+
yield [ :STATE, $1 ]
|
277
|
+
str = $'
|
278
|
+
when /\AState (\d+)\/(-?\d+):/
|
279
|
+
# using fingerprint name
|
280
|
+
yield [ :STATE, $2 ]
|
281
|
+
str = $'
|
282
|
+
when /\AState (\d+):/
|
283
|
+
yield [ :STATE, $1 ]
|
284
|
+
str = $'
|
285
|
+
when /\ATransition ([0-9\-\+]+)/
|
286
|
+
yield [ :TRANS, $1 ]
|
287
|
+
str = $'
|
288
|
+
when /\A"([^"]*)"*/
|
289
|
+
yield [ :STRING, $1 ]
|
290
|
+
str = $'
|
291
|
+
when /\A[a-zA-Z]\w*/
|
292
|
+
yield [ :IDENT, $& ]
|
293
|
+
str = $'
|
294
|
+
when /\A-?\d+/
|
295
|
+
yield [ :INTEGER, $& ]
|
296
|
+
str = $'
|
297
|
+
when /\A\/\\/
|
298
|
+
yield [ :AND, $& ]
|
299
|
+
str = $'
|
300
|
+
when /\A\|->/
|
301
|
+
yield [ $&, $& ]
|
302
|
+
str = $'
|
303
|
+
# when /\A\n/
|
304
|
+
# puts "Nl"
|
305
|
+
# yield [ :NL, $& ]
|
306
|
+
# str = $'
|
307
|
+
when /\A\-->/
|
308
|
+
yield [ $&, $& ]
|
309
|
+
str = $'
|
310
|
+
when /\A=/
|
311
|
+
yield [ $&, $& ]
|
312
|
+
str = $'
|
313
|
+
else
|
314
|
+
c = str[0,1]
|
315
|
+
yield [ c, c ]
|
316
|
+
str = str[1..-1]
|
317
|
+
end
|
318
|
+
end # until
|
319
|
+
end # while
|
320
|
+
yield [ false, '$'] # is optional from Racc 1.3.7
|
321
|
+
end
|
322
|
+
|
323
|
+
...end parser.y/module_eval...
|
324
|
+
##### State transition tables begin ###
|
325
|
+
|
326
|
+
racc_action_table = [
|
327
|
+
32, 22, 39, 58, 34, 51, 52, 41, 33, 38,
|
328
|
+
50, 57, 40, 46, 32, 27, 39, 45, 34, 25,
|
329
|
+
26, 6, 33, 38, 9, 32, 40, 39, 6, 34,
|
330
|
+
62, 9, 63, 33, 38, 17, 32, 40, 39, 19,
|
331
|
+
34, 18, 15, 12, 33, 38, 22, 32, 40, 39,
|
332
|
+
53, 34, 28, 61, 22, 33, 38, 10, 32, 40,
|
333
|
+
39, 65, 34, 15, nil, nil, 33, 38, 27, nil,
|
334
|
+
40, 29, 25, 26 ]
|
335
|
+
|
336
|
+
racc_action_check = [
|
337
|
+
40, 38, 40, 47, 40, 42, 44, 38, 40, 40,
|
338
|
+
42, 47, 40, 40, 52, 17, 52, 39, 52, 17,
|
339
|
+
17, 2, 52, 52, 2, 58, 52, 58, 0, 58,
|
340
|
+
54, 0, 54, 58, 58, 8, 63, 58, 63, 12,
|
341
|
+
63, 10, 7, 6, 63, 63, 51, 45, 63, 45,
|
342
|
+
45, 45, 21, 53, 15, 45, 45, 1, 28, 45,
|
343
|
+
28, 62, 28, 13, nil, nil, 28, 28, 23, nil,
|
344
|
+
28, 23, 23, 23 ]
|
345
|
+
|
346
|
+
racc_action_pointer = [
|
347
|
+
26, 57, 19, nil, nil, nil, 40, 32, 29, nil,
|
348
|
+
41, nil, 35, 53, nil, 46, nil, 11, nil, nil,
|
349
|
+
nil, 41, nil, 64, nil, nil, nil, nil, 54, nil,
|
350
|
+
nil, nil, nil, nil, nil, nil, nil, nil, -7, 11,
|
351
|
+
-4, nil, -4, nil, -9, 43, nil, -6, nil, nil,
|
352
|
+
nil, 38, 10, 46, 23, nil, nil, nil, 21, nil,
|
353
|
+
nil, nil, 54, 32, nil, nil, nil ]
|
354
|
+
|
355
|
+
racc_action_default = [
|
356
|
+
-43, -43, -1, -2, -4, -5, -43, -8, -9, -11,
|
357
|
+
-43, -3, -43, -7, -18, -43, -10, -43, 67, -6,
|
358
|
+
-19, -43, -21, -43, -13, -15, -16, -17, -43, -12,
|
359
|
+
-14, -20, -22, -23, -24, -25, -26, -27, -43, -43,
|
360
|
+
-43, -28, -43, -30, -43, -43, -38, -43, -40, -42,
|
361
|
+
-29, -43, -43, -43, -43, -35, -37, -39, -43, -31,
|
362
|
+
-32, -33, -43, -43, -41, -34, -36 ]
|
363
|
+
|
364
|
+
racc_goto_table = [
|
365
|
+
31, 55, 48, 43, 24, 14, 3, 21, 11, 23,
|
366
|
+
30, 20, 16, 42, 13, 54, 59, 56, 2, 66,
|
367
|
+
64, 47, 1, nil, 60, nil, nil, nil, nil, nil,
|
368
|
+
nil, nil, nil, nil, nil, 56 ]
|
369
|
+
|
370
|
+
racc_goto_check = [
|
371
|
+
14, 21, 23, 19, 11, 12, 3, 13, 3, 10,
|
372
|
+
11, 12, 9, 18, 7, 20, 19, 14, 2, 21,
|
373
|
+
23, 22, 1, nil, 14, nil, nil, nil, nil, nil,
|
374
|
+
nil, nil, nil, nil, nil, 14 ]
|
375
|
+
|
376
|
+
racc_goto_pointer = [
|
377
|
+
nil, 22, 18, 6, nil, nil, nil, 7, nil, 4,
|
378
|
+
-8, -13, -2, -8, -28, nil, nil, nil, -25, -35,
|
379
|
+
-30, -44, -19, -38 ]
|
380
|
+
|
381
|
+
racc_goto_default = [
|
382
|
+
nil, nil, nil, nil, 4, 5, 7, nil, 8, nil,
|
383
|
+
nil, nil, nil, 44, 49, 35, 36, 37, nil, nil,
|
384
|
+
nil, nil, nil, nil ]
|
385
|
+
|
386
|
+
racc_reduce_table = [
|
387
|
+
0, 0, :racc_error,
|
388
|
+
1, 19, :_reduce_1,
|
389
|
+
1, 20, :_reduce_none,
|
390
|
+
2, 20, :_reduce_none,
|
391
|
+
1, 21, :_reduce_4,
|
392
|
+
1, 21, :_reduce_none,
|
393
|
+
3, 23, :_reduce_6,
|
394
|
+
2, 22, :_reduce_7,
|
395
|
+
1, 22, :_reduce_none,
|
396
|
+
1, 24, :_reduce_none,
|
397
|
+
2, 24, :_reduce_none,
|
398
|
+
1, 26, :_reduce_11,
|
399
|
+
3, 27, :_reduce_none,
|
400
|
+
1, 28, :_reduce_none,
|
401
|
+
2, 28, :_reduce_none,
|
402
|
+
1, 29, :_reduce_none,
|
403
|
+
1, 29, :_reduce_none,
|
404
|
+
1, 29, :_reduce_none,
|
405
|
+
1, 25, :_reduce_none,
|
406
|
+
2, 25, :_reduce_19,
|
407
|
+
4, 30, :_reduce_20,
|
408
|
+
1, 31, :_reduce_none,
|
409
|
+
1, 32, :_reduce_22,
|
410
|
+
1, 32, :_reduce_none,
|
411
|
+
1, 32, :_reduce_none,
|
412
|
+
1, 32, :_reduce_none,
|
413
|
+
1, 32, :_reduce_none,
|
414
|
+
1, 32, :_reduce_none,
|
415
|
+
2, 33, :_reduce_28,
|
416
|
+
3, 33, :_reduce_29,
|
417
|
+
1, 36, :_reduce_30,
|
418
|
+
3, 36, :_reduce_31,
|
419
|
+
3, 37, :_reduce_32,
|
420
|
+
4, 35, :_reduce_33,
|
421
|
+
5, 35, :_reduce_34,
|
422
|
+
1, 38, :_reduce_none,
|
423
|
+
3, 38, :_reduce_36,
|
424
|
+
1, 39, :_reduce_37,
|
425
|
+
2, 34, :_reduce_38,
|
426
|
+
3, 34, :_reduce_39,
|
427
|
+
1, 40, :_reduce_none,
|
428
|
+
3, 40, :_reduce_41,
|
429
|
+
1, 41, :_reduce_42 ]
|
430
|
+
|
431
|
+
racc_reduce_n = 43
|
432
|
+
|
433
|
+
racc_shift_n = 67
|
434
|
+
|
435
|
+
racc_token_table = {
|
436
|
+
false => 0,
|
437
|
+
:error => 1,
|
438
|
+
:TRANS => 2,
|
439
|
+
"-->" => 3,
|
440
|
+
:INTEGER => 4,
|
441
|
+
:STATE => 5,
|
442
|
+
"<" => 6,
|
443
|
+
">" => 7,
|
444
|
+
:IDENT => 8,
|
445
|
+
"," => 9,
|
446
|
+
:AND => 10,
|
447
|
+
"=" => 11,
|
448
|
+
:STRING => 12,
|
449
|
+
"[" => 13,
|
450
|
+
"]" => 14,
|
451
|
+
"|->" => 15,
|
452
|
+
"{" => 16,
|
453
|
+
"}" => 17 }
|
454
|
+
|
455
|
+
racc_nt_base = 18
|
456
|
+
|
457
|
+
racc_use_result_var = false
|
458
|
+
|
459
|
+
Racc_arg = [
|
460
|
+
racc_action_table,
|
461
|
+
racc_action_check,
|
462
|
+
racc_action_default,
|
463
|
+
racc_action_pointer,
|
464
|
+
racc_goto_table,
|
465
|
+
racc_goto_check,
|
466
|
+
racc_goto_default,
|
467
|
+
racc_goto_pointer,
|
468
|
+
racc_nt_base,
|
469
|
+
racc_reduce_table,
|
470
|
+
racc_token_table,
|
471
|
+
racc_shift_n,
|
472
|
+
racc_reduce_n,
|
473
|
+
racc_use_result_var ]
|
474
|
+
|
475
|
+
Racc_token_to_s_table = [
|
476
|
+
"$end",
|
477
|
+
"error",
|
478
|
+
"TRANS",
|
479
|
+
"\"-->\"",
|
480
|
+
"INTEGER",
|
481
|
+
"STATE",
|
482
|
+
"\"<\"",
|
483
|
+
"\">\"",
|
484
|
+
"IDENT",
|
485
|
+
"\",\"",
|
486
|
+
"AND",
|
487
|
+
"\"=\"",
|
488
|
+
"STRING",
|
489
|
+
"\"[\"",
|
490
|
+
"\"]\"",
|
491
|
+
"\"|->\"",
|
492
|
+
"\"{\"",
|
493
|
+
"\"}\"",
|
494
|
+
"$start",
|
495
|
+
"target",
|
496
|
+
"entries",
|
497
|
+
"entry",
|
498
|
+
"state",
|
499
|
+
"trans",
|
500
|
+
"state_def",
|
501
|
+
"variables",
|
502
|
+
"state_id",
|
503
|
+
"actiondef",
|
504
|
+
"actionspecs",
|
505
|
+
"actionspec",
|
506
|
+
"variable",
|
507
|
+
"name",
|
508
|
+
"value",
|
509
|
+
"record",
|
510
|
+
"set",
|
511
|
+
"seq",
|
512
|
+
"rlist",
|
513
|
+
"ritem",
|
514
|
+
"seqlist",
|
515
|
+
"seqitem",
|
516
|
+
"slist",
|
517
|
+
"sitem" ]
|
518
|
+
|
519
|
+
Racc_debug_parser = false
|
520
|
+
|
521
|
+
##### State transition tables end #####
|
522
|
+
|
523
|
+
# reduce 0 omitted
|
524
|
+
|
525
|
+
module_eval(<<'.,.,', 'parser.y', 12)
|
526
|
+
def _reduce_1(val, _values)
|
527
|
+
@graph
|
528
|
+
end
|
529
|
+
.,.,
|
530
|
+
|
531
|
+
# reduce 2 omitted
|
532
|
+
|
533
|
+
# reduce 3 omitted
|
534
|
+
|
535
|
+
module_eval(<<'.,.,', 'parser.y', 17)
|
536
|
+
def _reduce_4(val, _values)
|
537
|
+
@graph.add_node( val[0] )
|
538
|
+
end
|
539
|
+
.,.,
|
540
|
+
|
541
|
+
# reduce 5 omitted
|
542
|
+
|
543
|
+
module_eval(<<'.,.,', 'parser.y', 21)
|
544
|
+
def _reduce_6(val, _values)
|
545
|
+
@graph.add_edge( val[0], val[2] )
|
546
|
+
end
|
547
|
+
.,.,
|
548
|
+
|
549
|
+
module_eval(<<'.,.,', 'parser.y', 27)
|
550
|
+
def _reduce_7(val, _values)
|
551
|
+
val[0].variables=val[1]; val[0]
|
552
|
+
end
|
553
|
+
.,.,
|
554
|
+
|
555
|
+
# reduce 8 omitted
|
556
|
+
|
557
|
+
# reduce 9 omitted
|
558
|
+
|
559
|
+
# reduce 10 omitted
|
560
|
+
|
561
|
+
module_eval(<<'.,.,', 'parser.y', 33)
|
562
|
+
def _reduce_11(val, _values)
|
563
|
+
Node.new( val[0], {} )
|
564
|
+
end
|
565
|
+
.,.,
|
566
|
+
|
567
|
+
# reduce 12 omitted
|
568
|
+
|
569
|
+
# reduce 13 omitted
|
570
|
+
|
571
|
+
# reduce 14 omitted
|
572
|
+
|
573
|
+
# reduce 15 omitted
|
574
|
+
|
575
|
+
# reduce 16 omitted
|
576
|
+
|
577
|
+
# reduce 17 omitted
|
578
|
+
|
579
|
+
# reduce 18 omitted
|
580
|
+
|
581
|
+
module_eval(<<'.,.,', 'parser.y', 46)
|
582
|
+
def _reduce_19(val, _values)
|
583
|
+
k=val[1].keys.first; val[0][k] = val[1][k]; val[0]
|
584
|
+
end
|
585
|
+
.,.,
|
586
|
+
|
587
|
+
module_eval(<<'.,.,', 'parser.y', 48)
|
588
|
+
def _reduce_20(val, _values)
|
589
|
+
{ val[1] => val[3] }
|
590
|
+
end
|
591
|
+
.,.,
|
592
|
+
|
593
|
+
# reduce 21 omitted
|
594
|
+
|
595
|
+
module_eval(<<'.,.,', 'parser.y', 52)
|
596
|
+
def _reduce_22(val, _values)
|
597
|
+
val[0].to_i
|
598
|
+
end
|
599
|
+
.,.,
|
600
|
+
|
601
|
+
# reduce 23 omitted
|
602
|
+
|
603
|
+
# reduce 24 omitted
|
604
|
+
|
605
|
+
# reduce 25 omitted
|
606
|
+
|
607
|
+
# reduce 26 omitted
|
608
|
+
|
609
|
+
# reduce 27 omitted
|
610
|
+
|
611
|
+
module_eval(<<'.,.,', 'parser.y', 59)
|
612
|
+
def _reduce_28(val, _values)
|
613
|
+
{}
|
614
|
+
end
|
615
|
+
.,.,
|
616
|
+
|
617
|
+
module_eval(<<'.,.,', 'parser.y', 60)
|
618
|
+
def _reduce_29(val, _values)
|
619
|
+
val[1]
|
620
|
+
end
|
621
|
+
.,.,
|
622
|
+
|
623
|
+
module_eval(<<'.,.,', 'parser.y', 62)
|
624
|
+
def _reduce_30(val, _values)
|
625
|
+
val[0]
|
626
|
+
end
|
627
|
+
.,.,
|
628
|
+
|
629
|
+
module_eval(<<'.,.,', 'parser.y', 63)
|
630
|
+
def _reduce_31(val, _values)
|
631
|
+
k=val[2].keys.first; val[0][k] = val[2][k]; val[0]
|
632
|
+
end
|
633
|
+
.,.,
|
634
|
+
|
635
|
+
module_eval(<<'.,.,', 'parser.y', 65)
|
636
|
+
def _reduce_32(val, _values)
|
637
|
+
{ val[0] => val[2] }
|
638
|
+
end
|
639
|
+
.,.,
|
640
|
+
|
641
|
+
module_eval(<<'.,.,', 'parser.y', 68)
|
642
|
+
def _reduce_33(val, _values)
|
643
|
+
[]
|
644
|
+
end
|
645
|
+
.,.,
|
646
|
+
|
647
|
+
module_eval(<<'.,.,', 'parser.y', 69)
|
648
|
+
def _reduce_34(val, _values)
|
649
|
+
val[2]
|
650
|
+
end
|
651
|
+
.,.,
|
652
|
+
|
653
|
+
# reduce 35 omitted
|
654
|
+
|
655
|
+
module_eval(<<'.,.,', 'parser.y', 72)
|
656
|
+
def _reduce_36(val, _values)
|
657
|
+
val[0].push( val[2][0] ); val[0]
|
658
|
+
end
|
659
|
+
.,.,
|
660
|
+
|
661
|
+
module_eval(<<'.,.,', 'parser.y', 74)
|
662
|
+
def _reduce_37(val, _values)
|
663
|
+
[ val[0] ]
|
664
|
+
end
|
665
|
+
.,.,
|
666
|
+
|
667
|
+
module_eval(<<'.,.,', 'parser.y', 77)
|
668
|
+
def _reduce_38(val, _values)
|
669
|
+
[]
|
670
|
+
end
|
671
|
+
.,.,
|
672
|
+
|
673
|
+
module_eval(<<'.,.,', 'parser.y', 78)
|
674
|
+
def _reduce_39(val, _values)
|
675
|
+
val[1]
|
676
|
+
end
|
677
|
+
.,.,
|
678
|
+
|
679
|
+
# reduce 40 omitted
|
680
|
+
|
681
|
+
module_eval(<<'.,.,', 'parser.y', 81)
|
682
|
+
def _reduce_41(val, _values)
|
683
|
+
val[0].push( val[2][0] ); val[0]
|
684
|
+
end
|
685
|
+
.,.,
|
686
|
+
|
687
|
+
module_eval(<<'.,.,', 'parser.y', 83)
|
688
|
+
def _reduce_42(val, _values)
|
689
|
+
[ val[0] ]
|
690
|
+
end
|
691
|
+
.,.,
|
692
|
+
|
693
|
+
def _reduce_none(val, _values)
|
694
|
+
val[0]
|
695
|
+
end
|
696
|
+
|
697
|
+
end # class Tla2DotParser
|
698
|
+
|
699
|
+
|
700
|
+
if $0 == __FILE__
|
701
|
+
src = <<EOS
|
702
|
+
{
|
703
|
+
name => MyName,
|
704
|
+
id => MyIdent
|
705
|
+
}
|
706
|
+
EOS
|
707
|
+
puts 'Parsing (String):'
|
708
|
+
print src
|
709
|
+
puts
|
710
|
+
puts 'Result (Ruby Object):'
|
711
|
+
p HashParser.new.parse(src)
|
712
|
+
end
|