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
-
objectContextualKeywordRule
- 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
tokenTypeTokenTypekeywordsIEnumerable<string>contextPredicateFunc<string, int, bool>priorityint
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
inputstringpositionintcontextTokenizerContext