# StringSearch:RegexpParser

### Import List

        Object
        Object
        StringSearch

Class List
Builder | Factory for nodes of the abstract syntax tree.
Expr | Represents a sequence of terms like ``a`', ``[a]`', or ``a*`'.
Factor |
Group | Represents list of alternatives, separated by ``|`'.
Term | An atomic factor, optionally followed by a quantifier.

Class Summary: Builder [Detail]

      +--StringSearch:RegexpParser.Builder

Factory for nodes of the abstract syntax tree.

Constructor Summary
InitBuilder(Builder)
NewBuilder(): Builder
Method Summary
NewExpr(): Expr
NewFactor(FactorType): Factor
NewGroup(GroupId): Group
NewTerm(): Term

Class Summary: Expr [Detail]

      +--StringSearch:RegexpParser.Expr

Represents a sequence of terms like ``a`', ``[a]`', or ``a*`'.

Field Summary
next-: Expr Links elements of Group.exprList.
termList-: Term Sequence of terms within the expression.
Constructor Summary
InitExpr(Expr)

Class Summary: Factor [Detail]

      +--StringSearch:RegexpParser.Factor

Field Summary
char-: CHAR For a character match, this field holds the expected character.
charSet-: CharSet For a character set match, this field refers to a set of characters.
group-: Group For a parenthised group, this field refers to the nested group.
type-: FactorType Determines how the factor is matched against input.
Constructor Summary
InitFactor(Factor, FactorType)

Class Summary: Group [Detail]

      +--StringSearch:RegexpParser.Group

Represents list of alternatives, separated by ``|`'.

Field Summary
exprList-: Expr List of alternatives within this group.
groupId-: GroupId Identifier for this group.
Constructor Summary
InitGroup(Group, GroupId)
Parse(Builder, String8, Flags): Group Parses the regular expression in pattern, modified by the options passed in flags.

Class Summary: Term [Detail]

      +--StringSearch:RegexpParser.Term

An atomic factor, optionally followed by a quantifier.

Field Summary
factor-: Factor The base expression of the term.
next-: Term Links elements of Expr.termList.
quantifier-: QuantifierType Specifies how often factor must match for the term to be considered a successful match.
Constructor Summary
InitTerm(Term)

Type Summary
CharSet = POINTER TO ARRAY n OF SET
FactorType = SHORTINT
GroupId = SHORTINT
QuantifierType = SHORTINT One of exactlyOnce, zeroOrOnceGreedy, zeroOrMoreGreedy, or onceOrMoreGreedy.

Procedure Summary
UpperLower(CHAR, VAR CHAR, VAR CHAR)

Constant Summary
backslash
exactlyOnce The expression must match exactly once.
matchAfterLastChar
matchAnyButNewline
matchAtFirstChar
matchChar
matchCharIgnoreCase
matchGroup
matchSet
matchSetInverted
onceOrMoreGreedy The expression must match one or more times.
sizeCHAR
sizeSET
zeroOrMoreGreedy The expression must match zero or more times.
zeroOrOnceGreedy The expression can match at most once, and the longest match wins.

Class Detail: Builder

Constructor Detail

### InitBuilder

    PROCEDURE InitBuilder(b: Builder)

### NewBuilder

    PROCEDURE NewBuilder(): Builder

Method Detail

### NewExpr

    PROCEDURE (b: Builder) NewExpr(): Expr

### NewFactor

    PROCEDURE (b: Builder) NewFactor(type: FactorType): Factor

### NewGroup

    PROCEDURE (b: Builder) NewGroup(groupId: GroupId): Group

### NewTerm

    PROCEDURE (b: Builder) NewTerm(): Term

Class Detail: Expr

Field Detail

### next

    FIELD next-: Expr

> Links elements of Group.exprList.

### termList

    FIELD termList-: Term

> Sequence of terms within the expression. List is linked by Term.next. Note: This list may be empty, which happens for expressions like ```', ``()`', ``(a|)`', and so on.

Constructor Detail

### InitExpr

    PROCEDURE InitExpr(expr: Expr)

Class Detail: Factor

Field Detail

### char

    FIELD char-: CHAR

> For a character match, this field holds the expected character. Otherwise, it is 0X.

### charSet

    FIELD charSet-: CharSet

> For a character set match, this field refers to a set of characters. Otherwise, it is NIL.

### group

    FIELD group-: Group

> For a parenthised group, this field refers to the nested group. Otherwise, it is NIL.

### type

    FIELD type-: FactorType

> Determines how the factor is matched against input.

Constructor Detail

### InitFactor

    PROCEDURE InitFactor(factor: Factor;
                         type: FactorType)

Class Detail: Group

Field Detail

### exprList

    FIELD exprList-: Expr

> List of alternatives within this group. List is linked by Expr.next.

### groupId

    FIELD groupId-: GroupId

> Identifier for this group. The group that represents the whole regular expression has an id of ``0`'. The ids of nested groups is derived by counting opening parenthesis before it. The first ``(`' in the expression gets the id ``1`', the second ``2`', and so on.

Constructor Detail

### InitGroup

    PROCEDURE InitGroup(group: Group;
                        groupId: GroupId)

### Parse

    PROCEDURE Parse(b: Builder;
                    pattern: String8;
                    flags: Flags): Group

> Parses the regular expression in pattern, modified by the options passed in flags.

> Result is an abstract syntax tree of the regular expression on success, and NIL on failure. The nodes of the AST a constructed from instances created through the builder object b.

> For a short description of regular expression syntax, see StringSearch:RegexpDFA.

Class Detail: Term

Field Detail

### factor

    FIELD factor-: Factor

> The base expression of the term.

### next

    FIELD next-: Term

> Links elements of Expr.termList.

### quantifier

    FIELD quantifier-: QuantifierType

> Specifies how often factor must match for the term to be considered a successful match.

Constructor Detail

### InitTerm

    PROCEDURE InitTerm(term: Term)

Type Detail

### CharSet

    TYPE CharSet = POINTER TO ARRAY n OF SET

### FactorType

    TYPE FactorType = SHORTINT

### GroupId

    TYPE GroupId = SHORTINT

### QuantifierType

    TYPE QuantifierType = SHORTINT

> One of exactlyOnce, zeroOrOnceGreedy, zeroOrMoreGreedy, or onceOrMoreGreedy.

Procedure Detail

### UpperLower

    PROCEDURE UpperLower(ch: CHAR;
                         VAR upper: CHAR;
                         VAR lower: CHAR)

Constant Detail

### backslash

    CONST backslash

### exactlyOnce

    CONST exactlyOnce

> The expression must match exactly once. Example: ``a`'.

### matchAfterLastChar

    CONST matchAfterLastChar

### matchAnyButNewline

    CONST matchAnyButNewline

### matchAtFirstChar

    CONST matchAtFirstChar

### matchChar

    CONST matchChar

### matchCharIgnoreCase

    CONST matchCharIgnoreCase

### matchGroup

    CONST matchGroup

### matchSet

    CONST matchSet

### matchSetInverted

    CONST matchSetInverted

### onceOrMoreGreedy

    CONST onceOrMoreGreedy

> The expression must match one or more times. The longest match wins. Example: ``a+`'.

### sizeCHAR

    CONST sizeCHAR

### sizeSET

    CONST sizeSET

### zeroOrMoreGreedy

    CONST zeroOrMoreGreedy

> The expression must match zero or more times. The longest match wins. Example: ``a*`'.

### zeroOrOnceGreedy

    CONST zeroOrOnceGreedy

> The expression can match at most once, and the longest match wins. Example: ``a?`'.