puffy 0.3.1 → 1.1.0.pre.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,671 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.7.3
4
+ # This file is automatically generated by Racc 1.8.1
4
5
  # from Racc grammar file "parser.y".
5
6
  #
6
7
 
7
- require 'racc/parser.rb'
8
+ ###### racc/parser.rb begin
9
+ unless $".find {|p| p.end_with?('/racc/parser.rb')}
10
+ $".push "#{__dir__}/racc/parser.rb"
11
+ self.class.module_eval(<<'...end racc/parser.rb/module_eval...', 'racc/parser.rb', 1)
12
+ #--
13
+ # Copyright (c) 1999-2006 Minero Aoki
14
+ #
15
+ # This program is free software.
16
+ # You can distribute/modify this program under the same terms of ruby.
17
+ #
18
+ # As a special exception, when this code is copied by Racc
19
+ # into a Racc output file, you may use that output file
20
+ # without restriction.
21
+ #++
22
+
23
+ unless $".find {|p| p.end_with?('/racc/info.rb')}
24
+ $".push "#{__dir__}/racc/info.rb"
25
+
26
+ module Racc
27
+ VERSION = '1.8.1'
28
+ Version = VERSION
29
+ Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
30
+ end
31
+
32
+ end
33
+
34
+
35
+ module Racc
36
+ class ParseError < StandardError; end
37
+ end
38
+ unless defined?(::ParseError)
39
+ ParseError = Racc::ParseError # :nodoc:
40
+ end
41
+
42
+ # Racc is an LALR(1) parser generator.
43
+ # It is written in Ruby itself, and generates Ruby programs.
44
+ #
45
+ # == Command-line Reference
46
+ #
47
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
48
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
49
+ # [-v] [--verbose]
50
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
51
+ # [-g] [--debug]
52
+ # [-E] [--embedded]
53
+ # [-l] [--no-line-convert]
54
+ # [-c] [--line-convert-all]
55
+ # [-a] [--no-omit-actions]
56
+ # [-C] [--check-only]
57
+ # [-S] [--output-status]
58
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
59
+ #
60
+ # [+grammarfile+]
61
+ # Racc grammar file. Any extension is permitted.
62
+ # [-o+outfile+, --output-file=+outfile+]
63
+ # A filename for output. default is <+filename+>.tab.rb
64
+ # [-O+filename+, --log-file=+filename+]
65
+ # Place logging output in file +filename+.
66
+ # Default log file name is <+filename+>.output.
67
+ # [-e+rubypath+, --executable=+rubypath+]
68
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
69
+ # [-v, --verbose]
70
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
71
+ # [-g, --debug]
72
+ # add debug code to parser class. To display debugging information,
73
+ # use this '-g' option and set @yydebug true in parser class.
74
+ # [-E, --embedded]
75
+ # Output parser which doesn't need runtime files (racc/parser.rb).
76
+ # [-F, --frozen]
77
+ # Output parser which declares frozen_string_literals: true
78
+ # [-C, --check-only]
79
+ # Check syntax of racc grammar file and quit.
80
+ # [-S, --output-status]
81
+ # Print messages time to time while compiling.
82
+ # [-l, --no-line-convert]
83
+ # turns off line number converting.
84
+ # [-c, --line-convert-all]
85
+ # Convert line number of actions, inner, header and footer.
86
+ # [-a, --no-omit-actions]
87
+ # Call all actions, even if an action is empty.
88
+ # [--version]
89
+ # print Racc version and quit.
90
+ # [--copyright]
91
+ # Print copyright and quit.
92
+ # [--help]
93
+ # Print usage and quit.
94
+ #
95
+ # == Generating Parser Using Racc
96
+ #
97
+ # To compile Racc grammar file, simply type:
98
+ #
99
+ # $ racc parse.y
100
+ #
101
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
102
+ #
103
+ # == Writing A Racc Grammar File
104
+ #
105
+ # If you want your own parser, you have to write a grammar file.
106
+ # A grammar file contains the name of your parser class, grammar for the parser,
107
+ # user code, and anything else.
108
+ # When writing a grammar file, yacc's knowledge is helpful.
109
+ # If you have not used yacc before, Racc is not too difficult.
110
+ #
111
+ # Here's an example Racc grammar file.
112
+ #
113
+ # class Calcparser
114
+ # rule
115
+ # target: exp { print val[0] }
116
+ #
117
+ # exp: exp '+' exp
118
+ # | exp '*' exp
119
+ # | '(' exp ')'
120
+ # | NUMBER
121
+ # end
122
+ #
123
+ # Racc grammar files resemble yacc files.
124
+ # But (of course), this is Ruby code.
125
+ # yacc's $$ is the 'result', $0, $1... is
126
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
127
+ #
128
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
129
+ # more information on grammar files.
130
+ #
131
+ # == Parser
132
+ #
133
+ # Then you must prepare the parse entry method. There are two types of
134
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
135
+ #
136
+ # Racc::Parser#do_parse is simple.
137
+ #
138
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
139
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
140
+ # EOF is [false, false].
141
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
142
+ # If you want to change this, see the grammar reference.
143
+ #
144
+ # Racc::Parser#yyparse is little complicated, but useful.
145
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
146
+ #
147
+ # For example, <code>yyparse(obj, :scan)</code> causes
148
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
149
+ #
150
+ # == Debugging
151
+ #
152
+ # When debugging, "-v" or/and the "-g" option is helpful.
153
+ #
154
+ # "-v" creates verbose log file (.output).
155
+ # "-g" creates a "Verbose Parser".
156
+ # Verbose Parser prints the internal status when parsing.
157
+ # But it's _not_ automatic.
158
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
159
+ # -g option only creates the verbose parser.
160
+ #
161
+ # === Racc reported syntax error.
162
+ #
163
+ # Isn't there too many "end"?
164
+ # grammar of racc file is changed in v0.10.
165
+ #
166
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
167
+ #
168
+ # === Racc reported "XXXX conflicts".
169
+ #
170
+ # Try "racc -v xxxx.y".
171
+ # It causes producing racc's internal log file, xxxx.output.
172
+ #
173
+ # === Generated parsers does not work correctly
174
+ #
175
+ # Try "racc -g xxxx.y".
176
+ # This command let racc generate "debugging parser".
177
+ # Then set @yydebug=true in your parser.
178
+ # It produces a working log of your parser.
179
+ #
180
+ # == Re-distributing Racc runtime
181
+ #
182
+ # A parser, which is created by Racc, requires the Racc runtime module;
183
+ # racc/parser.rb.
184
+ #
185
+ # Ruby 1.8.x comes with Racc runtime module,
186
+ # you need NOT distribute Racc runtime files.
187
+ #
188
+ # If you want to include the Racc runtime module with your parser.
189
+ # This can be done by using '-E' option:
190
+ #
191
+ # $ racc -E -omyparser.rb myparser.y
192
+ #
193
+ # This command creates myparser.rb which `includes' Racc runtime.
194
+ # Only you must do is to distribute your parser file (myparser.rb).
195
+ #
196
+ # Note: parser.rb is ruby license, but your parser is not.
197
+ # Your own parser is completely yours.
198
+ module Racc
199
+
200
+ unless defined?(Racc_No_Extensions)
201
+ Racc_No_Extensions = false # :nodoc:
202
+ end
203
+
204
+ class Parser
205
+
206
+ Racc_Runtime_Version = ::Racc::VERSION
207
+ Racc_Runtime_Core_Version_R = ::Racc::VERSION
208
+
209
+ begin
210
+ if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
211
+ require 'jruby'
212
+ require 'racc/cparse-jruby.jar'
213
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
214
+ else
215
+ require 'racc/cparse'
216
+ end
217
+
218
+ unless new.respond_to?(:_racc_do_parse_c, true)
219
+ raise LoadError, 'old cparse.so'
220
+ end
221
+ if Racc_No_Extensions
222
+ raise LoadError, 'selecting ruby version of racc runtime core'
223
+ end
224
+
225
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
226
+ Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
227
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
228
+ Racc_Runtime_Type = 'c' # :nodoc:
229
+ rescue LoadError
230
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
231
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
232
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
233
+ Racc_Runtime_Type = 'ruby'
234
+ end
235
+
236
+ def Parser.racc_runtime_type # :nodoc:
237
+ Racc_Runtime_Type
238
+ end
239
+
240
+ def _racc_setup
241
+ @yydebug = false unless self.class::Racc_debug_parser
242
+ @yydebug = false unless defined?(@yydebug)
243
+ if @yydebug
244
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
245
+ @racc_debug_out ||= $stderr
246
+ end
247
+ arg = self.class::Racc_arg
248
+ arg[13] = true if arg.size < 14
249
+ arg
250
+ end
251
+
252
+ def _racc_init_sysvars
253
+ @racc_state = [0]
254
+ @racc_tstack = []
255
+ @racc_vstack = []
256
+
257
+ @racc_t = nil
258
+ @racc_val = nil
259
+
260
+ @racc_read_next = true
261
+
262
+ @racc_user_yyerror = false
263
+ @racc_error_status = 0
264
+ end
265
+
266
+ # The entry point of the parser. This method is used with #next_token.
267
+ # If Racc wants to get token (and its value), calls next_token.
268
+ #
269
+ # Example:
270
+ # def parse
271
+ # @q = [[1,1],
272
+ # [2,2],
273
+ # [3,3],
274
+ # [false, '$']]
275
+ # do_parse
276
+ # end
277
+ #
278
+ # def next_token
279
+ # @q.shift
280
+ # end
281
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
282
+ def do_parse
283
+ #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
284
+ end
285
+ RUBY
286
+
287
+ # The method to fetch next token.
288
+ # If you use #do_parse method, you must implement #next_token.
289
+ #
290
+ # The format of return value is [TOKEN_SYMBOL, VALUE].
291
+ # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
292
+ # for 'IDENT'. ";" (String) for ';'.
293
+ #
294
+ # The final symbol (End of file) must be false.
295
+ def next_token
296
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
297
+ end
298
+
299
+ def _racc_do_parse_rb(arg, in_debug)
300
+ action_table, action_check, action_default, action_pointer,
301
+ _, _, _, _,
302
+ _, _, token_table, * = arg
303
+
304
+ _racc_init_sysvars
305
+ tok = act = i = nil
306
+
307
+ catch(:racc_end_parse) {
308
+ while true
309
+ if i = action_pointer[@racc_state[-1]]
310
+ if @racc_read_next
311
+ if @racc_t != 0 # not EOF
312
+ tok, @racc_val = next_token()
313
+ unless tok # EOF
314
+ @racc_t = 0
315
+ else
316
+ @racc_t = (token_table[tok] or 1) # error token
317
+ end
318
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
319
+ @racc_read_next = false
320
+ end
321
+ end
322
+ i += @racc_t
323
+ unless i >= 0 and
324
+ act = action_table[i] and
325
+ action_check[i] == @racc_state[-1]
326
+ act = action_default[@racc_state[-1]]
327
+ end
328
+ else
329
+ act = action_default[@racc_state[-1]]
330
+ end
331
+ while act = _racc_evalact(act, arg)
332
+ ;
333
+ end
334
+ end
335
+ }
336
+ end
337
+
338
+ # Another entry point for the parser.
339
+ # If you use this method, you must implement RECEIVER#METHOD_ID method.
340
+ #
341
+ # RECEIVER#METHOD_ID is a method to get next token.
342
+ # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
343
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
344
+ def yyparse(recv, mid)
345
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
346
+ end
347
+ RUBY
348
+
349
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
350
+ action_table, action_check, action_default, action_pointer,
351
+ _, _, _, _,
352
+ _, _, token_table, * = arg
353
+
354
+ _racc_init_sysvars
355
+
356
+ catch(:racc_end_parse) {
357
+ until i = action_pointer[@racc_state[-1]]
358
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
359
+ ;
360
+ end
361
+ end
362
+ recv.__send__(mid) do |tok, val|
363
+ unless tok
364
+ @racc_t = 0
365
+ else
366
+ @racc_t = (token_table[tok] or 1) # error token
367
+ end
368
+ @racc_val = val
369
+ @racc_read_next = false
370
+
371
+ i += @racc_t
372
+ unless i >= 0 and
373
+ act = action_table[i] and
374
+ action_check[i] == @racc_state[-1]
375
+ act = action_default[@racc_state[-1]]
376
+ end
377
+ while act = _racc_evalact(act, arg)
378
+ ;
379
+ end
380
+
381
+ while !(i = action_pointer[@racc_state[-1]]) ||
382
+ ! @racc_read_next ||
383
+ @racc_t == 0 # $
384
+ unless i and i += @racc_t and
385
+ i >= 0 and
386
+ act = action_table[i] and
387
+ action_check[i] == @racc_state[-1]
388
+ act = action_default[@racc_state[-1]]
389
+ end
390
+ while act = _racc_evalact(act, arg)
391
+ ;
392
+ end
393
+ end
394
+ end
395
+ }
396
+ end
397
+
398
+ ###
399
+ ### common
400
+ ###
401
+
402
+ def _racc_evalact(act, arg)
403
+ action_table, action_check, _, action_pointer,
404
+ _, _, _, _,
405
+ _, _, _, shift_n,
406
+ reduce_n, * = arg
407
+ nerr = 0 # tmp
408
+
409
+ if act > 0 and act < shift_n
410
+ #
411
+ # shift
412
+ #
413
+ if @racc_error_status > 0
414
+ @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
415
+ end
416
+ @racc_vstack.push @racc_val
417
+ @racc_state.push act
418
+ @racc_read_next = true
419
+ if @yydebug
420
+ @racc_tstack.push @racc_t
421
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
422
+ end
423
+
424
+ elsif act < 0 and act > -reduce_n
425
+ #
426
+ # reduce
427
+ #
428
+ code = catch(:racc_jump) {
429
+ @racc_state.push _racc_do_reduce(arg, act)
430
+ false
431
+ }
432
+ if code
433
+ case code
434
+ when 1 # yyerror
435
+ @racc_user_yyerror = true # user_yyerror
436
+ return -reduce_n
437
+ when 2 # yyaccept
438
+ return shift_n
439
+ else
440
+ raise '[Racc Bug] unknown jump code'
441
+ end
442
+ end
443
+
444
+ elsif act == shift_n
445
+ #
446
+ # accept
447
+ #
448
+ racc_accept if @yydebug
449
+ throw :racc_end_parse, @racc_vstack[0]
450
+
451
+ elsif act == -reduce_n
452
+ #
453
+ # error
454
+ #
455
+ case @racc_error_status
456
+ when 0
457
+ unless arg[21] # user_yyerror
458
+ nerr += 1
459
+ on_error @racc_t, @racc_val, @racc_vstack
460
+ end
461
+ when 3
462
+ if @racc_t == 0 # is $
463
+ # We're at EOF, and another error occurred immediately after
464
+ # attempting auto-recovery
465
+ throw :racc_end_parse, nil
466
+ end
467
+ @racc_read_next = true
468
+ end
469
+ @racc_user_yyerror = false
470
+ @racc_error_status = 3
471
+ while true
472
+ if i = action_pointer[@racc_state[-1]]
473
+ i += 1 # error token
474
+ if i >= 0 and
475
+ (act = action_table[i]) and
476
+ action_check[i] == @racc_state[-1]
477
+ break
478
+ end
479
+ end
480
+ throw :racc_end_parse, nil if @racc_state.size <= 1
481
+ @racc_state.pop
482
+ @racc_vstack.pop
483
+ if @yydebug
484
+ @racc_tstack.pop
485
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
486
+ end
487
+ end
488
+ return act
489
+
490
+ else
491
+ raise "[Racc Bug] unknown action #{act.inspect}"
492
+ end
493
+
494
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
495
+
496
+ nil
497
+ end
498
+
499
+ def _racc_do_reduce(arg, act)
500
+ _, _, _, _,
501
+ goto_table, goto_check, goto_default, goto_pointer,
502
+ nt_base, reduce_table, _, _,
503
+ _, use_result, * = arg
504
+
505
+ state = @racc_state
506
+ vstack = @racc_vstack
507
+ tstack = @racc_tstack
508
+
509
+ i = act * -3
510
+ len = reduce_table[i]
511
+ reduce_to = reduce_table[i+1]
512
+ method_id = reduce_table[i+2]
513
+ void_array = []
514
+
515
+ tmp_t = tstack[-len, len] if @yydebug
516
+ tmp_v = vstack[-len, len]
517
+ tstack[-len, len] = void_array if @yydebug
518
+ vstack[-len, len] = void_array
519
+ state[-len, len] = void_array
520
+
521
+ # tstack must be updated AFTER method call
522
+ if use_result
523
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
524
+ else
525
+ vstack.push __send__(method_id, tmp_v, vstack)
526
+ end
527
+ tstack.push reduce_to
528
+
529
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
530
+
531
+ k1 = reduce_to - nt_base
532
+ if i = goto_pointer[k1]
533
+ i += state[-1]
534
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
535
+ return curstate
536
+ end
537
+ end
538
+ goto_default[k1]
539
+ end
540
+
541
+ # This method is called when a parse error is found.
542
+ #
543
+ # ERROR_TOKEN_ID is an internal ID of token which caused error.
544
+ # You can get string representation of this ID by calling
545
+ # #token_to_str.
546
+ #
547
+ # ERROR_VALUE is a value of error token.
548
+ #
549
+ # value_stack is a stack of symbol values.
550
+ # DO NOT MODIFY this object.
551
+ #
552
+ # This method raises ParseError by default.
553
+ #
554
+ # If this method returns, parsers enter "error recovering mode".
555
+ def on_error(t, val, vstack)
556
+ raise ParseError, sprintf("parse error on value %s (%s)",
557
+ val.inspect, token_to_str(t) || '?')
558
+ end
559
+
560
+ # Enter error recovering mode.
561
+ # This method does not call #on_error.
562
+ def yyerror
563
+ throw :racc_jump, 1
564
+ end
565
+
566
+ # Exit parser.
567
+ # Return value is +Symbol_Value_Stack[0]+.
568
+ def yyaccept
569
+ throw :racc_jump, 2
570
+ end
571
+
572
+ # Leave error recovering mode.
573
+ def yyerrok
574
+ @racc_error_status = 0
575
+ end
576
+
577
+ # For debugging output
578
+ def racc_read_token(t, tok, val)
579
+ @racc_debug_out.print 'read '
580
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
581
+ @racc_debug_out.puts val.inspect
582
+ @racc_debug_out.puts
583
+ end
584
+
585
+ def racc_shift(tok, tstack, vstack)
586
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
587
+ racc_print_stacks tstack, vstack
588
+ @racc_debug_out.puts
589
+ end
590
+
591
+ def racc_reduce(toks, sim, tstack, vstack)
592
+ out = @racc_debug_out
593
+ out.print 'reduce '
594
+ if toks.empty?
595
+ out.print ' <none>'
596
+ else
597
+ toks.each {|t| out.print ' ', racc_token2str(t) }
598
+ end
599
+ out.puts " --> #{racc_token2str(sim)}"
600
+ racc_print_stacks tstack, vstack
601
+ @racc_debug_out.puts
602
+ end
603
+
604
+ def racc_accept
605
+ @racc_debug_out.puts 'accept'
606
+ @racc_debug_out.puts
607
+ end
608
+
609
+ def racc_e_pop(state, tstack, vstack)
610
+ @racc_debug_out.puts 'error recovering mode: pop token'
611
+ racc_print_states state
612
+ racc_print_stacks tstack, vstack
613
+ @racc_debug_out.puts
614
+ end
615
+
616
+ def racc_next_state(curstate, state)
617
+ @racc_debug_out.puts "goto #{curstate}"
618
+ racc_print_states state
619
+ @racc_debug_out.puts
620
+ end
621
+
622
+ def racc_print_stacks(t, v)
623
+ out = @racc_debug_out
624
+ out.print ' ['
625
+ t.each_index do |i|
626
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
627
+ end
628
+ out.puts ' ]'
629
+ end
630
+
631
+ def racc_print_states(s)
632
+ out = @racc_debug_out
633
+ out.print ' ['
634
+ s.each {|st| out.print ' ', st }
635
+ out.puts ' ]'
636
+ end
637
+
638
+ def racc_token2str(tok)
639
+ self.class::Racc_token_to_s_table[tok] or
640
+ raise "[Racc Bug] can't convert token #{tok} to string"
641
+ end
642
+
643
+ # Convert internal ID of token symbol to the string.
644
+ def token_to_str(t)
645
+ self.class::Racc_token_to_s_table[t]
646
+ end
647
+
648
+ end
649
+
650
+ end
651
+
652
+ ...end racc/parser.rb/module_eval...
653
+ end
654
+ ###### racc/parser.rb end
8
655
 
