module RegexpExamples::ParseGroupHelper
A collection of related helper methods, utilised by the ‘Parser` class
Protected Instance Methods
parse_caret()
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 6 def parse_caret if @current_position == 0 PlaceHolderGroup.new # Ignore the "illegal" character else raise_anchors_exception! end end
parse_char_group()
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 40 def parse_char_group @current_position += 1 # Skip past opening "[" chargroup_parser = ChargroupParser.new(rest_of_string) chargroup_parser.parse @current_position += (chargroup_parser.length - 1) # Step back to closing "]" CharGroup.new(chargroup_parser.result, @ignorecase) end
parse_dollar()
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 14 def parse_dollar if @current_position == (regexp_string.length - 1) PlaceHolderGroup.new # Ignore the "illegal" character else raise_anchors_exception! end end
parse_dot_group()
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 48 def parse_dot_group DotGroup.new(@multiline) end
parse_extended_whitespace()
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 22 def parse_extended_whitespace if @extended skip_whitespace PlaceHolderGroup.new # Ignore the whitespace/comment else parse_single_char_group(next_char) end end
parse_or_group(left_repeaters)
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 52 def parse_or_group(left_repeaters) @current_position += 1 right_repeaters = parse OrGroup.new(left_repeaters, right_repeaters) end
parse_single_char_group(char)
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 36 def parse_single_char_group(char) SingleCharGroup.new(char, @ignorecase) end
skip_whitespace()
click to toggle source
# File lib/regexp-examples/parser_helpers/parse_group_helper.rb, line 31 def skip_whitespace whitespace_chars = rest_of_string.match(/#.*|\s+/)[0] @current_position += whitespace_chars.length - 1 end