Table of Contents

Class LiteralRule

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

Denotes a rule that matches a constant text

public class LiteralRule : Rule
Inheritance
LiteralRule
Inherited Members

Constructors

LiteralRule(string)

Creates a new instance

public LiteralRule(string literal)

Parameters

literal string

the literal that should be matched

Properties

IsLiteral

True, if the rule contributes characters, otherwise false

public override bool IsLiteral { get; }

Property Value

bool

Literal

Gets the literal that should be matched

public string Literal { get; }

Property Value

string

TokenType

Gets the token type of tokens created for this rule

public override string TokenType { get; }

Property Value

string

Methods

CanStartWith(Rule, List<Rule>)

Indicates whether the rule could start with the given other rule

protected override bool CanStartWith(Rule rule, List<Rule> trace)

Parameters

rule Rule

the other rule

trace List<Rule>

a list of rules visited so far

Returns

bool

true, if the rule could start with the given other rule, otherwise false

CanSynthesize(object, ParseContext, SynthesisPlan)

Determines whether the current rule can synthesize rule applications for the given semantic element

public override bool CanSynthesize(object semanticElement, ParseContext context, SynthesisPlan synthesisPlan)

Parameters

semanticElement object

the semantic element

context ParseContext

the context in which the rule is synthesized

synthesisPlan SynthesisPlan

the plan of the synthesis

Returns

bool

true, if a rule application can be synthesized, otherwise false

IsEpsilonAllowed(List<Rule>)

Determines whether the rule could capture empty input

protected override bool IsEpsilonAllowed(List<Rule> trace)

Parameters

trace List<Rule>

Returns

bool

true, if the rule can be expanded to an empty string, otherwise false

Match(ParseContext, RecursionContext, ref ParsePosition)

Matches the the context at the provided position

public override RuleApplication Match(ParseContext context, RecursionContext recursionContext, ref ParsePosition position)

Parameters

context ParseContext

the context in which the rule is matched

recursionContext RecursionContext

the recursion context of the matching

position ParsePosition

the position in the input

Returns

RuleApplication

the rule application for the provided position

SuggestCompletions(ParseContext, RuleApplication, string, ParsePosition)

Suggests useful code completions

public override IEnumerable<CompletionEntry> SuggestCompletions(ParseContext context, RuleApplication ruleApplication, string fragment, ParsePosition position)

Parameters

context ParseContext
ruleApplication RuleApplication
fragment string
position ParsePosition

Returns

IEnumerable<CompletionEntry>

Synthesize(object, ParsePosition, ParseContext)

Synthesizes a rule application for the given semantic element

public override RuleApplication Synthesize(object semanticElement, ParsePosition position, ParseContext context)

Parameters

semanticElement object
position ParsePosition

the parse position at which the element should be synthesized

context ParseContext

the parse context

Returns

RuleApplication

a rule application

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.