class PERL5_REGULAR_EXPRESSION_BUILDER
Summary
Direct parents
Inherit list: POSIX_REGULAR_EXPRESSION_BUILDER
Known children
Inherit list: PYTHON_REGULAR_EXPRESSION_BUILDER
Class invariant
Overview
Creation features
Features
options
{ANY}
scanning
{PERL5_REGULAR_EXPRESSION_BUILDER}
parsing
{BACKTRACKING_REGULAR_EXPRESSION_BUILDER}
  • read_character
    Goto to the next character that is not a blank or a comment.
  • read_integer
    Reads in 'last_integer' the current integer values and then goto to the next character that is not a blank or a comment.
  • emit_repeat (mini: INTEGER_32, maxi: INTEGER_32)
    Takes the top of the stack and replace it with a construction that will evaluate the repeating of it from 'mini' to 'maxi' times.
parsing
{POSIX_REGULAR_EXPRESSION_BUILDER}
parsing
{}
parsing
{BACKTRACKING_REGULAR_EXPRESSION_BUILDER}
parsing
{POSIX_REGULAR_EXPRESSION_BUILDER}
sub parts of union
{POSIX_REGULAR_EXPRESSION_BUILDER}
make
{ANY}
  • make
    Initialise the attributes.
behaviors
{ANY}
internal behavior
{}
parsing
{ANY}
results
{ANY}
build
{}
basic
{ANY}
error management
{ANY}
scanning
{ANY}
assertions
{ANY}
character classes
{ANY}
character class naming
{ANY}
{}
and/or basics
{ANY}
has_extended_legibility: BOOLEAN
writable attribute
{ANY}
Is the extended legibility active?
has_extended_ligibility: BOOLEAN
effective function
{ANY}
This feature is obsolete: Use `has_extended_legibility' instead.
set_extended_legibility
effective procedure
{ANY}
Activate extended legibility.
ensure
set_extended_ligibility
effective procedure
{ANY}
This feature is obsolete: Use `set_extended_legibility' instead.
set_no_extended_legibility
effective procedure
{ANY}
Deactivate extended legibility.
ensure
set_no_extended_ligibility
effective procedure
{ANY}
This feature is obsolete: Use `set_no_extended_legibility' instead.
set_default_options
effective procedure
{ANY}
Set the default options
ensure
has_unterminated_comment: BOOLEAN
writable attribute
was an unterminated comment sequence (?#... detected
skip_blanks_and_comments
effective procedure
Skips the blanks and comments when the extended legibility option is set.
require ensure
read_character
effective procedure
Goto to the next character that is not a blank or a comment.
require
  • has_no_error: not has_error
  • not_at_end: not end_of_input
ensure
  • next_position: position > old position
  • has_no_error: not has_error
read_integer
effective procedure
Reads in 'last_integer' the current integer values and then goto to the next character that is not a blank or a comment.
require
  • has_no_error: not has_error
  • not_at_end: not end_of_input
  • begin_with_a_digit: last_character.is_decimal_digit
ensure
  • has_no_error: not has_error
  • digits_eaten: end_of_input or else not last_character.is_decimal_digit
emit_repeat (mini: INTEGER_32, maxi: INTEGER_32)
effective procedure
Takes the top of the stack and replace it with a construction that will evaluate the repeating of it from 'mini' to 'maxi' times.
If current character is '?' it means that the repeat is not greedy.
require
  • enough_data: stack.count > 0
  • mini_is_valid: mini >= 0 and then mini /= Repeat_infiny
  • maxi_is_valid: maxi = Repeat_infiny or else maxi >= mini
  • not_droping: mini = 0 implies maxi /= 0
ensure
  • constant_stack_count: stack.count = old stack.count
  • stack_not_empty: stack.count > 0
parse_alternative
effective procedure
Parses an alternative of sequences.
alternative ::= sequence [ '|' sequence ]...
require
  • has_no_error: not has_error
  • not_at_end: not end_of_input
ensure
  • error_or_stack_incremented_by_one: has_error or else stack.count = old stack.count + 1
  • state_known: has_error or else end_of_input or else last_character = ')'
parse_group
effective procedure
Parses a group.
A group is either a POSIX group or an extended pattern group.
require
  • has_no_error: not has_error
  • not_at_end: not end_of_input
  • begin_with_open_parenthesis: last_character = '('
ensure
  • error_or_stack_incremented_by_one: has_error or else stack.count = old stack.count + 1
parse_escaped
effective procedure
Parses an escaped character.
escaped ::= '\' CHARACTER
require
  • has_no_error: not has_error
  • not_at_end: not end_of_input
  • begin_with_escape: last_character = '\'
ensure
  • error_or_stack_incremented_by_one: has_error or else stack.count = old stack.count + 1
parse_union_factor
effective procedure
Parses a union factor.
union_factor::= '[.' TEXT '.]' | '[:' CLASS ':]' | '[:<:]' | '[:>:]' | CHARACTER
require
  • has_no_error: not has_error
  • not_at_end: not end_of_input
internal_parse_escaped (in_union: BOOLEAN)
effective procedure
{}
require
parse_posix_indication
effective procedure
{}
parse_extended_pattern
effective procedure
{}
require
parse_looking (ahead: BOOLEAN)
effective procedure
{}
require
read_modifiers (level: BOOLEAN)
effective procedure
{}
require ensure
internal_parse
effective procedure
Main parse of a POSIX regular expression.
require
  • at_first_position: position = expression.lower
  • stack_is_empty: stack.is_empty
  • no_groups: last_group_count = 0 and group_stack.is_empty
ensure
  • error_or_result: has_error or else stack.count = 1 and group_stack.is_empty
parse_sequence
effective procedure
Parses a sequence of terms.
sequence ::= term [ term ]...
require ensure
parse_term
effective procedure
Parses a term.
term ::= factor [ repeat-spec ] repeat-spec ::= '?' | '*' | '+' | '{' integer [',' [integer]] '}'
require ensure
parse_factor
effective procedure
Parses a factor.
factor ::= group | union | '.' | '^' | '$' | escaped | text
require ensure
parse_text
effective procedure
Parses a text.
text ::= A SEQUENCE NOT FOLLOWED BY EITHER '*', '+', '?', '{' OF NOT ESCAPED CHARACTERS
require ensure
parse_union
effective procedure
Parses a union.
union ::= '[' ['^'] union_term... ']'
require ensure
parse_union_term
effective procedure
Parses a union term.
union_term ::= union_factor ['-' union_factor]
require ensure
read_embedded
effective procedure
Parses the text embedded in one of '[.' TEXT '.]'
,'[:' TEXT ':]' or '[=' TEXT '=]'. The parsed text is put in feature 'last_string'.
require
recorded_character: CHARACTER
writable attribute
Last union_factor's character recorded.
recorded_item: BACKTRACKING_NODE
writable attribute
Last union_factor's item (complex expression) recorded.
set_recorded_character (value: CHARACTER)
effective procedure
Records the union_factor's character 'value'.
ensure
set_recorded_item (value: BACKTRACKING_NODE)
effective procedure
Records the union_factor's item (complex expression) 'value'.
require
  • item_not_void: value /= Void
ensure
emit_recorded
effective procedure
Emits the last union_factor's recorded character or item, depending on its kind.
ensure
  • incremented_by_one: stack.count = old stack.count + 1
make
effective procedure
{ANY}
Initialise the attributes.
is_case_insensitive: BOOLEAN
writable attribute
{ANY}
Is the match case insensitive?
Default is False
is_case_sensitive: BOOLEAN
effective function
{ANY}
Is the match case sensitive?
Default is True
set_case_sensitive
effective procedure
{ANY}
Set the match as case sensitive.
ensure
set_case_insensitive
effective procedure
{ANY}
Set the match as case insensitive.
ensure
does_any_match_newline: BOOLEAN
writable attribute
{ANY}
Does the "any character" mark match a newline?
Default is False
set_any_match_newline
effective procedure
{ANY}
The "any character" mark will match a newline.
ensure
set_any_dont_match_newline
effective procedure
{ANY}
The "any character" mark will not match a newline.
ensure
does_match_line_boundary: BOOLEAN
writable attribute
{ANY}
Does the begin/end marks match line boundary?
Default is False
does_match_text_boundary: BOOLEAN
effective function
{ANY}
Does the begin/end marks match text boundary?
Default is True
ensure
set_match_line_boundary
effective procedure
{ANY}
The begin/end marks will match line boundary.
ensure
set_match_text_boundary
effective procedure
{ANY}
The begin/end marks will match text boundary.
ensure
is_greedy: BOOLEAN
writable attribute
{}
Does match a maximal repeat?
Default is False
set_greedy
effective procedure
{}
Will match a maximal repeat.
ensure
set_not_greedy
effective procedure
{}
Will match a minimal repeat.
ensure
is_looking_ahead: BOOLEAN
writable attribute
{}
Is building a look-ahead term?
is_looking_behind: BOOLEAN
writable attribute
{}
Is building a look-behind term?
is_looking_around: BOOLEAN
effective function
{}
Is building look-ahead or look-behind?
is_looking_positive: BOOLEAN
writable attribute
{}
Is the current look-around positive or negative?
parse_expression (expr: ABSTRACT_STRING)
effective procedure
{ANY}
Set the expression to parse and parse it.
When no error the result if put in feature 'last_regular_expression'. If there is an error, a human readable explanation is retrievable by the feature 'last_error'.
require
  • expression_not_void: expr /= Void
ensure
parse
effective procedure
{ANY}
Parse the current expression.
The result if any is got through 'last_regular_expression'
require ensure
has_result: BOOLEAN
effective function
{ANY}
Did the last 'parse' or 'parse_expression' produced a result in 'last_regular_expression'?
ensure
writable attribute
{ANY}
The last regular expression pattern built by 'parse' or 'parse_expression'
writable attribute
{}
The stack of items.
group_stack: FAST_ARRAY[INTEGER_32]
writable attribute
{}
The stack of groups
last_group_count: INTEGER_32
writable attribute
{}
The count of groups currently found.
once function
{}
The names of the named subgroups
Repeat_infiny: INTEGER_32
is -1
constant attribute
{}
Constant that means "infinite repetition".
emit (item: BACKTRACKING_NODE)
effective procedure
{}
Pushes 'item' on the stack.
 [..] -> [.., item]
require
  • item_not_void: item /= Void
ensure
  • stack_count_increased_by_one: stack.count = old stack.count + 1
  • stack_not_empty: stack.count > 0
effective function
{}
Pops the Result from the stack.
 [... Result] -> [...]
require
  • stack_not_empty: stack.count > 0
ensure
  • stack_count_decreased_by_one: stack.count = old stack.count - 1
emit_any_character
effective procedure
{}
Push the match to any characters
emit_begin_of_line
effective procedure
{}
Push the match to begin of a line
emit_end_of_line
effective procedure
{}
Push the match to end of a line
prepare_group
effective procedure
{}
Declares that a new group begins.
ensure
emit_group
effective procedure
{}
Push the "end of group" item and update the group indicators
 [.. X] -> [.., end_group(i)]
require ensure
emit_begin_group
effective procedure
{}
Push the "begin of group" item and update the group indicators
 [..]
This feature is obsolete: Use `declare_group'/`emit_group' instead (February 2006).
emit_end_group
effective procedure
{}
Push the "end of group" item and update the group indicators
 [..]
