Table of Contents

Class ContextualKeywordRule

Namespace
BlazOrbit.SyntaxHighlight.Rules
Assembly
BlazOrbit.SyntaxHighlight.dll

Matches keywords only when a context predicate is satisfied.

public sealed class ContextualKeywordRule : ITokenRule
Inheritance
object
ContextualKeywordRule
Implements

Constructors

ContextualKeywordRule(TokenType, IEnumerable<string>, Func<string, int, bool>, int)

Initializes a new instance of the ContextualKeywordRule class.

public ContextualKeywordRule(TokenType tokenType, IEnumerable<string> keywords, Func<string, int, bool> contextPredicate, int priority = 0)

Parameters

tokenType TokenType
keywords IEnumerable<string>
contextPredicate Func<string, int, bool>
priority int

Properties

Priority

Gets the priority of this rule. Higher values are evaluated first.

public int Priority { get; }

Property Value

int

Methods

TryMatch(string, int, TokenizerContext)

Attempts to match a contextual keyword at the specified position.

public TokenMatch? TryMatch(string input, int position, TokenizerContext context)

Parameters

input string
position int
context TokenizerContext

Returns

TokenMatch?