StringSearch:SubstringBF

Import List

    Object
    Object
    RT0
    StringSearch
 
Class List
FactoryThis class implements a brute-force substring matcher.
MatchObject
Matcher
Class Summary: Factory [Detail]
  +---RT0.Object
       |
       +---Object.Object
            |
            +---StringSearch.Factory
                 |
                 +--StringSearch:SubstringBF.Factory

This class implements a brute-force substring matcher. With a pattern length of M and a string length of N, a substring search can require up to O(N*M) operations.

Constructor Summary
InitFactory(Factory)

          
Method Summary
Compile(String8, Flags): Matcher

          Compile a expression, for example a regular expression pattern, into a Matcher expression object.
Inherited Methods

From RT0.Object:

          Finalize

From Object.Object:

          Equals, HashCode, ToString

From StringSearch.Factory:

          Compile, Destroy

 
Class Summary: MatchObject [Detail]
  +---RT0.Object
       |
       +---Object.Object
            |
            +---StringSearch.MatchObject
                 |
                 +--StringSearch:SubstringBF.MatchObject
Inherited Fields

From StringSearch.MatchObject:

          endpos, matcher, pos, string

Constructor Summary
InitMatchObject(MatchObject, LONGINT, LONGINT, Matcher, String8, LONGINT, LONGINT)

          
Method Summary
End(LONGINT): LONGINT

          Returns the index of the end of the substring matched by group.
Start(LONGINT): LONGINT

          Returns the index of the start of the substring matched by group.
Inherited Methods

From RT0.Object:

          Finalize

From Object.Object:

          Equals, HashCode, ToString

From StringSearch.MatchObject:

          Destroy, End, Start

 
Class Summary: Matcher [Detail]
  +---RT0.Object
       |
       +---Object.Object
            |
            +---StringSearch.Matcher
                 |
                 +--StringSearch:SubstringBF.Matcher
Inherited Fields

From StringSearch.Matcher:

          flags, groups, pattern

Constructor Summary
InitMatcher(Matcher, String8, Flags, LONGINT)

          
Method Summary
Match(String8, LONGINT, LONGINT): MatchObject

          Like Matcher.MatchChars, but works on an instance of Object.String8.
MatchChars(ARRAY OF CHAR, LONGINT, LONGINT): MatchObject

          Returns a corresponding MatchObject instance, if zero or more characters at the beginning of string match this Matcher.
Search(String8, LONGINT, LONGINT): MatchObject

          Like Matcher.SearchChars, but works on an instance of Object.String8.
SearchChars(ARRAY OF CHAR, LONGINT, LONGINT): MatchObject

          Scans through string looking for a location where this Matcher produces a match, and return a corresponding MatchObject instance.
Inherited Methods

From RT0.Object:

          Finalize

From Object.Object:

          Equals, HashCode, ToString

From StringSearch.Matcher:

          Destroy, Match, MatchChars, Search, SearchChars

 
Variable Summary
factory-: Factory

          
Constant Summary
copyString

          See StringSearch.copyString.
ignoreCase

          See StringSearch.ignoreCase.

Class Detail: Factory
Constructor Detail

InitFactory

PROCEDURE InitFactory(f: Factory)
Method Detail

Compile

PROCEDURE (f: Factory) Compile(pattern: String8; 
                  flags: Flags): Matcher

Compile a expression, for example a regular expression pattern, into a Matcher expression object. The matcher object can be used for matching using its Matcher.MatchChars and Matcher.SearchChars methods.

The pattern's behaviour can be modified by specifying a flags value. The set can include of the following variables: ignoreCase, copyString.

Result is NIL if the given pattern is invalid.

Pre-condition: The value of pattern does not contain the character 0X.

[Description inherited from Compile]

Redefines: Compile

 
Class Detail: MatchObject
Constructor Detail

InitMatchObject

PROCEDURE InitMatchObject(m: MatchObject; 
                          pos: LONGINT; 
                          endpos: LONGINT; 
                          matcher: Matcher; 
                          string: String8; 
                          start: LONGINT; 
                          end: LONGINT)
Method Detail

End

PROCEDURE (m: MatchObject) End(group: LONGINT): LONGINT

Returns the index of the end of the substring matched by group. See MatchObject.Start.

[Description inherited from End]

Redefines: End


Start

PROCEDURE (m: MatchObject) Start(group: LONGINT): LONGINT

Returns the index of the start of the substring matched by group. A group of `0' refers to the whole matched substring. Returns `-1' if the group exists but did not contribute to the match. For a match object m, and a group g that did contribute to the match, the substring matched by group g is `string[m.Start(g), m.End(g)['. Note that `m.Start(g)' will equal `m.End(g)' if g matched a null string.

Note: Not all matcher implementations implement groups other than the whole match.

Pre-condition: `0 <= group <= m.matcher.groups'

[Description inherited from Start]

Redefines: Start

 
Class Detail: Matcher
Constructor Detail

InitMatcher

PROCEDURE InitMatcher(matcher: Matcher; 
                      pattern: String8; 
                      flags: Flags; 
                      groups: LONGINT)
Method Detail

Match

PROCEDURE (matcher: Matcher) Match(string: String8; 
                pos: LONGINT; 
                endpos: LONGINT): MatchObject

Like Matcher.MatchChars, but works on an instance of Object.String8.

[Description inherited from Match]

Redefines: Match


MatchChars

PROCEDURE (matcher: Matcher) MatchChars(string: ARRAY OF CHAR; 
                     pos: LONGINT; 
                     endpos: LONGINT): MatchObject

Returns a corresponding MatchObject instance, if zero or more characters at the beginning of string match this Matcher. Returns NIL if the string does not match the pattern. Note that this is different from a zero-length match.

Note: If you want to locate a match anywhere in string, use Matcher.Search instead.

The second parameter pos gives an index in the string where the search is to start, for example 0 to start at the beginning of the string.

The parameter endpos limits how far the string will be searched. It will be as if the string is endpos characters long, so only the characters in `[pos, endpos[' will be searched for a match. A value of `-1' is equivalent to an endpos of `Length(string)'.

Pre-condition: The start position is within the string `0 <= pos <= Length(string)', and the given end position is either `-1', or between the start position and the end of the string `pos <= endpos <= Length(string)'.

[Description inherited from MatchChars]

Redefines: MatchChars


Search

PROCEDURE (matcher: Matcher) Search(string: String8; 
                 pos: LONGINT; 
                 endpos: LONGINT): MatchObject

Like Matcher.SearchChars, but works on an instance of Object.String8.

[Description inherited from Search]

Redefines: Search


SearchChars

PROCEDURE (matcher: Matcher) SearchChars(string: ARRAY OF CHAR; 
                      pos: LONGINT; 
                      endpos: LONGINT): MatchObject

Scans through string looking for a location where this Matcher produces a match, and return a corresponding MatchObject instance. Returns NIL if no position in the string matches the pattern. Note that this is different from finding a zero-length match at some point in the string.

The pos and endpos parameters have the same meaning as for the Matcher.MatchChars method.

[Description inherited from SearchChars]

Redefines: SearchChars

 
Variable Detail

factory

VAR factory-: Factory
Constant Detail

copyString

CONST copyString 

See StringSearch.copyString.


ignoreCase

CONST ignoreCase 

See StringSearch.ignoreCase.