This feature is obsolete: Use `declare_group'/`emit_group' instead (February 2006).
emit_match_previous_group (group: INTEGER_32)
effective procedure
{}
Push the item that matches the character 'char'
 [..]
-> [.., previous_group(group)]
require ensure
  • stack_count_increased_by_one: stack.count = old stack.count + 1
  • stack_not_empty: stack.count > 0
emit_match_single (char: CHARACTER)
effective procedure
{}
Push the item that matches the character 'char'
 [..]
-> [.., char]
ensure
  • stack_count_increased_by_one: stack.count = old stack.count + 1
  • stack_not_empty: stack.count > 0
emit_match_range (lower: CHARACTER, upper: CHARACTER)
effective procedure
{}
Push the item that matches the character range 'lower'..'
upper'.
 [..] -> [.., lower..upper]
require
  • valid_range: lower <= upper
ensure
  • stack_count_increased_by_one: stack.count = old stack.count + 1
  • stack_not_empty: stack.count > 0
emit_match_text (text: STRING)
effective procedure
{}
Push the item that matches the 'text'
 [..]
-> [.., text]
ensure
  • stack_count_increased_by_one: stack.count = old stack.count + 1
  • stack_not_empty: stack.count > 0
begin_collect
effective procedure
{}
Begin to collect a collection of items by pushing Void on the stack.
After calling 'begin_collect', one of the features 'end_collect_or' or 'end_collect_and' have to be called. That kind of group is intended to manage the collections of alternatives or sequences in an optimal way.
 [..] -> [.., Void]