9
656
 
10
657
  require 'deep_merge'
11
658
  require 'ipaddr'
659
+ require 'json'
12
660
  require 'strscan'
13
661
 
14
662
  module Puffy
15
663
  class Parser < Racc::Parser
16
664
 
17
- module_eval(<<'...end parser.y/module_eval...', 'parser.y', 166)
665
+ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 176)
18
666
 
19
667
  attr_accessor :yydebug
20
- attr_reader :policy, :filename
668
+ attr_reader :current_policies, :filename
21
669
  #attr_accessor :variables, :nodes, :services
22
670
 
23
671
  def ipaddress?(s)
@@ -98,6 +746,7 @@ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 166)
98
746
  when s.scan(/rdr-to\b/) then emit(:RDR_TO, s.matched)
99
747
  when s.scan(/srv\b/) then emit(:SRV, s.matched)
100
748
  when s.scan(/apt-mirror\b/) then emit(:APT_MIRROR, s.matched)
749
+ when s.scan(/azure-ip-range\b/) then emit(:AZURE_IP_RANGE, s.matched)
101
750
 
102
751
  when s.scan(/\d+\.\d+\.\d+\.\d+(\/\d+)?/) && ip = ipaddress?(s) then emit(:ADDRESS, ip, s.matched_size)
103
752
  when s.scan(/[[:xdigit:]]*:[:[:xdigit:]]+(\/\d+)?/) && ip = ipaddress?(s) then emit(:ADDRESS, ip, s.matched_size)
@@ -120,7 +769,7 @@ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 166)
120
769
 
121
770
  begin
122
771
  do_parse
123
- rescue Racc::ParseError => e
772
+ rescue Racc::ParseError
124
773
  raise ParseError.new("Parse error: unexpected token: #{@current_token[0]}", @current_token[1])
125
774
  end
126
775
  end
@@ -154,6 +803,10 @@ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 166)
154
803
  @saved_policies = {}
155
804
  @services = {}
156
805
  @rule_factory = Puffy::RuleFactory.new
806
+ @default_policies = {
807
+ in: { action: :block, log: false },
808
+ out: { action: :block, log: false },
809
+ }
157
810
  end
158
811
 
159
812
  def nodes
@@ -200,8 +853,8 @@ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 166)
200
853
  end.flatten
201
854
  end
202
855
 
