Module: CiscoAclIntp::SpecialTokenHandler
- Included in:
- Scanner
- Defined in:
- lib/cisco_acl_intp/scanner_special_token_handler.rb
Overview
Data and Handler functions of special tokens
Constant Summary collapse
- STR_REGEXP =
STRING token regexp: first letter is alphabet or digit
'[a-zA-Z\d]\S*'.freeze
- STRING_ARG_TOKENS =
Tokens that takes string parameter
[ ['remark', :leftover], ['description', :leftover], ['extended', :word], ['standard', :word], ['dynamic', :word], ['log-input', :word], ['log', :word], ['time-range', :word], ['reflect', :word], ['evaluate', :word], ['object-group', 'network', :word], ['object-group', 'service', :word], ['object-group', :word], # longest match ['group-object', :word] ].freeze
- SYMBOL_TO_REGEXPSTR =
Conversion table of string-tokens
{ word: ['(', STR_REGEXP, ')'].join, leftover: '(.*)$' }.freeze
Instance Method Summary collapse
-
#convert_tokens_to_regexpstr(set) ⇒ String
Convert STRING_ARG_TOKENS to Regexp string.
-
#gen_arg_token_lists ⇒ Array
Generate regexp string list for scanner.
Instance Method Details
#convert_tokens_to_regexpstr(set) ⇒ String
Convert STRING_ARG_TOKENS to Regexp string
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cisco_acl_intp/scanner_special_token_handler.rb', line 38 def convert_tokens_to_regexpstr(set) set.map do |each| case each when String '(' + each + ')' when Symbol SYMBOL_TO_REGEXPSTR[each] end end end |
#gen_arg_token_lists ⇒ Array
Generate regexp string list for scanner
51 52 53 54 55 56 |
# File 'lib/cisco_acl_intp/scanner_special_token_handler.rb', line 51 def gen_arg_token_lists STRING_ARG_TOKENS.map do |each| re_str_list = convert_tokens_to_regexpstr(each) [re_str_list.join('\s+'), each.length] end end |