Rule

Description

abstract class Tinman.Core.Parsing.Rule

Derived from

IRule

Abstract base class for IRule implementations.

Public / Constructors

Add


public static method Add → (2)

first in : IRule

First rule or null.

second in : IRule

Second rule or null.

returns → IRule

The resulting rule or null.

Combines the given rules with IRule.Add while ignoring null values.

Or


public static method Or → (2)

first in : IRule

First rule or null.

second in : IRule

Second rule or null.

returns → IRule

The resulting rule or null.

Combines the given rules with IRule.Or while ignoring null values.

Public / Methods

Name​Proxy


public static method NameProxy → (2)

name in : string

[not-empty]
The grammar rule name.

grammar opt : Grammar = null

The grammar object the rule belongs to or null,

returns → IGrammarRuleProxy

The rule.

Returns an empty grammar rule that can be used by other rules.

At some later point, the proxy must be set by calling IGrammarRuleProxy.SetProxyTarget.

See also

Grammar.GetRule2

None​Of

2 overloads


public static method NoneOf1 → (1)

chars in : string

[not-empty]
The characters.

returns → IRule

The rule.

Returns a rule that matches all characters except the given ones.


public static method NoneOf2 → (1)

chars in : IBagConst<char>

[not-empty]
The characters.

returns → IRule

The rule.

Returns a rule that matches all characters except the given ones.

One​Of

2 overloads


public static method OneOf1 → (1)

chars in : string

[not-empty]
The characters.

returns → IRule

The rule.

Returns a rule that matches one of the given characters.


public static method OneOf2 → (1)

chars in : IBagConst<char>

[not-empty]
The characters.

returns → IRule

The rule.

Returns a rule that matches one of the given characters.

Range


public static method Range → (2)

from in : char

First character of range, inclusive.

to in : char

[>=from]
Last character of range, inclusive.

returns → IRule

The rule.

Returns a rule that matches one character in the given range.

To​Char​Set


public static method ToCharSet → (2)

in : string

The input string.

chars in : IBag<char>

The set to use or null.

returns → IBag<char>

The set of characters.

Returns a set that contains all the characters found in the given string.

Token

2 overloads


public static method Token1 → (2)

token in : string

[not-empty]
The string token.

caseSensitive opt : bool = true

Perform case-sensitive match for the token?

returns → IRule

The rule.

Returns a rule that matches the given string token.


public static method Token2 → (1)

token in : char

The character token.

returns → IRule

The rule.

Returns a rule that matches the given character token.

Wrap

6 overloads


public static method Wrap1 → (2)

rule in : IRule

[not-null]
The rule to wrap.

startEnd in : char

The start/end tag.

returns → IRule

The rule.

Wraps the given rule in the specified start and end tags.


public static method Wrap2 → (3)

rule in : IRule

[not-null]
The rule to wrap.

start in : char

The start tag.

end in : char

The end tag.

returns → IRule

The rule.

Wraps the given rule in the specified start and end tags.


public static method Wrap3 → (2)

rule in : IRule

[not-null]
The rule to wrap.

startEnd in : string

[not-empty]
The start/end tag.

returns → IRule

The rule.

Wraps the given rule in the specified start and end tags.


public static method Wrap4 → (3)

rule in : IRule

[not-null]
The rule to wrap.

start in : string

[not-empty]
The start tag.

end in : string

[not-empty]
The end tag.

returns → IRule

The rule.

Wraps the given rule in the specified start and end tags.


public static method Wrap5 → (2)

rule in : IRule

[not-null]
The rule to wrap.

startEnd in : IRule

[not-null]
The start/end tag.

returns → IRule

The rule.

Wraps the given rule in the specified start and end tags.


public static method Wrap6 → (3)

rule in : IRule

[not-null]
The rule to wrap.

start in : IRule

[not-null]
The start tag.

end in : IRule

[not-null]
The end tag.

returns → IRule

The rule.

Wraps the given rule in the specified start and end tags.

Protected / Constructors

Rule


protected constructor Rule → ()

Creates a new instance of Rule.

Protected / Methods

Begin​Match


protected abstract method BeginMatch → (1)

context in : ParserContext

The parser context to use.

returns → bool

true if this rule has matched the input,
false if the rule is mismatching.

Begins to match this rule.

After processing the match result, EndMatch must be called.

Do​Count


protected virtual method DoCount → (1)

rules in : IBag<IRule>

The set of visited rules, to avoid infinite recursion.

returns → AstCount

The computed AstCount value.

Computes the AST count for this rule.

End​Match


protected virtual method EndMatch → (1)

context in : ParserContext

The parser context to use.

End to match this rule.

To​Source​Internal


protected abstract method ToSourceInternal → (3)

sb in : StringBuilder

The output buffer to use.

flags in : RuleToSourceFlags

The output flags to use.

outer opt : RulePrecedence = ParsingUtil.PrecedenceMin

The precedence of the enclosing rule.

Called from IRule.ToSource to generate the source code for this rule.