203
- def policy_for(hostname)
204
- prefered_value_for_hostname(@saved_policies, hostname) || @default_policy || :block
856
+ def policies_for(hostname)
857
+ return @default_policies.merge(prefered_value_for_hostname(@saved_policies, hostname))
205
858
  end
206
859
 
207
860
  def constraint_service_to_hosts(service, hosts)
@@ -227,244 +880,259 @@ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 166)
227
880
  ##### State transition tables begin ###
228
881
 
229
882
  racc_action_table = [
230
- 134, 134, 131, 134, 134, 6, 155, 156, 167, 75,
231
- 162, 17, 160, 7, 8, 34, 110, 18, 9, 115,
232
- 116, 111, 110, 10, 35, 115, 116, 111, 110, 77,
233
- 78, 115, 116, 111, 21, 17, 133, 133, 22, 133,
234
- 133, 18, 169, 170, 107, 112, 120, 121, 113, 114,
235
- 107, 112, 17, 15, 113, 114, 107, 112, 18, 6,
236
- 113, 114, 6, 27, 39, 77, 78, 7, 8, 6,
237
- 7, 8, 9, 40, 24, 9, 6, 7, 8, 68,
238
- 25, 26, 9, 50, 7, 8, 77, 78, 67, 9,
239
- 48, 49, 51, 52, 50, 25, 26, 115, 116, 70,
240
- 39, 48, 49, 51, 52, 50, 25, 26, 69, 40,
241
- 9, 63, 48, 49, 51, 52, 50, 25, 26, 136,
242
- 137, 9, 79, 48, 49, 51, 52, 50, 25, 26,
243
- 141, 142, 115, 116, 48, 49, 51, 52, 50, 25,
244
- 26, 30, 31, 32, 97, 48, 49, 51, 52, 50,
245
- 25, 26, 30, 31, 32, 100, 48, 49, 51, 52,
246
- 50, 25, 26, 90, 91, 92, 101, 48, 49, 51,
247
- 52, 50, 25, 26, 90, 91, 92, 102, 48, 49,
248
- 51, 52, 50, 25, 26, 90, 91, 92, 103, 48,
249
- 49, 51, 52, 50, 25, 26, 90, 91, 92, 104,
250
- 48, 49, 51, 52, 50, 25, 26, 77, 78, 115,
251
- 116, 48, 49, 51, 52, 50, 25, 26, 169, 170,
252
- 105, 119, 48, 49, 51, 52, 19, 25, 26, 123,
253
- 21, 17, 55, 56, 22, 21, 21, 18, 28, 22,
254
- 22, 30, 31, 32, 60, 61, 30, 31, 32, 162,
255
- 114, 114, 171, 172, 114, 129, 130, 138, 144, 145,
256
- 148, 150, 114, 153, 154, 158, 162, 175, 176, 162,
257
- 178, 179 ]
883
+ 36, 36, 31, 144, 93, 36, 38, 134, 135, 12,
884
+ 36, 38, 43, 76, 77, 36, 38, 17, 23, 44,
885
+ 24, 38, 6, 51, 52, 51, 52, 7, 127, 8,
886
+ 178, 29, 38, 10, 40, 35, 35, 37, 41, 40,
887
+ 35, 30, 37, 41, 40, 35, 36, 37, 41, 40,
888
+ 35, 36, 37, 41, 124, 128, 56, 127, 129, 130,
889
+ 40, 38, 48, 37, 41, 180, 181, 36, 127, 49,
890
+ 167, 168, 38, 57, 152, 153, 23, 38, 24, 38,
891
+ 160, 35, 110, 124, 128, 160, 35, 129, 130, 40,
892
+ 38, 10, 37, 41, 124, 128, 108, 109, 129, 130,
893
+ 40, 160, 35, 37, 41, 40, 86, 40, 37, 41,
894
+ 37, 41, 10, 85, 19, 64, 75, 110, 40, 110,
895
+ 20, 37, 41, 62, 63, 65, 66, 64, 79, 26,
896
+ 27, 108, 109, 108, 109, 62, 63, 65, 66, 64,
897
+ 21, 26, 27, 110, 23, 88, 24, 62, 63, 65,
898
+ 66, 64, 87, 26, 27, 26, 27, 108, 109, 62,
899
+ 63, 65, 66, 64, 19, 26, 27, 51, 52, 48,
900
+ 20, 62, 63, 65, 66, 64, 49, 26, 27, 173,
901
+ 80, 171, 19, 62, 63, 65, 66, 64, 20, 26,
902
+ 27, 26, 27, 81, 19, 62, 63, 65, 66, 64,
903
+ 20, 26, 27, 51, 52, 51, 52, 62, 63, 65,
904
+ 66, 64, 173, 26, 27, 182, 183, 147, 148, 62,
905
+ 63, 65, 66, 64, 95, 26, 27, 51, 52, 180,
906
+ 181, 62, 63, 65, 66, 64, 100, 26, 27, 102,
907
+ 75, 117, 118, 62, 63, 65, 66, 6, 6, 26,
908
+ 27, 119, 7, 7, 8, 8, 6, 6, 10, 10,
909
+ 120, 7, 7, 8, 8, 121, 122, 10, 10, 69,
910
+ 70, 133, 23, 137, 24, 130, 130, 142, 143, 149,
911
+ 155, 156, 162, 130, 165, 166, 173, 186, 187, 173,
912
+ 189, 190 ]
258
913
 
259
914
  racc_action_check = [
260
- 114, 131, 114, 146, 156, 0, 146, 146, 164, 53,
261
- 150, 7, 150, 0, 0, 16, 90, 7, 0, 90,
262
- 90, 90, 91, 1, 16, 91, 91, 91, 123, 53,
263
- 53, 123, 123, 123, 19, 50, 114, 131, 19, 146,
264
- 156, 50, 164, 164, 90, 90, 98, 98, 90, 90,
265
- 91, 91, 51, 6, 91, 91, 123, 123, 51, 2,
266
- 123, 123, 3, 10, 20, 98, 98, 2, 2, 4,
267
- 3, 3, 2, 20, 9, 3, 5, 4, 4, 48,
268
- 9, 9, 4, 34, 5, 5, 75, 75, 48, 5,
269
- 34, 34, 34, 34, 35, 34, 34, 110, 110, 49,
270
- 55, 35, 35, 35, 35, 39, 35, 35, 49, 55,
271
- 39, 44, 39, 39, 39, 39, 40, 39, 39, 118,
272
- 118, 40, 54, 40, 40, 40, 40, 45, 40, 40,
273
- 126, 126, 126, 126, 45, 45, 45, 45, 46, 45,
274
- 45, 28, 28, 28, 74, 46, 46, 46, 46, 47,
275
- 46, 46, 61, 61, 61, 82, 47, 47, 47, 47,
276
- 58, 47, 47, 71, 71, 71, 83, 58, 58, 58,
277
- 58, 59, 58, 58, 72, 72, 72, 85, 59, 59,
278
- 59, 59, 67, 59, 59, 73, 73, 73, 86, 67,
279
- 67, 67, 67, 68, 67, 67, 149, 149, 149, 87,
280
- 68, 68, 68, 68, 69, 68, 68, 121, 121, 142,
281
- 142, 69, 69, 69, 69, 70, 69, 69, 167, 167,
282
- 88, 96, 70, 70, 70, 70, 8, 70, 70, 106,
283
- 8, 52, 36, 36, 8, 36, 56, 52, 15, 36,
284
- 56, 15, 15, 15, 42, 42, 42, 42, 42, 165,
285
- 107, 108, 165, 165, 111, 112, 113, 119, 129, 130,
286
- 133, 135, 141, 144, 145, 148, 160, 169, 170, 172,
287
- 175, 178 ]
915
+ 17, 130, 17, 130, 67, 31, 17, 115, 115, 1,
916
+ 54, 31, 18, 54, 54, 77, 54, 6, 21, 18,
917
+ 21, 77, 0, 67, 67, 115, 115, 0, 108, 0,
918
+ 175, 11, 108, 0, 17, 17, 130, 17, 17, 31,
919
+ 31, 12, 31, 31, 54, 54, 144, 54, 54, 77,
920
+ 77, 168, 77, 77, 108, 108, 35, 109, 108, 108,
921
+ 108, 109, 22, 108, 108, 175, 175, 157, 137, 22,
922
+ 157, 157, 137, 41, 140, 140, 70, 140, 70, 127,
923
+ 144, 144, 89, 109, 109, 168, 168, 109, 109, 109,
924
+ 153, 48, 109, 109, 137, 137, 89, 89, 137, 137,
925
+ 137, 157, 157, 137, 137, 140, 62, 127, 140, 140,
926
+ 127, 127, 49, 62, 7, 43, 50, 90, 153, 91,
927
+ 7, 153, 153, 43, 43, 43, 43, 44, 56, 43,
928
+ 43, 90, 90, 91, 91, 44, 44, 44, 44, 59,
929
+ 8, 44, 44, 161, 8, 63, 8, 59, 59, 59,
930
+ 59, 60, 63, 59, 59, 10, 10, 161, 161, 60,
931
+ 60, 60, 60, 61, 64, 60, 60, 25, 25, 69,
932
+ 64, 61, 61, 61, 61, 72, 69, 61, 61, 162,
933
+ 57, 162, 65, 72, 72, 72, 72, 73, 65, 72,
934
+ 72, 29, 29, 58, 66, 73, 73, 73, 73, 85,
935
+ 66, 73, 73, 53, 53, 93, 93, 85, 85, 85,
936
+ 85, 86, 176, 85, 85, 176, 176, 132, 132, 86,
937
+ 86, 86, 86, 87, 68, 86, 86, 135, 135, 178,
938
+ 178, 87, 87, 87, 87, 88, 74, 87, 87, 80,
939
+ 92, 98, 99, 88, 88, 88, 88, 2, 3, 88,
940
+ 88, 103, 2, 3, 2, 3, 4, 5, 2, 3,
941
+ 104, 4, 5, 4, 5, 105, 106, 4, 5, 45,
942
+ 45, 114, 45, 123, 45, 124, 126, 128, 129, 133,
943
+ 142, 143, 146, 152, 155, 156, 171, 180, 181, 183,
944
+ 186, 189 ]
288
945
 
