TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

interface IGrammarRuleProxy in Tinman.Core.Parsing

interface IGrammarRuleProxy extends IGrammarRule

Attributes

Flags

The grammar rule flags.

property Flags { get }
type GrammarRuleFlags
value The rule flags.
inherited IGrammarRule.Flags

Grammar

The Grammar object that has defined this rule.

property Grammar { get }
type Grammar
value [not-null] The grammar.
inherited IGrammarRule.Grammar

IsTerminal

Is this a terminal rule?

property IsTerminal { get }
type bool
value true if this rule is terminal, false if it is not.
inherited IRule.IsTerminal

Remarks:

A terminal rule performs flat matching of the input characters, without any further rule recursion.

MatchPrefix

Returns the common prefix string that this rule always matches.

property MatchPrefix { get }
type string
value The simple match prefix or null.
inherited IRule.MatchPrefix

Precedence

Returns the precedence of this rule.

property Precedence { get }
type RulePrecedence
value The rule precedence.
inherited IRule.Precedence

Rule

The body of this grammar rule.

property Rule { get }
type IRule
value The body rule.
inherited IGrammarRule.Rule

RuleName

The name of this rule.

property RuleName { get }
type string
value [not-null] The rule name.
inherited IGrammarRule.RuleName

Methods

Add

Appends the given rule to this one.

[Pure]
method Add (IRule rule)
type IRule
params rule [not-null] The rule to append.
returns [not-null] The resulting rule.
inherited IRule.Add

Ast

Returns a rule that creates an AST node upon match.

[Pure]
method Ast (string tokenType)
type IRule
params tokenType [not-null] The token type.
returns [not-null] The resulting rule.
inherited IRule.Ast

AstIfLeft

Creates an AST node from this rule and the given one if this rule is matched.

[Pure]
method AstIfLeft (IRule rule, string tokenType)
type IRule
params rule [not-null] The other rule.
  tokenType [not-empty] The token type.
returns [not-null] The resulting rule.
inherited IRule.AstIfLeft

AstIfRight

Creates an AST node from this rule and the given one if the latter rule is matched.

[Pure]
method AstIfRight (IRule rule, string tokenType)
type IRule
params rule [not-null] The other rule.
  tokenType [not-empty] The token type.
returns [not-null] The resulting rule.
inherited IRule.AstIfRight

CollectReferencedRules

Collects all IGrammarRule s that are referenced by this rule resp. any of its descendants.

method CollectReferencedRules (ICollector<IRule> rules, bool collectThis = true)
params rules [not-null] The collector for referenced grammar rules.
  collectThis true to collect this rule if it is a grammar rule, false to collect only descendant grammar rules. Defaults to true.
inherited IRule.CollectReferencedRules

Count

Determines the number of AST nodes this rule may produce.

[Pure]
method Count (IBag<IRule> rules)
type AstCount
params rules [not-null] Set of rules being processed. Used to avoid left recursion.
returns The AST node count flags.
inherited IRule.Count

Except

Returns a rule that matches the input only iff this rule matches but the given exception rule does not.

[Pure]
method Except (IRule exception)
type IRule
params exception [not-null] The exception rule.
returns [not-null] The resulting rule.
inherited IRule.Except

List

Returns a rule that matches a non-empty list of elements (matched by this rule) that are delimited by the given rule.

[Pure]
method List (IRule delimiter)
type IRule
params delimiter [not-null] The delimiter rule.
returns [not-null] The resulting rule.
inherited IRule.List

Many

Returns a rule that matches this rule n times, where n lies in the range [minOccurs..maxOccurs].

[Pure]
method Many (int32 minOccurs, int32 maxOccurs)
type IRule
params minOccurs [>=0] Minimum number of allowed occurrences.
  maxOccurs [>=minOccurs] Maximum number of allowed occurrences.
returns [not-null] The resulting rule.
inherited IRule.Many

Match

Tries to match the given character.

method Match (char c)
type bool
params c The character token to match.
returns true if the rule has successfully matched the input token, false if the rule could not be matched.
inherited IRule.Match

Remarks:

This method is useful for matching single token rules.


Tries to match the given input tokens.

method Match (ParserContext context, bool allowEmpty = true)
type bool
params context [not-null] The parser context object to use.
  allowEmpty Allow the rule to match zero tokens? Defaults to true.
returns true if the rule has successfully matched all input tokens, false if the rule could not be matched.
inherited IRule.Match

Remarks:

When this method returns false, the state of the given parser context will have remained unchanged.

Name

Creates a named grammar rule from this rule.

method Name (string name, GrammarRuleFlags flags = GrammarRuleFlags.None, Grammar grammar = null)
type IGrammarRule
params name [not-empty] The rule name.
  flags The grammar rule flags. Defaults to None.
  grammar The grammar object the rule belongs to or null,
returns [not-null] The resulting rule.
inherited IRule.Name

See also:

Grammar.GetRule

Not

Returns a rule that matches an when this rule does not, and vice-versa.

[Pure]
method Not ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.Not

OneOrMore

Returns a rule that matches this rule one or more times.

[Pure]
method OneOrMore ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.OneOrMore

Or

Returns a rule that matches either this rule or the given one.

[Pure]
method Or (IRule rule)
type IRule
params rule [not-null] The rule.
returns [not-null] The resulting rule.
inherited IRule.Or

SetProxyTarget

method SetProxyTarget (IRule rule, GrammarRuleFlags flags = GrammarRuleFlags.None)
params rule
  flags

ToGrammarAst

Transforms this rule into a AST grammar rule (according to GrammarAst).

[Pure]
method ToGrammarAst ()
type IRule
returns The AST grammar rule or null if this rule does not generate any AST nodes.
inherited IRule.ToGrammarAst

ToSource

Returns the string representation of this rule.

[Pure]
method ToSource (StringBuilder sb, RuleToSourceFlags flags, RulePrecedence outer = RulePrecedence.Lowest)
params sb [not-null] The string builder to use.
  flags The format flags to use.
  outer The outer rule precedence.
returns [not-null] The string representation.
inherited IRule.ToSource

Remarks:

The string representation will be wrapped in braces if necessary regarding to the outer rule precedence.

Trim

Returns a rule that skips all whitespaces before and after matching this rule.

[Pure]
method Trim ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.Trim

TrimLeft

Returns a rule that skips all whitespaces before matching this rule.

[Pure]
method TrimLeft ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.TrimLeft

TrimRight

Returns a rule that skips all whitespaces after matching this rule.

[Pure]
method TrimRight ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.TrimRight

ZeroOrMore

Returns a rule that matches this rule zero or more times.

[Pure]
method ZeroOrMore ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.ZeroOrMore

ZeroOrOne

Returns a rule that matches this rule zero times or one time.

[Pure]
method ZeroOrOne ()
type IRule
returns [not-null] The resulting rule.
inherited IRule.ZeroOrOne