+
Point of view
All features
deferred class BACKTRACKING_REGULAR_EXPRESSION_BUILDER
Summary
The frame class of all the regular expression builders.
Direct parents
Insert list: REGULAR_EXPRESSION_ITEM_GLOBALS, REGULAR_EXPRESSION_STRING_SCANNER
Known children
Inherit list: POSIX_REGULAR_EXPRESSION_BUILDER
Class invariant
Overview
Features
make
{ANY}
  • make
    Initialise the attributes.
behaviors
{ANY}
internal behavior
{}
parsing
{ANY}
results
{ANY}
{}
  • internal_parse
    The parse function to be implemented by the effective builders.
build
{}
basic
{ANY}
error management
{ANY}
scanning
{ANY}
assertions
{ANY}
character classes
{ANY}
character class naming
{ANY}
{}
and/or basics
{ANY}
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
set_default_options
effective procedure
{ANY}
Set the default options
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'
internal_parse
deferred procedure
{}
The parse function to be implemented by the effective builders.
require ensure
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_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.
The feature boolean 'is_greedy' controls if the matched repeat will be of minimal length or of maximal length. That feature is reset to its default (False) value.
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
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
read_character
effective procedure
{ANY}
Reads the next character.
require ensure
read_integer
effective procedure
{ANY}
Reads an integer value beginning at the currently scanned position.
The read value is stored in 'last_integer'.
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}