289
946
  racc_action_pointer = [
290
- 3, 23, 57, 60, 67, 74, 50, 9, 222, 58,
291
- 63, nil, nil, nil, nil, 234, 11, nil, nil, 26,
292
- 60, nil, nil, nil, nil, nil, nil, nil, 134, nil,
293
- nil, nil, nil, nil, 73, 84, 227, nil, nil, 95,
294
- 106, nil, 239, nil, 106, 117, 128, 139, 75, 95,
295
- 33, 50, 229, 5, 108, 96, 228, nil, 150, 161,
296
- nil, 145, nil, nil, nil, nil, nil, 172, 183, 194,
297
- 205, 134, 145, 156, 128, 62, nil, nil, nil, nil,
298
- nil, nil, 150, 152, nil, 163, 183, 185, 215, nil,
299
- 12, 18, nil, nil, nil, nil, 200, nil, 41, nil,
300
- nil, nil, nil, nil, nil, nil, 199, 213, 214, nil,
301
- 90, 217, 221, 222, -2, nil, nil, nil, 93, 249,
302
- nil, 183, nil, 24, nil, nil, 125, nil, nil, 250,
303
- 251, -1, nil, 221, nil, 233, nil, nil, nil, nil,
304
- nil, 225, 202, nil, 228, 229, 1, nil, 227, 167,
305
- 8, nil, nil, nil, nil, nil, 2, nil, nil, nil,
306
- 264, nil, nil, nil, 2, 247, nil, 178, nil, 260,
307
- 261, nil, 267, nil, nil, 233, nil, nil, 233, nil ]
947
+ 20, 9, 245, 246, 254, 255, 14, 112, 136, nil,
948
+ 134, 18, 41, nil, nil, nil, nil, -2, 8, nil,
949
+ nil, 10, 58, nil, nil, 144, nil, nil, nil, 170,
950
+ nil, 3, nil, nil, nil, 18, nil, nil, nil, nil,
951
+ nil, 41, nil, 108, 120, 264, nil, nil, 78, 99,
952
+ 97, nil, nil, 180, 8, nil, 91, 172, 188, 132,
953
+ 144, 156, 102, 141, 162, 180, 192, 0, 212, 165,
954
+ 68, nil, 168, 180, 222, nil, nil, 13, nil, nil,
955
+ 206, nil, nil, nil, nil, 192, 204, 216, 228, 68,
956
+ 103, 105, 221, 182, nil, nil, nil, nil, 236, 230,
957
+ nil, nil, nil, 239, 255, 253, 261, nil, 24, 53,
958
+ nil, nil, nil, nil, 251, 2, nil, nil, nil, nil,
959
+ nil, nil, nil, 244, 240, nil, 241, 71, 245, 246,
960
+ -1, nil, 192, 271, nil, 204, nil, 64, nil, nil,
961
+ 69, nil, 272, 273, 44, nil, 255, nil, nil, nil,
962
+ nil, nil, 248, 82, nil, 251, 252, 65, nil, nil,
963
+ nil, 129, 177, nil, nil, nil, nil, nil, 49, nil,
964
+ nil, 284, nil, nil, nil, 24, 210, nil, 188, nil,
965
+ 248, 249, nil, 287, nil, nil, 255, nil, nil, 254,
966
+ nil ]
308
967
 
309
968
  racc_action_default = [
310
- -5, -100, -5, -5, -5, -5, -100, -100, -100, -100,
311
- -100, -1, -2, -3, -4, -100, -100, -15, -16, -100,
312
- -100, -22, -23, -33, -34, -47, -48, 180, -100, -7,
313
- -11, -12, -13, -14, -32, -32, -100, -21, -18, -32,
314
- -32, -26, -100, -10, -100, -32, -32, -32, -100, -100,
315
- -100, -100, -100, -49, -100, -100, -100, -20, -32, -32,
316
- -6, -100, -9, -27, -29, -30, -31, -32, -32, -32,
317
- -32, -72, -72, -72, -44, -100, -51, -55, -56, -28,
318
- -17, -19, -100, -100, -8, -100, -100, -100, -100, -39,
319
- -82, -82, -70, -71, -40, -41, -45, -43, -100, -54,
320
- -24, -25, -35, -36, -37, -38, -68, -82, -82, -75,
321
- -100, -82, -100, -100, -100, -89, -90, -69, -57, -100,
322
- -50, -100, -53, -82, -73, -74, -100, -93, -77, -100,
323
- -100, -100, -81, -86, -87, -60, -58, -59, -46, -52,
324
- -67, -82, -100, -92, -100, -100, -100, -85, -100, -100,
325
- -100, -76, -91, -78, -79, -80, -100, -84, -88, -96,
326
- -100, -62, -66, -83, -42, -100, -65, -100, -95, -100,
327
- -100, -61, -100, -64, -94, -98, -99, -63, -100, -97 ]
969
+ -5, -105, -5, -5, -5, -5, -105, -105, -105, -31,
970
+ -105, -34, -105, -1, -2, -3, -4, -105, -105, -14,
971
+ -15, -105, -105, -21, -22, -32, -48, -49, -33, -105,
972
+ 191, -105, -7, -11, -12, -88, -89, -91, -92, -96,
973
+ -97, -105, -13, -30, -30, -105, -20, -17, -34, -34,
974
+ -45, -56, -57, -105, -105, -10, -105, -105, -105, -30,
975
+ -30, -30, -105, -105, -105, -105, -105, -50, -105, -105,
976
+ -105, -19, -30, -30, -105, -44, -6, -105, -9, -90,
977
+ -105, -25, -27, -28, -29, -30, -30, -30, -30, -73,
978
+ -73, -73, -45, -105, -52, -26, -16, -18, -105, -105,
979
+ -35, -8, -98, -105, -105, -105, -105, -40, -82, -82,
980
+ -71, -72, -41, -42, -46, -105, -55, -23, -24, -36,
981
+ -37, -38, -39, -69, -82, -75, -82, -105, -105, -105,
982
+ -105, -70, -58, -105, -51, -105, -54, -82, -74, -76,
983
+ -105, -95, -105, -105, -105, -81, -61, -59, -60, -47,
984
+ -53, -68, -82, -105, -94, -105, -105, -105, -85, -86,
985
+ -87, -105, -105, -77, -93, -78, -79, -80, -105, -84,
986
+ -101, -105, -63, -67, -83, -43, -105, -66, -105, -100,
987
+ -105, -105, -62, -105, -65, -99, -103, -104, -64, -105,
988
+ -102 ]
328
989
 
329
990
  racc_goto_table = [
330
- 76, 20, 132, 16, 29, 38, 161, 124, 125, 106,
331
- 117, 128, 37, 58, 59, 168, 166, 43, 174, 147,
332
- 127, 173, 99, 89, 94, 95, 42, 33, 177, 57,
333
- 36, 62, 23, 74, 157, 96, 143, 118, 135, 149,
334
- 80, 151, 140, 159, 163, 122, 71, 72, 73, 81,
335
- 84, 54, 152, 164, 98, 1, 54, 11, 12, 13,
336
- 14, 64, 65, 66, 165, 126, 146, nil, 139, nil,
337
- nil, nil, nil, nil, 82, 83, nil, nil, nil, nil,
338
- nil, nil, nil, 85, 86, 87, 88 ]
991
+ 94, 22, 32, 47, 126, 126, 25, 18, 145, 74,
992
+ 179, 58, 68, 185, 46, 138, 55, 139, 123, 131,
993
+ 54, 158, 159, 141, 42, 53, 116, 82, 83, 84,
994
+ 107, 112, 113, 126, 169, 159, 154, 45, 71, 78,
995
+ 98, 99, 28, 163, 92, 174, 159, 151, 136, 164,
996
+ 96, 114, 132, 103, 104, 105, 106, 146, 172, 72,
997
+ 73, 161, 101, 97, 89, 90, 91, 177, 150, 170,
998
+ 175, 1, 184, 13, 14, 15, 16, 115, 176, 188,
999
+ 140, 157 ]
339
1000
 
340
1001
  racc_goto_check = [
341
- 27, 12, 35, 8, 7, 11, 29, 31, 31, 30,
342
- 30, 31, 12, 4, 4, 36, 29, 7, 36, 35,
343
- 32, 29, 27, 18, 18, 18, 6, 9, 29, 12,
344
- 10, 7, 17, 19, 35, 20, 32, 21, 22, 23,
345
- 11, 31, 30, 24, 35, 27, 8, 8, 8, 12,
346
- 7, 13, 32, 25, 26, 1, 13, 1, 1, 1,
347
- 1, 13, 13, 13, 28, 33, 34, nil, 27, nil,
348
- nil, nil, nil, nil, 13, 13, nil, nil, nil, nil,
349
- nil, nil, nil, 13, 13, 13, 13 ]
1002
+ 22, 14, 7, 13, 8, 8, 20, 10, 9, 23,
1003
+ 40, 15, 15, 40, 14, 35, 7, 35, 34, 34,
1004
+ 6, 38, 9, 8, 11, 20, 22, 15, 15, 15,
1005
+ 24, 24, 24, 8, 38, 9, 8, 12, 14, 7,
1006
+ 15, 15, 19, 35, 25, 38, 9, 34, 22, 8,
1007
+ 13, 23, 26, 15, 15, 15, 15, 27, 33, 4,
1008
+ 4, 28, 7, 14, 10, 10, 10, 33, 22, 29,
1009
+ 30, 1, 33, 1, 1, 1, 1, 31, 32, 33,
1010
+ 36, 37 ]
350
1011
 
351
1012
  racc_goto_pointer = [
352
- nil, 55, nil, nil, -26, nil, -2, -11, -4, 11,
353
- 11, -15, -7, 16, nil, nil, nil, 23, -48, -20,
354
- -39, -59, -80, -96, -106, -106, -21, -53, -96, -144,
355
- -81, -100, -90, -45, -65, -112, -149 ]
1013
+ nil, 71, nil, nil, 11, nil, -11, -15, -104, -122,
1014
+ 0, 6, 16, -19, -7, -32, nil, nil, nil, 31,
1015
+ -4, nil, -67, -41, -59, -23, -62, -75, -85, -92,
1016
+ -100, -16, -93, -104, -90, -109, -47, -63, -123, nil,
1017
+ -165 ]
356
1018
 
357
1019
  racc_goto_default = [
358
- nil, nil, 2, 3, 4, 5, nil, nil, nil, 41,
359
- nil, nil, nil, 44, 45, 46, 47, 53, nil, nil,
360
- nil, nil, nil, nil, 93, nil, nil, nil, nil, nil,
361
- nil, 109, 108, nil, nil, nil, nil ]
1020
+ nil, nil, 2, 3, 4, 5, nil, nil, 33, 34,
1021
+ nil, nil, nil, nil, nil, nil, 59, 60, 61, 9,
1022
+ 67, 11, 50, nil, nil, nil, nil, nil, nil, 111,
1023
+ nil, nil, nil, nil, nil, 125, nil, nil, nil, 39,
1024
+ nil ]
362
1025
 