ensure
  • has_collect: stack.fast_occurrences(Void) > 0
  • emit_group_empty: stack.last = Void
  • emit_group_count_incremented: stack.fast_occurrences(Void) = old stack.fast_occurrences(Void) + 1
is_collect_empty: BOOLEAN
effective function
{}
True if currently begun collect is empty
require
  • is_collecting: stack.fast_occurrences(Void) > 0
ensure
  • definition: Result = stack.last = Void
end_collect_true
effective procedure
{}
Replace an empty collection by TRUE
 [.., Void] -> [.., TRUE]
require
end_collect_or
effective procedure
{}
Collects the item on the stack until the collect mark (a Void) and replace it by a single item that is a or of all of them.
The collection must not be empty. The order of evaluation will remain. The binary or's tree is recursive on right for efficiency.
 [.., Void, X] -> [.., X]
 [.., Void, Y, X] -> [.., Y or X]
 [.., Void, Z, Y, X] -> [.., Z or (Y or X)]
 ...
require ensure
  • stack_not_empty: stack.count > 0
  • emit_group_count_decremented: stack.fast_occurrences(Void) = old stack.fast_occurrences(Void) - 1
effective function
{}
end_collect_and
effective procedure
{}
Collects the item on the stack until the collect mark (a Void) and replace it by a single item that is a and of all of them.
The collection must not be empty. The order of evaluation will remain. The binary and's tree is recursive on right for efficiency.
 [.., Void, X] -> [.., X]
 [.., Void, Y, X] -> [.., Y and X]
 [.., Void, Z, Y, X] -> [.., Z and (Y and X)]
 ...
