Table of Contents

Class SingleRuleApplication

Namespace
NMF.AnyText.Rules
Assembly
NMF.AnyText.Core.dll

Denotes a type of rule application that includes zero or one inner rule applications

public class SingleRuleApplication : RuleApplication
Inheritance
SingleRuleApplication
Derived
Inherited Members

Constructors

SingleRuleApplication(Rule, RuleApplication, ParsePositionDelta, ParsePositionDelta)

Creates a new rule application

public SingleRuleApplication(Rule rule, RuleApplication inner, ParsePositionDelta length, ParsePositionDelta examinedTo)

Parameters

rule Rule

the rule that the rule application references

inner RuleApplication

the inner rule application, if any

length ParsePositionDelta

the length of the rule application

examinedTo ParsePositionDelta

a length until which the text was examined to conclude this rule application

Properties

Children

Gets the child rule applications

public override IEnumerable<RuleApplication> Children { get; }

Property Value

IEnumerable<RuleApplication>

Inner

Gets the inner rule application

public RuleApplication Inner { get; }

Property Value

RuleApplication

PotentialError

Denotes a potential error to improve error reporting

public override RuleApplication PotentialError { get; }

Property Value

RuleApplication

SemanticElement

Gets the semantic element of the rule application

public override object SemanticElement { get; }

Property Value

object

Methods

Activate(ParseContext, bool)

Activates the rule application, i.e. marks it as part of the current parse tree

public override void Activate(ParseContext context, bool initial)

Parameters

context ParseContext

the context in which the parse tree exists

initial bool

flag to indicate whether the activation is part of the initial parse

AddParseErrors(ParseContext)

Gets a collection of parse errors represented by this rule application

public override void AddParseErrors(ParseContext context)

Parameters

context ParseContext

the parse context in which the parse errors are requested

ApplyTo(RuleApplication, ParseContext)

Applies the structure of the current rule application to the given other rule application

public override RuleApplication ApplyTo(RuleApplication other, ParseContext context)

Parameters

other RuleApplication

the rule application to which the rule should be applied

context ParseContext

the parse context

Returns

RuleApplication

the merged rule application

ContinueToNextToken(RuleApplication, PrettyPrintWriter, ParseContext)

Writes white spaces until the next token

public override bool ContinueToNextToken(RuleApplication childRuleApplication, PrettyPrintWriter writer, ParseContext context)

Parameters

childRuleApplication RuleApplication

the child rule application that was written last

writer PrettyPrintWriter

the pretty print writer to write to

context ParseContext

the parse context

Returns

bool

true, if a token was produced, otherwise false

Deactivate(ParseContext)

Deactivates the rule application, i.e. unmarks it as part of the parse tree

public override void Deactivate(ParseContext context)

Parameters

context ParseContext

the context in which the parse tree exists

FindChildAt(ParsePosition, Rule)

Gets the child rule application at the given position

public override RuleApplication FindChildAt(ParsePosition position, Rule rule)

Parameters

position ParsePosition

The position

rule Rule

The expected rule of the child

Returns

RuleApplication

The child at the given position or null

GetFirstInnerLiteral()

Calculates the first literal within this rule application

public override LiteralRuleApplication GetFirstInnerLiteral()

Returns

LiteralRuleApplication

the first literal rule application or null

GetLastInnerLiteral()

Calculates the last literal within this rule application

public override LiteralRuleApplication GetLastInnerLiteral()

Returns

LiteralRuleApplication

the last literal rule application or null

GetLiteralAt(ParsePosition, bool)

Gets the literal at the given position

public override RuleApplication GetLiteralAt(ParsePosition position, bool onlyActive = false)

Parameters

position ParsePosition

the position

onlyActive bool

whether to only return an active rule application (default: false)

Returns

RuleApplication

the literal rule application or null, if there is no literal there

GetValue(ParseContext)

Gets the parsed newPosition under the given context

public override object GetValue(ParseContext context)

Parameters

context ParseContext

the parse context

Returns

object

the parsed newPosition

IterateLiterals(Action<LiteralRuleApplication>, ParsePosition, ParsePosition, bool)

Iterate over all literals

public override void IterateLiterals(Action<LiteralRuleApplication> action, ParsePosition from, ParsePosition to, bool includeFailures)

Parameters

action Action<LiteralRuleApplication>

the action that should be performed for all literals

from ParsePosition

the inclusive position from which the literals should be iterated

to ParsePosition

the inclusive position to which the literals should be iterated

includeFailures bool

true, if failed rule applications should be considered, otherwise false

IterateLiterals(Action<LiteralRuleApplication>, bool)

Iterate over all literals

public override void IterateLiterals(Action<LiteralRuleApplication> action, bool includeFailures)

Parameters

action Action<LiteralRuleApplication>

the action that should be performed for all literals

includeFailures bool

true, if failed rule applications should be considered, otherwise false

IterateLiterals(Func<LiteralRuleApplication, bool>, ParsePosition, bool)

Iterate over all literals

public override bool IterateLiterals(Func<LiteralRuleApplication, bool> action, ParsePosition from, bool includeFailures)

Parameters

action Func<LiteralRuleApplication, bool>

the action that should be performed for all literals

from ParsePosition

the inclusive position from which the literals should be iterated

includeFailures bool

true, if failed rule applications should be considered, otherwise false

Returns

bool

IterateLiterals(Func<LiteralRuleApplication, bool>, bool)

Iterate over all literals

public override bool IterateLiterals(Func<LiteralRuleApplication, bool> action, bool includeFailures)

Parameters

action Func<LiteralRuleApplication, bool>

the action that should be performed for all literals

includeFailures bool

true, if failed rule applications should be considered, otherwise false

Returns

bool

IterateLiterals<T>(Action<LiteralRuleApplication, T>, T, bool)

Iterate over all literals

public override void IterateLiterals<T>(Action<LiteralRuleApplication, T> action, T parameter, bool includeFailures)

Parameters

action Action<LiteralRuleApplication, T>

the action that should be performed for all literals

parameter T

the parameter

includeFailures bool

true, if failed rule applications should be considered, otherwise false

Type Parameters

T

the parameter type

OnContextChange(object, object, ParseContext)

Gets called when the context of this rule application changes

protected override void OnContextChange(object oldContext, object newContext, ParseContext context)

Parameters

oldContext object

the old context element

newContext object

the new context element

context ParseContext

the parse context

OnMigrate(RuleApplication, RuleApplication, ParseContext)

protected virtual void OnMigrate(RuleApplication oldValue, RuleApplication newValue, ParseContext context)

Parameters

oldValue RuleApplication
newValue RuleApplication
context ParseContext

ReplaceChild(RuleApplication, RuleApplication, ParseContext)

Replaces the given child rule application with the given new child

public override void ReplaceChild(RuleApplication childApplication, RuleApplication newChild, ParseContext context)

Parameters

childApplication RuleApplication

the child rule application

newChild RuleApplication

a new child

context ParseContext

the context in which the child is replaced

Validate(ParseContext)

Validates the rule semantically

public override void Validate(ParseContext context)

Parameters

context ParseContext

the parse context in which the rule is validated

Write(PrettyPrintWriter, ParseContext)

Writes the given rule application to the provided text writer

public override void Write(PrettyPrintWriter writer, ParseContext context)

Parameters

writer PrettyPrintWriter

the writer to which the rule application should be written

context ParseContext

the parse context