363
1026
  racc_reduce_table = [
364
1027
  0, 0, :racc_error,
365
- 2, 43, :_reduce_none,
366
- 2, 43, :_reduce_none,
367
- 2, 43, :_reduce_3,
368
- 2, 43, :_reduce_none,
369
- 0, 43, :_reduce_none,
370
- 5, 44, :_reduce_6,
371
- 3, 44, :_reduce_7,
372
- 3, 48, :_reduce_8,
373
- 2, 48, :_reduce_9,
374
- 1, 48, :_reduce_10,
375
- 1, 49, :_reduce_11,
376
- 1, 49, :_reduce_12,
377
- 1, 49, :_reduce_13,
378
- 3, 47, :_reduce_14,
379
- 1, 50, :_reduce_15,
380
- 1, 50, :_reduce_16,
381
- 5, 45, :_reduce_17,
382
- 3, 45, :_reduce_18,
383
- 3, 52, :_reduce_19,
384
- 2, 52, :_reduce_20,
385
- 1, 52, :_reduce_21,
386
- 1, 54, :_reduce_22,
387
- 1, 54, :_reduce_23,
388
- 4, 53, :_reduce_24,
389
- 4, 53, :_reduce_25,
390
- 1, 53, :_reduce_26,
391
- 3, 51, :_reduce_27,
392
- 3, 51, :_reduce_28,
393
- 2, 55, :_reduce_29,
394
- 2, 55, :_reduce_30,
395
- 2, 55, :_reduce_31,
396
- 0, 55, :_reduce_32,
397
- 2, 46, :_reduce_33,
398
- 2, 46, :_reduce_34,
399
- 4, 57, :_reduce_35,
400
- 4, 57, :_reduce_36,
401
- 4, 58, :_reduce_37,
402
- 4, 58, :_reduce_38,
403
- 3, 56, :_reduce_39,
404
- 3, 56, :_reduce_40,
405
- 3, 56, :_reduce_41,
406
- 8, 56, :_reduce_42,
407
- 1, 62, :_reduce_none,
408
- 0, 62, :_reduce_none,
409
- 0, 63, :_reduce_none,
410
- 2, 63, :_reduce_46,
411
- 1, 59, :_reduce_47,
412
- 1, 59, :_reduce_48,
413
- 0, 61, :_reduce_none,
414
- 3, 61, :_reduce_50,
415
- 1, 61, :_reduce_51,
416
- 3, 68, :_reduce_52,
417
- 2, 68, :_reduce_53,
418
- 1, 68, :_reduce_54,
419
- 1, 69, :_reduce_55,
420
- 1, 69, :_reduce_56,
421
- 0, 64, :_reduce_none,
422
- 1, 64, :_reduce_58,
423
- 1, 64, :_reduce_59,
424
- 0, 65, :_reduce_none,
425
- 4, 65, :_reduce_61,
426
- 2, 65, :_reduce_62,
427
- 3, 70, :_reduce_63,
428
- 2, 70, :_reduce_64,
429
- 1, 70, :_reduce_65,
430
- 1, 71, :_reduce_66,
431
- 4, 66, :_reduce_67,
432
- 2, 66, :_reduce_68,
433
- 2, 66, :_reduce_69,
434
- 1, 66, :_reduce_70,
435
- 1, 60, :_reduce_none,
436
- 0, 60, :_reduce_72,
437
- 2, 72, :_reduce_73,
438
- 2, 72, :_reduce_74,
439
- 1, 72, :_reduce_75,
440
- 4, 72, :_reduce_76,
441
- 2, 72, :_reduce_77,
442
- 4, 72, :_reduce_78,
443
- 4, 72, :_reduce_79,
444
- 4, 73, :_reduce_80,
445
- 2, 73, :_reduce_81,
446
- 0, 73, :_reduce_none,
447
- 3, 76, :_reduce_83,
448
- 2, 76, :_reduce_84,
449
- 1, 76, :_reduce_85,
450
- 1, 77, :_reduce_86,
451
- 1, 77, :_reduce_87,
452
- 3, 77, :_reduce_88,
453
- 1, 74, :_reduce_89,
454
- 1, 74, :_reduce_90,
455
- 3, 75, :_reduce_91,
456
- 2, 75, :_reduce_92,
457
- 1, 75, :_reduce_93,
458
- 3, 67, :_reduce_94,
459
- 2, 67, :_reduce_95,
460
- 0, 67, :_reduce_96,
461
- 4, 78, :_reduce_97,
462
- 2, 78, :_reduce_98,
463
- 2, 78, :_reduce_99 ]
464
-
465
- racc_reduce_n = 100
466
-
467
- racc_shift_n = 180
1028
+ 2, 44, :_reduce_none,
1029
+ 2, 44, :_reduce_none,
1030
+ 2, 44, :_reduce_3,
1031
+ 2, 44, :_reduce_none,
1032
+ 0, 44, :_reduce_none,
1033
+ 5, 45, :_reduce_6,
1034
+ 3, 45, :_reduce_7,
1035
+ 3, 49, :_reduce_8,
1036
+ 2, 49, :_reduce_9,
1037
+ 1, 49, :_reduce_10,
1038
+ 1, 50, :_reduce_11,
1039
+ 1, 50, :_reduce_12,
1040
+ 3, 48, :_reduce_13,
1041
+ 1, 53, :_reduce_14,
1042
+ 1, 53, :_reduce_15,
1043
+ 5, 46, :_reduce_16,
1044
+ 3, 46, :_reduce_17,
1045
+ 3, 55, :_reduce_18,
1046
+ 2, 55, :_reduce_19,
1047
+ 1, 55, :_reduce_20,
1048
+ 1, 57, :_reduce_21,
1049
+ 1, 57, :_reduce_22,
1050
+ 4, 56, :_reduce_23,
1051
+ 4, 56, :_reduce_24,
1052
+ 3, 54, :_reduce_25,
1053
+ 3, 54, :_reduce_26,
1054
+ 2, 58, :_reduce_27,
1055
+ 2, 58, :_reduce_28,
1056
+ 2, 58, :_reduce_29,
1057
+ 0, 58, :_reduce_30,
1058
+ 1, 47, :_reduce_31,
1059
+ 2, 47, :_reduce_32,
1060
+ 2, 62, :_reduce_33,
1061
+ 0, 62, :_reduce_34,
1062
+ 5, 64, :_reduce_35,
1063
+ 4, 60, :_reduce_36,
1064
+ 4, 60, :_reduce_37,
1065
+ 4, 61, :_reduce_38,
1066
+ 4, 61, :_reduce_39,
1067
+ 3, 59, :_reduce_40,
1068
+ 3, 59, :_reduce_41,
1069
+ 3, 59, :_reduce_42,
1070
+ 8, 59, :_reduce_43,
1071
+ 1, 66, :_reduce_44,
1072
+ 0, 66, :_reduce_45,
1073
+ 0, 69, :_reduce_none,
1074
+ 2, 69, :_reduce_47,
1075
+ 1, 63, :_reduce_48,
1076
+ 1, 63, :_reduce_49,
1077
+ 0, 68, :_reduce_none,
1078
+ 3, 68, :_reduce_51,
1079
+ 1, 68, :_reduce_52,
1080
+ 3, 74, :_reduce_53,
1081
+ 2, 74, :_reduce_54,
1082
+ 1, 74, :_reduce_55,
1083
+ 1, 65, :_reduce_56,
1084
+ 1, 65, :_reduce_57,
1085
+ 0, 70, :_reduce_none,
1086
+ 1, 70, :_reduce_59,
1087
+ 1, 70, :_reduce_60,
1088
+ 0, 71, :_reduce_none,
1089
+ 4, 71, :_reduce_62,
1090
+ 2, 71, :_reduce_63,
1091
+ 3, 75, :_reduce_64,
1092
+ 2, 75, :_reduce_65,
1093
+ 1, 75, :_reduce_66,
1094
+ 1, 76, :_reduce_67,
1095
+ 4, 72, :_reduce_68,
1096
+ 2, 72, :_reduce_69,
1097
+ 2, 72, :_reduce_70,
1098
+ 1, 72, :_reduce_71,
1099
+ 1, 67, :_reduce_none,
1100
+ 0, 67, :_reduce_73,
1101
+ 2, 77, :_reduce_74,
1102
+ 1, 77, :_reduce_75,
1103
+ 2, 77, :_reduce_76,
1104
+ 4, 77, :_reduce_77,
1105
+ 4, 77, :_reduce_78,
1106
+ 4, 77, :_reduce_79,
1107
+ 4, 78, :_reduce_80,
1108
+ 2, 78, :_reduce_81,
1109
+ 0, 78, :_reduce_none,
1110
+ 3, 80, :_reduce_83,
1111
+ 2, 80, :_reduce_84,
1112
+ 1, 80, :_reduce_85,
1113
+ 1, 81, :_reduce_86,
1114
+ 1, 81, :_reduce_87,
1115
+ 1, 52, :_reduce_88,
1116
+ 1, 52, :_reduce_89,
1117
+ 3, 52, :_reduce_90,
1118
+ 1, 82, :_reduce_91,
1119
+ 1, 82, :_reduce_92,
1120
+ 3, 79, :_reduce_93,
1121
+ 2, 79, :_reduce_94,
1122
+ 1, 79, :_reduce_95,
1123
+ 1, 51, :_reduce_96,
1124
+ 1, 51, :_reduce_97,
1125
+ 4, 51, :_reduce_98,
1126
+ 3, 73, :_reduce_99,
1127
+ 2, 73, :_reduce_100,
1128
+ 0, 73, :_reduce_101,
1129
+ 4, 83, :_reduce_102,
1130
+ 2, 83, :_reduce_103,
1131
+ 2, 83, :_reduce_104 ]
1132
+
1133
+ racc_reduce_n = 105
1134
+
1135
+ racc_shift_n = 191
468
1136
 
469
1137
  racc_token_table = {
470
1138
  false => 0,
@@ -474,43 +1142,44 @@ racc_token_table = {
474
1142
  "{" => 4,
475
1143
  "}" => 5,
476
1144
  "," => 6,
477
- :ADDRESS => 7,
1145
+ :SERVICE => 7,
478
1146
  :STRING => 8,
479
- :VARIABLE => 9,
480
- :SERVICE => 10,
481
- :NODE => 11,
482
- :REGEX => 12,
483
- :DO => 13,
484
- :END => 14,
485
- :POLICY => 15,
486
- :LOG => 16,
487
- :IPV4 => 17,
488
- :IPV6 => 18,
489
- :CLIENT => 19,
490
- :SERVER => 20,
491
- :ON => 21,
492
- :BLOCK => 22,
493
- :PASS => 23,
494
- :IN => 24,
495
- :OUT => 25,
496
- :INET => 26,
497
- :INET6 => 27,
498
- :PROTO => 28,
499
- :FROM => 29,
500
- :TO => 30,
501
- :ALL => 31,
502
- :ANY => 32,
503
- :SRV => 33,
504
- "(" => 34,
505
- ")" => 35,
506
- :APT_MIRROR => 36,
507
- :PORT => 37,
508
- :INTEGER => 38,
509
- ":" => 39,
510
- :RDR_TO => 40,
511
- :NAT_TO => 41 }
512
-
513
- racc_nt_base = 42
1147
+ :NODE => 9,
1148
+ :REGEX => 10,
1149
+ :DO => 11,
1150
+ :END => 12,
1151
+ :POLICY => 13,
1152
+ :ALL => 14,
1153
+ :IPV4 => 15,
1154
+ :IPV6 => 16,
1155
+ :CLIENT => 17,
1156
+ :SERVER => 18,
1157
+ :LOG => 19,
1158
+ :ON => 20,
1159
+ :BLOCK => 21,
1160
+ :PASS => 22,
1161
+ :IN => 23,
1162
+ :OUT => 24,
1163
+ :INET => 25,
1164
+ :INET6 => 26,
1165
+ :PROTO => 27,
1166
+ :FROM => 28,
1167
+ :TO => 29,
1168
+ :ANY => 30,
1169
+ :SRV => 31,
1170
+ "(" => 32,
1171
+ ")" => 33,
1172
+ :APT_MIRROR => 34,
1173
+ :PORT => 35,
1174
+ :VARIABLE => 36,
1175
+ :INTEGER => 37,
1176
+ ":" => 38,
1177
+ :ADDRESS => 39,
1178
+ :AZURE_IP_RANGE => 40,
1179
+ :RDR_TO => 41,
1180
+ :NAT_TO => 42 }
1181
+
1182
+ racc_nt_base = 43
514
1183
 
515
1184
  racc_use_result_var = true
516
1185
 