require ensure
  • stack_not_empty: stack.count > 0
  • emit_group_count_decremented: stack.fast_occurrences(Void) = old stack.fast_occurrences(Void) - 1
emit_not
effective procedure
{}
Replaces the top of the stack by its negation.
 [.., X] -> [.., not(X)]
(where not(X) is like (X and (CUT and FALSE)) or TRUE)
require
  • enough_data: stack.count > 0
ensure
  • constant_stack_count: stack.count = old stack.count
  • stack_not_empty: stack.count > 0
emit_not_then_any
effective procedure
{}
Replaces the top of the stack by its negation followed by any.
 [.., X] -> [.., not(X)]
(where not(X) is like (X and (CUT and FALSE)) or ANY)
require
  • enough_data: stack.count > 0
ensure
  • constant_stack_count: stack.count = old stack.count
  • stack_not_empty: stack.count > 0
emit_true_or
effective procedure
{}
Replaces the top of the stack by true or it
 [.., X] -> [.., true or X]
require
  • enough_data: stack.count > 0
ensure
  • constant_stack_count: stack.count = old stack.count
  • stack_not_empty: stack.count > 0
emit_or_true
effective procedure
{}
Replaces the top of the stack by it or true
 [.., X] -> [.., X or true]
require
  • enough_data: stack.count > 0
ensure
  • constant_stack_count: stack.count = old stack.count
  • stack_not_empty: stack.count > 0
emit_controled_or_true
effective procedure
{}
Replaces the top of the stack by
 if is_greedy then [.., X] -> [.., X or true]
              else [.., X] -> [.., true or X]
controled_or_true_item (x: BACKTRACKING_NODE): BACKTRACKING_NODE
effective function
{}
Returns an item for " 'x' or true ". The returned item depend on the flag 'is_greedy'.
 if is_greedy then Result = (X or true)
              else Result = (true or X)
emit_looking
effective procedure
{}
require ensure
  • constant_stack_count: stack.count = old stack.count
  • stack_not_empty: stack.count > 0
scanned_string: ABSTRACT_STRING
writable attribute
{ANY}
The expression being currently build.
set_scanned_string (string: ABSTRACT_STRING)
effective procedure
{ANY}
Set the 'scanned_string' with 'string'.
ensure
has_error: BOOLEAN
writable attribute
{ANY}
True when an error was encountered
clear_error
effective procedure
{ANY}
Remove the error flag
ensure
last_error: STRING
effective function
{ANY}
Returns a string recorded for the error.
require ensure
  • not_void: Result /= Void
set_error (message: STRING)
effective procedure
{ANY}
Set has_error and last_error.
The explaining error string 'last_error' is created as follow: "Error at position 'position': 'message'.".
require
  • message_not_void: message /= Void
  • has_no_error: not has_error