@@ -539,20 +1208,19 @@ Racc_token_to_s_table = [
539
1208
  "\"{\"",
540
1209
  "\"}\"",
541
1210
  "\",\"",
542
- "ADDRESS",
543
- "STRING",
544
- "VARIABLE",
545
1211
  "SERVICE",
1212
+ "STRING",
546
1213
  "NODE",
547
1214
  "REGEX",
548
1215
  "DO",
549
1216
  "END",
550
1217
  "POLICY",
551
- "LOG",
1218
+ "ALL",
552
1219
  "IPV4",
553
1220
  "IPV6",
554
1221
  "CLIENT",
555
1222
  "SERVER",
1223
+ "LOG",
556
1224
  "ON",
557
1225
  "BLOCK",
558
1226
  "PASS",
@@ -563,53 +1231,59 @@ Racc_token_to_s_table = [
563
1231
  "PROTO",
564
1232
  "FROM",
565
1233
  "TO",
566
- "ALL",
567
1234
  "ANY",
568
1235
  "SRV",
569
1236
  "\"(\"",
570
1237
  "\")\"",
571
1238
  "APT_MIRROR",
572
1239
  "PORT",
1240
+ "VARIABLE",
573
1241
  "INTEGER",
574
1242
  "\":\"",
1243
+ "ADDRESS",
1244
+ "AZURE_IP_RANGE",
575
1245
  "RDR_TO",
576
1246
  "NAT_TO",
577
1247
  "$start",
578
1248
  "target",
579
1249
  "assignation",
580
1250
  "node",
581
- "policy",
1251
+ "policies",
582
1252
  "service",
583
1253
  "variable_value_list",
584
1254
  "variable_value",
1255
+ "host_list_item",
1256
+ "port",
585
1257
  "service_name",
586
1258
  "block",
587
1259
  "node_name_list",
588
- "block_with_policy",
1260
+ "block_with_policies",
589
1261
  "node_name",
590
1262
  "rules",
591
1263
  "pf_rule",
592
1264
  "ipv4_block",
593
1265
  "ipv6_block",
1266
+ "policy_list",
594
1267
  "action",
1268
+ "policy",
1269
+ "direction",
1270
+ "log",
595
1271
  "optional_hosts",
596
1272
  "rule_direction",
597
- "log",
598
1273
  "on_interface",
599
1274
  "rule_af",
600
1275
  "protospec",
601
1276
  "hosts",
602
1277
  "filteropts",
603
1278
  "direction_list",
604
- "direction",
605
1279
  "protocol_list",
606
1280
  "protocol",
607
1281
  "hosts_host",
608
1282
  "hosts_port",
609
- "host",
610
1283
  "host_list",
611
1284
  "port_list",
612
- "port",
1285
+ "port_list_item",
1286
+ "host",
613
1287
  "filteropt" ]
614
1288
  Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
615
1289
 
@@ -625,7 +1299,7 @@ Racc_debug_parser = false
625
1299
 
626
1300
  module_eval(<<'.,.,', 'parser.y', 4)
627
1301
  def _reduce_3(val, _values, result)
628
- @default_policy = val[0]
1302
+ @default_policies = val[0]
629
1303
  result
630
1304
  end
631
1305
  .,.,
@@ -671,28 +1345,28 @@ module_eval(<<'.,.,', 'parser.y', 13)
671
1345
 
672
1346
  module_eval(<<'.,.,', 'parser.y', 15)
673
1347
  def _reduce_11(val, _values, result)
674
- result = val[0][:value]
1348
+ result = val[0]
675
1349
  result
676
1350
  end
677
1351
  .,.,
678
1352
 
679
1353
  module_eval(<<'.,.,', 'parser.y', 16)
680
1354
  def _reduce_12(val, _values, result)
681
- result = val[0][:value]
1355
+ result = val[0]
682
1356
  result
683
1357
  end
684
1358
  .,.,
685
1359
 
686
- module_eval(<<'.,.,', 'parser.y', 17)
1360
+ module_eval(<<'.,.,', 'parser.y', 18)
687
1361
  def _reduce_13(val, _values, result)
688
- result = @variables.fetch(val[0][:value])
1362
+ @services[val[1]] = val[2]
689
1363
  result
690
1364
  end
691
1365
  .,.,
692
1366
 
693
- module_eval(<<'.,.,', 'parser.y', 19)
1367
+ module_eval(<<'.,.,', 'parser.y', 20)
694
1368
  def _reduce_14(val, _values, result)
695
- @services[val[1]] = val[2]
1369
+ result = val[0][:value]
696
1370
  result
697
1371
  end
698
1372
  .,.,
@@ -704,44 +1378,44 @@ module_eval(<<'.,.,', 'parser.y', 21)
704
1378
  end
705
1379
  .,.,
706
1380
 
707
- module_eval(<<'.,.,', 'parser.y', 22)
1381
+ module_eval(<<'.,.,', 'parser.y', 23)
708
1382
  def _reduce_16(val, _values, result)
709
- result = val[0][:value]
1383
+ val[2].each { |name| @nodes[name] = val[4]; @saved_policies[name] = @current_policies }
710
1384
  result
711
1385
  end
712
1386
  .,.,
713
1387
 
714
1388
  module_eval(<<'.,.,', 'parser.y', 24)
715
1389
  def _reduce_17(val, _values, result)
716
- val[2].each { |name| @nodes[name] = val[4]; @saved_policies[name] = @policy }
1390
+ @nodes[val[1]] = val[2]; @saved_policies[val[1]] = @current_policies
717
1391
  result
718
1392
  end
719
1393
  .,.,
720
1394
 
721
- module_eval(<<'.,.,', 'parser.y', 25)
1395
+ module_eval(<<'.,.,', 'parser.y', 26)
722
1396
  def _reduce_18(val, _values, result)
723
- @nodes[val[1]] = val[2]; @saved_policies[val[1]] = @policy
1397
+ result = val[0] + [val[2]]
724
1398
  result
725
1399
  end
726
1400
  .,.,
727
1401
 
728
1402
  module_eval(<<'.,.,', 'parser.y', 27)
729
1403
  def _reduce_19(val, _values, result)
730
- result = val[0] + [val[2]]
1404
+ result = val[0] + [val[1]]
731
1405
  result
732
1406
  end
733
1407
  .,.,
734
1408
 
735
1409
  module_eval(<<'.,.,', 'parser.y', 28)
736
1410
  def _reduce_20(val, _values, result)
737
- result = val[0] + [val[1]]
1411
+ result = [val[0]]
738
1412
  result
739
1413
  end
740
1414
  .,.,
741
1415
 
742
- module_eval(<<'.,.,', 'parser.y', 29)
1416
+ module_eval(<<'.,.,', 'parser.y', 30)
743
1417
  def _reduce_21(val, _values, result)
744
- result = [val[0]]
1418
+ result = val[0][:value]
745
1419
  result
746
1420
  end
747
1421
  .,.,
@@ -753,44 +1427,44 @@ module_eval(<<'.,.,', 'parser.y', 31)
753
1427
  end
754
1428
  .,.,
755
1429
 
756
- module_eval(<<'.,.,', 'parser.y', 32)
1430
+ module_eval(<<'.,.,', 'parser.y', 33)
757
1431
  def _reduce_23(val, _values, result)
758
- result = val[0][:value]
1432
+ @current_policies = val[1]; result = val[2]
759
1433
  result
760
1434
  end
761
1435
  .,.,
762
1436
 
763
1437
  module_eval(<<'.,.,', 'parser.y', 34)
764
1438
  def _reduce_24(val, _values, result)
765
- @policy = val[1]; result = val[2]
1439
+ @current_policies = val[1]; result = val[2]
766
1440
  result
767
1441
  end
768
1442
  .,.,
769
1443
 
770
- module_eval(<<'.,.,', 'parser.y', 35)
1444
+ module_eval(<<'.,.,', 'parser.y', 36)
771
1445
  def _reduce_25(val, _values, result)
772
- @policy = val[1]; result = val[2]
1446
+ result = val[1].freeze
773
1447
  result
774
1448
  end
775
1449
  .,.,
776
1450
 
777
- module_eval(<<'.,.,', 'parser.y', 36)
1451
+ module_eval(<<'.,.,', 'parser.y', 37)
778
1452
  def _reduce_26(val, _values, result)
779
- @policy = nil; result = val[0]
1453
+ result = val[1].freeze
780
1454
  result
781
1455
  end
782
1456
  .,.,
783
1457
 
784
- module_eval(<<'.,.,', 'parser.y', 38)
1458
+ module_eval(<<'.,.,', 'parser.y', 39)
785
1459
  def _reduce_27(val, _values, result)
786
- result = val[1].freeze
1460
+ result = val[0] + val[1]
787
1461
  result
788
1462
  end
789
1463
  .,.,
790
1464
 
791
- module_eval(<<'.,.,', 'parser.y', 39)
1465
+ module_eval(<<'.,.,', 'parser.y', 40)
792
1466
  def _reduce_28(val, _values, result)
793
- result = val[1].freeze
1467
+ result = val[0] + val[1]
794
1468
  result
795
1469
  end
796
1470
  .,.,
@@ -804,61 +1478,61 @@ module_eval(<<'.,.,', 'parser.y', 41)
804
1478
 
805
1479
  module_eval(<<'.,.,', 'parser.y', 42)
806
1480
  def _reduce_30(val, _values, result)
807
- result = val[0] + val[1]
1481
+ result = []
808
1482
  result
809
1483
  end
810
1484
  .,.,
811
1485
 
812
- module_eval(<<'.,.,', 'parser.y', 43)
1486
+ module_eval(<<'.,.,', 'parser.y', 44)
813
1487
  def _reduce_31(val, _values, result)
814
- result = val[0] + val[1]
1488
+ result = val[0]
815
1489
  result
816
1490
  end
817
1491
  .,.,
818
1492
 
819
- module_eval(<<'.,.,', 'parser.y', 44)
1493
+ module_eval(<<'.,.,', 'parser.y', 45)
820
1494
  def _reduce_32(val, _values, result)
821
- result = []
1495
+ warn("#{val[0][:filename]}:#{val[0][:lineno]}:#{val[0][:position]}: deprecated policy syntax:\n\t#{val[0][:line]}\n\t#{' ' * val[0][:position]}^#{'~' * (val[0][:line].length - 1 - val[0][:position])}\n\tUse explicit 'in' and 'out' policies, with optional logging:\n\tpolicy #{val[1][:action]} in all\n\tpolicy #{val[1][:action]} out all") ; result = { in: { action: val[1][:action] }, out: { action: val[1][:action] } }
822
1496
  result
823
1497
  end
824
1498
  .,.,
825
1499
 
826
- module_eval(<<'.,.,', 'parser.y', 46)
1500
+ module_eval(<<'.,.,', 'parser.y', 47)
827
1501
  def _reduce_33(val, _values, result)
828
- result = val[1][:action]
1502
+ result = val[1].merge(val[0][:dir] => val[0])
829
1503
  result
830
1504
  end
831
1505
  .,.,
832
1506
 
833
- module_eval(<<'.,.,', 'parser.y', 47)
1507
+ module_eval(<<'.,.,', 'parser.y', 48)
834
1508
  def _reduce_34(val, _values, result)
835
- result = 'log'
1509
+ result = {}
836
1510
  result
837
1511
  end
838
1512
  .,.,
839
1513
 
840
- module_eval(<<'.,.,', 'parser.y', 49)
1514
+ module_eval(<<'.,.,', 'parser.y', 50)
841
1515
  def _reduce_35(val, _values, result)
842
- result = val[2].reject { |x| x[:af] == :inet6 }.map { |x| x[:af] = :inet ; x }
1516
+ result = { action: val[1][:action], dir: val[2], log: val[3].any? }
843
1517
  result
844
1518
  end
845
1519
  .,.,
846
1520
 
847
- module_eval(<<'.,.,', 'parser.y', 50)
1521
+ module_eval(<<'.,.,', 'parser.y', 52)
848
1522
  def _reduce_36(val, _values, result)
849
1523
  result = val[2].reject { |x| x[:af] == :inet6 }.map { |x| x[:af] = :inet ; x }
850
1524
  result
851
1525
  end
852
1526
  .,.,
853
1527
 
854
- module_eval(<<'.,.,', 'parser.y', 52)
1528
+ module_eval(<<'.,.,', 'parser.y', 53)
855
1529
  def _reduce_37(val, _values, result)
856
- result = val[2].reject { |x| x[:af] == :inet }.map { |x| x[:af] = :inet6 ; x }
1530
+ result = val[2].reject { |x| x[:af] == :inet6 }.map { |x| x[:af] = :inet ; x }
857
1531
  result
858
1532
  end
859
1533
  .,.,
860
1534
 
861
- module_eval(<<'.,.,', 'parser.y', 53)
1535
+ module_eval(<<'.,.,', 'parser.y', 55)
862
1536
  def _reduce_38(val, _values, result)
863
1537
  result = val[2].reject { |x| x[:af] == :inet }.map { |x| x[:af] = :inet6 ; x }
864
1538
  result
@@ -867,6 +1541,13 @@ module_eval(<<'.,.,', 'parser.y', 53)
867
1541
 
868
1542
  module_eval(<<'.,.,', 'parser.y', 56)
869
1543
  def _reduce_39(val, _values, result)
1544
+ result = val[2].reject { |x| x[:af] == :inet }.map { |x| x[:af] = :inet6 ; x }
1545
+ result
1546
+ end
1547
+ .,.,
1548
+
1549
+ module_eval(<<'.,.,', 'parser.y', 59)
1550
+ def _reduce_40(val, _values, result)
870
1551
  begin
871
1552
  result = constraint_service_to_hosts(val[1], val[2])
872
1553
  rescue KeyError
@@ -877,8 +1558,8 @@ module_eval(<<'.,.,', 'parser.y', 56)
877
1558
  end
878
1559
  .,.,
879
1560
 
880
- module_eval(<<'.,.,', 'parser.y', 63)
881
- def _reduce_40(val, _values, result)
1561
+ module_eval(<<'.,.,', 'parser.y', 66)
1562
+ def _reduce_41(val, _values, result)
882
1563
  begin
883
1564
  raise "service #{val[1]} cannot be used as client" if @services.fetch(val[1]).map { |x| x[:dir] }.compact.any?
884
1565
  result = constraint_service_to_hosts(val[1], val[2]).map { |item| item.merge(dir: :out) }
@@ -890,8 +1571,8 @@ module_eval(<<'.,.,', 'parser.y', 63)
890
1571
  end
891
1572
  .,.,
892
1573
 
893
- module_eval(<<'.,.,', 'parser.y', 71)
894
- def _reduce_41(val, _values, result)
1574
+ module_eval(<<'.,.,', 'parser.y', 74)
1575
+ def _reduce_42(val, _values, result)
895
1576
  begin
896
1577
  raise "service #{val[1]} cannot be used as server" if @services.fetch(val[1]).map { |x| x[:dir] }.compact.any?
897
1578
  result = constraint_service_to_hosts(val[1], val[2]).map { |item| item.merge(dir: :in) }
@@ -903,245 +1584,248 @@ module_eval(<<'.,.,', 'parser.y', 71)
903
1584
  end
904
1585
  .,.,
905
1586
 
906
- module_eval(<<'.,.,', 'parser.y', 78)
907
- def _reduce_42(val, _values, result)
1587
+ module_eval(<<'.,.,', 'parser.y', 81)
1588
+ def _reduce_43(val, _values, result)
908
1589
  result = [val.compact.inject(:merge)]
909
1590
  result
910
1591
  end
911
1592
  .,.,
912
1593
 
913
- # reduce 43 omitted
914
-
915
- # reduce 44 omitted
916
-
917
- # reduce 45 omitted
1594
+ module_eval(<<'.,.,', 'parser.y', 83)
1595
+ def _reduce_44(val, _values, result)
1596
+ result = { log: true }
1597
+ result
1598
+ end
1599
+ .,.,
918
1600
 
919
1601
  module_eval(<<'.,.,', 'parser.y', 84)
920
- def _reduce_46(val, _values, result)
921
- result = { on: val[1][:value] }
1602
+ def _reduce_45(val, _values, result)
1603
+ result = {}
922
1604
  result
923
1605
  end
924
1606
  .,.,
925
1607
 
926
- module_eval(<<'.,.,', 'parser.y', 86)
1608
+ # reduce 46 omitted
1609
+
1610
+ module_eval(<<'.,.,', 'parser.y', 87)
927
1611
  def _reduce_47(val, _values, result)
928
- result = { action: :block }
1612
+ result = { on: val[1][:value] }
929
1613
  result
930
1614
  end
931
1615
  .,.,
932
1616
 
933
- module_eval(<<'.,.,', 'parser.y', 87)
1617
+ module_eval(<<'.,.,', 'parser.y', 89)
934
1618
  def _reduce_48(val, _values, result)
935
- result = { action: :pass }
1619
+ result = { action: :block }
936
1620
  result
937
1621
  end
938
1622
  .,.,
939
1623
 
940
- # reduce 49 omitted
941
-
942
1624
  module_eval(<<'.,.,', 'parser.y', 90)
943
- def _reduce_50(val, _values, result)
944
- result = { dir: val[1] }
1625
+ def _reduce_49(val, _values, result)
1626
+ result = { action: :pass }
945
1627
  result
946
1628
  end
947
1629
  .,.,
948
1630
 
949
- module_eval(<<'.,.,', 'parser.y', 91)
1631
+ # reduce 50 omitted
1632
+
1633
+ module_eval(<<'.,.,', 'parser.y', 93)
950
1634
  def _reduce_51(val, _values, result)
951
- result = { dir: val[0] }
1635
+ result = { dir: val[1] }
952
1636
  result
953
1637
  end
954
1638
  .,.,
955
1639
 
956
- module_eval(<<'.,.,', 'parser.y', 93)
1640
+ module_eval(<<'.,.,', 'parser.y', 94)
957
1641
  def _reduce_52(val, _values, result)
958
- result = val[0] + [val[2]]
1642
+ result = { dir: val[0] }
959
1643
  result
960
1644
  end
961
1645
  .,.,
962
1646
 
963
- module_eval(<<'.,.,', 'parser.y', 94)
1647
+ module_eval(<<'.,.,', 'parser.y', 96)
964
1648
  def _reduce_53(val, _values, result)
965
- result = val[0] + [val[1]]
1649
+ result = val[0] + [val[2]]
966
1650
  result
967
1651
  end
968
1652
  .,.,
969
1653
 
970
- module_eval(<<'.,.,', 'parser.y', 95)
1654
+ module_eval(<<'.,.,', 'parser.y', 97)
971
1655
  def _reduce_54(val, _values, result)
972
- result = [val[0]]
1656
+ result = val[0] + [val[1]]
973
1657
  result
974
1658
  end
975
1659
  .,.,
976
1660
 
977
- module_eval(<<'.,.,', 'parser.y', 97)
1661
+ module_eval(<<'.,.,', 'parser.y', 98)
978
1662
  def _reduce_55(val, _values, result)
979
- result = :in
1663
+ result = [val[0]]
980
1664
  result
981
1665
  end
982
1666
  .,.,
983
1667
 
984
- module_eval(<<'.,.,', 'parser.y', 98)
1668
+ module_eval(<<'.,.,', 'parser.y', 100)
985
1669
  def _reduce_56(val, _values, result)
986
- result = :out
1670
+ result = :in
987
1671
  result
988
1672
  end
989
1673
  .,.,
990
1674
 
991
- # reduce 57 omitted
992
-
993
1675
  module_eval(<<'.,.,', 'parser.y', 101)
994
- def _reduce_58(val, _values, result)
995
- result = { af: :inet }
1676
+ def _reduce_57(val, _values, result)
1677
+ result = :out
996
1678
  result
997
1679
  end
998
1680
  .,.,
999
1681
 
1000
- module_eval(<<'.,.,', 'parser.y', 102)
1682
+ # reduce 58 omitted
1683
+
1684
+ module_eval(<<'.,.,', 'parser.y', 104)
1001
1685
  def _reduce_59(val, _values, result)
1002
- result = { af: :inet6 }
1686
+ result = { af: :inet }
1003
1687
  result
1004
1688
  end
1005
1689
  .,.,
1006
1690
 
1007
- # reduce 60 omitted
1008
-
1009
1691
  module_eval(<<'.,.,', 'parser.y', 105)
1010
- def _reduce_61(val, _values, result)
1011
- result = { proto: val[2] }
1692
+ def _reduce_60(val, _values, result)
1693
+ result = { af: :inet6 }
1012
1694
  result
1013
1695
  end
1014
1696
  .,.,
1015
1697
 
1016
- module_eval(<<'.,.,', 'parser.y', 106)
1698
+ # reduce 61 omitted
1699
+
1700
+ module_eval(<<'.,.,', 'parser.y', 108)
1017
1701
  def _reduce_62(val, _values, result)
1018
- result = { proto: val[1] }
1702
+ result = { proto: val[2] }
1019
1703
  result
1020
1704
  end
1021
1705
  .,.,
1022
1706
 
1023
- module_eval(<<'.,.,', 'parser.y', 108)
1707
+ module_eval(<<'.,.,', 'parser.y', 109)
1024
1708
  def _reduce_63(val, _values, result)
1025
- result = val[0] + [val[2]]
1709
+ result = { proto: val[1] }
1026
1710
  result
1027
1711
  end
1028
1712
  .,.,
1029
1713
 
1030
- module_eval(<<'.,.,', 'parser.y', 109)
1714
+ module_eval(<<'.,.,', 'parser.y', 111)
1031
1715
  def _reduce_64(val, _values, result)
1032
- result = val[0] + [val[1]]
1716
+ result = val[0] + [val[2]]
1033
1717
  result
1034
1718
  end
1035
1719
  .,.,
1036
1720
 
1037
- module_eval(<<'.,.,', 'parser.y', 110)
1721
+ module_eval(<<'.,.,', 'parser.y', 112)
1038
1722
  def _reduce_65(val, _values, result)
1039
- result = [val[0]]
1723
+ result = val[0] + [val[1]]
1040
1724
  result
1041
1725
  end
1042
1726
  .,.,
1043
1727
 
1044
- module_eval(<<'.,.,', 'parser.y', 112)
1728
+ module_eval(<<'.,.,', 'parser.y', 113)
1045
1729
  def _reduce_66(val, _values, result)
1046
- result = val[0][:value].to_sym
1730
+ result = [val[0]]
1047
1731
  result
1048
1732
  end
1049
1733
  .,.,
1050
1734
 
1051
- module_eval(<<'.,.,', 'parser.y', 114)
1735
+ module_eval(<<'.,.,', 'parser.y', 115)
1052
1736
  def _reduce_67(val, _values, result)
1053
- result = { from: val[1], to: val[3] }
1737
+ result = val[0][:value].to_sym
1054
1738
  result
1055
1739
  end
1056
1740
  .,.,
1057
1741
 
1058
- module_eval(<<'.,.,', 'parser.y', 115)
1742
+ module_eval(<<'.,.,', 'parser.y', 117)
1059
1743
  def _reduce_68(val, _values, result)
1060
- result = { from: val[1] }
1744
+ result = { from: val[1], to: val[3] }
1061
1745
  result
1062
1746
  end
1063
1747
  .,.,
1064
1748
 
1065
- module_eval(<<'.,.,', 'parser.y', 116)
1749
+ module_eval(<<'.,.,', 'parser.y', 118)
1066
1750
  def _reduce_69(val, _values, result)
1067
- result = { to: val[1] }
1751
+ result = { from: val[1] }
1068
1752
  result
1069
1753
  end
1070
1754
  .,.,
1071
1755
 
1072
- module_eval(<<'.,.,', 'parser.y', 117)
1756
+ module_eval(<<'.,.,', 'parser.y', 119)
1073
1757
  def _reduce_70(val, _values, result)
1074
- result = {}
1758
+ result = { to: val[1] }
1075
1759
  result
1076
1760
  end
1077
1761
  .,.,
1078
1762
 
1079
- # reduce 71 omitted
1080
-
1081
1763
  module_eval(<<'.,.,', 'parser.y', 120)
1082
- def _reduce_72(val, _values, result)
1764
+ def _reduce_71(val, _values, result)
1083
1765
  result = {}
1084
1766
  result
1085
1767
  end
1086
1768
  .,.,
1087
1769
 
1088
- module_eval(<<'.,.,', 'parser.y', 122)
1770
+ # reduce 72 omitted
1771
+
1772
+ module_eval(<<'.,.,', 'parser.y', 123)
1089
1773
  def _reduce_73(val, _values, result)
1090
- result = [{ host: nil, port: val[1] }]
1774
+ result = {}
1091
1775
  result
1092
1776
  end
1093
1777
  .,.,
1094
1778
 
1095
- module_eval(<<'.,.,', 'parser.y', 123)
1779
+ module_eval(<<'.,.,', 'parser.y', 125)
1096
1780
  def _reduce_74(val, _values, result)
1097
- result = [{ host: val[0], port: val[1] }]
1781
+ result = [{ host: nil, port: val[1] }]
1098
1782
  result
1099
1783
  end
1100
1784
  .,.,
1101
1785
 
1102
- module_eval(<<'.,.,', 'parser.y', 124)
1786
+ module_eval(<<'.,.,', 'parser.y', 126)
1103
1787
  def _reduce_75(val, _values, result)
1104
1788
  result = [{ host: nil, port: val[0] }]
1105
1789
  result
1106
1790
  end
1107
1791
  .,.,
1108
1792
 
1109
- module_eval(<<'.,.,', 'parser.y', 125)
1793
+ module_eval(<<'.,.,', 'parser.y', 127)
1110
1794
  def _reduce_76(val, _values, result)
1111
- result = [{ host: val[1], port: val[3] }]
1795
+ result = [{ host: val[0], port: val[1] }]
1112
1796
  result
1113
1797
  end
1114
1798
  .,.,
1115
1799
 
1116
- module_eval(<<'.,.,', 'parser.y', 126)
1800
+ module_eval(<<'.,.,', 'parser.y', 128)
1117
1801
  def _reduce_77(val, _values, result)
1118
- result = [{ host: @variables.fetch(val[0][:value]), port: val[1] }]
1802
+ result = [{ host: val[1], port: val[3] }]
1119
1803
  result
1120
1804
  end
1121
1805
  .,.,
1122
1806
 
1123
- module_eval(<<'.,.,', 'parser.y', 127)
1807
+ module_eval(<<'.,.,', 'parser.y', 129)
1124
1808
  def _reduce_78(val, _values, result)
1125
1809
  result = Resolver.instance.resolv_srv(val[2][:value])
1126
1810
  result
1127
1811
  end
1128
1812
  .,.,
1129
1813
 
1130
- module_eval(<<'.,.,', 'parser.y', 128)
1814
+ module_eval(<<'.,.,', 'parser.y', 130)
1131
1815
  def _reduce_79(val, _values, result)
1132
1816
  result = Resolver.instance.resolv_apt_mirror(val[2][:value])
1133
1817
  result
1134
1818
  end
1135
1819
  .,.,
1136
1820
 
1137
- module_eval(<<'.,.,', 'parser.y', 130)
1821
+ module_eval(<<'.,.,', 'parser.y', 132)
1138
1822
  def _reduce_80(val, _values, result)
1139
1823
  result = val[2]
1140
1824
  result
1141
1825
  end
1142
1826
  .,.,
1143
1827
 
1144
- module_eval(<<'.,.,', 'parser.y', 131)
1828
+ module_eval(<<'.,.,', 'parser.y', 133)
1145
1829
  def _reduce_81(val, _values, result)
1146
1830
  result = val[1]
1147
1831
  result
@@ -1150,120 +1834,155 @@ module_eval(<<'.,.,', 'parser.y', 131)
1150
1834
 
1151
1835
  # reduce 82 omitted
1152
1836
 
1153
- module_eval(<<'.,.,', 'parser.y', 134)
1837
+ module_eval(<<'.,.,', 'parser.y', 136)
1154
1838
  def _reduce_83(val, _values, result)
1155
- result = val[0] + [val[2]]
1839
+ result = val[0] + val[2]
1156
1840
  result
1157
1841
  end
1158
1842
  .,.,
1159
1843
 
1160
- module_eval(<<'.,.,', 'parser.y', 135)
1844
+ module_eval(<<'.,.,', 'parser.y', 137)
1161
1845
  def _reduce_84(val, _values, result)
1162
- result = val[0] + [val[1]]
1846
+ result = val[0] + val[1]
1163
1847
  result
1164
1848
  end
1165
1849
  .,.,
1166
1850
 
1167
- module_eval(<<'.,.,', 'parser.y', 136)
1851
+ module_eval(<<'.,.,', 'parser.y', 138)
1168
1852
  def _reduce_85(val, _values, result)
1169
- result = [val[0]]
1853
+ result = val[0]
1170
1854
  result
1171
1855
  end
1172
1856
  .,.,
1173
1857
 
1174
- module_eval(<<'.,.,', 'parser.y', 138)
1858
+ module_eval(<<'.,.,', 'parser.y', 140)
1175
1859
  def _reduce_86(val, _values, result)
1176
- result = val[0][:value]
1860
+ result = [val[0]]
1177
1861
  result
1178
1862
  end
1179
1863
  .,.,
1180
1864
 
1181
- module_eval(<<'.,.,', 'parser.y', 139)
1865
+ module_eval(<<'.,.,', 'parser.y', 141)
1182
1866
  def _reduce_87(val, _values, result)
1183
- result = val[0][:value]
1867
+ result = @variables.fetch(val[0][:value])
1184
1868
  result
1185
1869
  end
1186
1870
  .,.,
1187
1871
 
1188
- module_eval(<<'.,.,', 'parser.y', 140)
1872
+ module_eval(<<'.,.,', 'parser.y', 143)
1189
1873
  def _reduce_88(val, _values, result)
1190
- result = Range.new(val[0][:value], val[2][:value])
1874
+ result = val[0][:value]
1191
1875
  result
1192
1876
  end
1193
1877
  .,.,
1194
1878
 
1195
- module_eval(<<'.,.,', 'parser.y', 142)
1879
+ module_eval(<<'.,.,', 'parser.y', 144)
1196
1880
  def _reduce_89(val, _values, result)
1197
1881
  result = val[0][:value]
1198
1882
  result
1199
1883
  end
1200
1884
  .,.,
1201
1885
 
1202
- module_eval(<<'.,.,', 'parser.y', 143)
1886
+ module_eval(<<'.,.,', 'parser.y', 145)
1203
1887
  def _reduce_90(val, _values, result)
1204
- result = val[0][:value]
1888
+ result = Range.new(val[0][:value], val[2][:value])
1205
1889
  result
1206
1890
  end
1207
1891
  .,.,
1208
1892
 
1209
- module_eval(<<'.,.,', 'parser.y', 145)
1893
+ module_eval(<<'.,.,', 'parser.y', 147)
1210
1894
  def _reduce_91(val, _values, result)
1211
- result = val[0] + [val[2]]
1895
+ result = val[0][:value]
1212
1896
  result
1213
1897
  end
1214
1898
  .,.,
1215
1899
 
1216
- module_eval(<<'.,.,', 'parser.y', 146)
1900
+ module_eval(<<'.,.,', 'parser.y', 148)
1217
1901
  def _reduce_92(val, _values, result)
1218
- result = val[0] + [val[1]]
1902
+ result = val[0][:value]
1219
1903
  result
1220
1904
  end
1221
1905
  .,.,
1222
1906
 
1223
- module_eval(<<'.,.,', 'parser.y', 147)
1907
+ module_eval(<<'.,.,', 'parser.y', 150)
1224
1908
  def _reduce_93(val, _values, result)
1225
- result = [val[0]]
1909
+ result = val[0] + val[2]
1226
1910
  result
1227
1911
  end
1228
1912
  .,.,
1229
1913
 
1230
- module_eval(<<'.,.,', 'parser.y', 149)
1914
+ module_eval(<<'.,.,', 'parser.y', 151)
1231
1915
  def _reduce_94(val, _values, result)
1232
- result = val[0].merge(val[2])
1916
+ result = val[0] + val[1]
1233
1917
  result
1234
1918
  end
1235
1919
  .,.,
1236
1920
 
1237
- module_eval(<<'.,.,', 'parser.y', 150)
1921
+ module_eval(<<'.,.,', 'parser.y', 152)
1238
1922
  def _reduce_95(val, _values, result)
1239
- result = val[0].merge(val[1])
1923
+ result = val[0]
1240
1924
  result
1241
1925
  end
1242
1926
  .,.,
1243
1927
 
1244
- module_eval(<<'.,.,', 'parser.y', 151)
1928
+ module_eval(<<'.,.,', 'parser.y', 154)
1245
1929
  def _reduce_96(val, _values, result)
1246
- result = {}
1930
+ result = [val[0]]
1247
1931
  result
1248
1932
  end
1249
1933
  .,.,
1250
1934
 
1251
- module_eval(<<'.,.,', 'parser.y', 153)
1935
+ module_eval(<<'.,.,', 'parser.y', 155)
1252
1936
  def _reduce_97(val, _values, result)
1253
- result = { rdr_to: [{ host: val[1][:value], port: val[3][:value] }] }
1937
+ result = @variables.fetch(val[0][:value])
1254
1938
  result
1255
1939
  end
1256
1940
  .,.,
1257
1941
 
1258
- module_eval(<<'.,.,', 'parser.y', 154)
1942
+ module_eval(<<'.,.,', 'parser.y', 156)
1259
1943
  def _reduce_98(val, _values, result)
1260
- result = { rdr_to: [{ host: val[1][:value], port: nil }] }
1944
+ result = Resolver.instance.resolv_azure_ip_range(val[2][:value])
1261
1945
  result
1262
1946
  end
1263
1947
  .,.,
1264
1948
 
1265
- module_eval(<<'.,.,', 'parser.y', 155)
1949
+ module_eval(<<'.,.,', 'parser.y', 158)
1266
1950
  def _reduce_99(val, _values, result)
1951
+ result = val[0].merge(val[2])
1952
+ result
1953
+ end
1954
+ .,.,
1955
+
1956
+ module_eval(<<'.,.,', 'parser.y', 159)
1957
+ def _reduce_100(val, _values, result)
1958
+ result = val[0].merge(val[1])
1959
+ result
1960
+ end
1961
+ .,.,
1962
+
1963
+ module_eval(<<'.,.,', 'parser.y', 160)
1964
+ def _reduce_101(val, _values, result)
1965
+ result = {}
1966
+ result
1967
+ end
1968
+ .,.,
1969
+
1970
+ module_eval(<<'.,.,', 'parser.y', 162)
1971
+ def _reduce_102(val, _values, result)
1972
+ result = { rdr_to: [{ host: val[1][:value], port: val[3][:value] }] }
1973
+ result
1974
+ end
1975
+ .,.,
1976
+
1977
+ module_eval(<<'.,.,', 'parser.y', 163)
1978
+ def _reduce_103(val, _values, result)
1979
+ result = { rdr_to: [{ host: val[1][:value], port: nil }] }
1980
+ result
1981
+ end
1982
+ .,.,
1983
+
1984
+ module_eval(<<'.,.,', 'parser.y', 164)
1985
+ def _reduce_104(val, _values, result)
1267
1986
  result = { nat_to: val[1][:value] }
1268
1987
  result
1269
1988
  end