ensure
position: INTEGER_32
writable attribute
{ANY}
The scanned position.
It is the position of 'last_character'.
last_character: CHARACTER
writable attribute
{ANY}
The scanned character.
The last character read from 'scanned_string'.
valid_last_character: BOOLEAN
writable attribute
{ANY}
True when 'last_character' is valid.
Is like 'scanned_string.valid_index(position)'
valid_previous_character: BOOLEAN
effective function
{ANY}
True if the position-1 is a valid position.
require ensure
previous_character: CHARACTER
effective function
{ANY}
The character at position-1.
require ensure
valid_next_character: BOOLEAN
effective function
{ANY}
True if the position+1 is a valid position.
require ensure
next_character: CHARACTER
effective function
{ANY}
The character at position+1.
require ensure
end_of_input: BOOLEAN
effective function
{ANY}
True when all the characters of 'scanned_string' are scanned.
ensure
goto_position (pos: INTEGER_32)
effective procedure
{ANY}
Change the currently scanned position to 'pos'.
Updates 'last_character' and 'valid_last_character' to reflect the new position value.
require ensure
saved_position: INTEGER_32
writable attribute
{ANY}
The saved position (only one is currently enough).
save_position
effective procedure
{ANY}
Saves the current scanning position.
require ensure
restore_saved_position
effective procedure
{ANY}
Restore the scanning position to the last saved one.
ensure
last_string: STRING
writable attribute
{ANY}
A string buffer.
last_integer: INTEGER_32
writable attribute
{ANY}
An integer buffer.
the_any_character_item: REGULAR_EXPRESSION_ITEM_ANY
once function
{ANY}
the_not_end_of_line_item: REGULAR_EXPRESSION_ITEM_NOT_END_OF_LINE
once function
{ANY}
the_begin_of_line_item: REGULAR_EXPRESSION_ITEM_BEGIN_OF_LINE
once function
{ANY}
once function
{ANY}
the_begin_of_text_item: REGULAR_EXPRESSION_ITEM_BEGIN_OF_TEXT
once function
{ANY}
the_real_end_of_text_item: REGULAR_EXPRESSION_ITEM_END_OF_TEXT
once function
{ANY}
once function
{ANY}
the_begin_of_word_item: REGULAR_EXPRESSION_ITEM_BEGIN_OF_WORD
once function
{ANY}
once function
{ANY}
the_is_posix_alnum_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_ALNUM
once function
{ANY}
the_is_posix_alpha_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_ALPHA
once function
{ANY}
the_is_posix_ascii_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_ASCII
once function
{ANY}
the_is_posix_blank_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_BLANK
once function
{ANY}
the_is_posix_cntrl_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_CNTRL
once function
{ANY}
the_is_posix_digit_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_DIGIT
once function
{ANY}
the_is_posix_graph_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_GRAPH
once function
{ANY}
the_is_posix_lower_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_LOWER
once function
{ANY}
the_is_posix_print_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_PRINT
once function
{ANY}
the_is_posix_punct_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_PUNCT
once function
{ANY}
the_is_posix_space_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_SPACE
once function
{ANY}
the_is_posix_upper_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_UPPER
once function
{ANY}
the_is_posix_word_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_WORD
once function
{ANY}
the_is_posix_xdigit_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_XDIGIT
once function
{ANY}
has_named_posix_item (name: STRING): BOOLEAN
effective function
{ANY}
True if 'name' is for a valid POSIX character class
require
  • name_not_void: name /= Void
named_posix_item (name: STRING): REGULAR_EXPRESSION_ITEM
effective function
{ANY}
the item for the valid POSIX character class 'name'
require ensure
  • good_result: Result /= Void
has_named_perl_item (name: STRING): BOOLEAN
effective function
{ANY}
True if 'name' is for a valid Perl character class
require
  • name_not_void: name /= Void
named_perl_item (name: STRING): REGULAR_EXPRESSION_ITEM
effective function
{ANY}
the item for the valid Perl character class 'name'
require ensure
  • good_result: Result /= Void
internal_named_posix_item (name: STRING): REGULAR_EXPRESSION_ITEM
effective function
{}
the item for a presumed POSIX character class 'name'
require
  • name_not_void: name /= Void
internal_named_perl_item (name: STRING): REGULAR_EXPRESSION_ITEM
effective function
{}
the item for a presumed Perl character class 'name'
require
  • name_not_void: name /= Void
the_cut_node: BACKTRACKING_NODE_CUT
once function
{ANY}
the_true_node: BACKTRACKING_NODE_TRUE
once function
{ANY}
the_false_node: BACKTRACKING_NODE_FALSE
once function
{ANY}
the_cut_and_false_node: BACKTRACKING_NODE_CUT_AND_FALSE
once function
{ANY}