Class BalancedRule
- Namespace
- BlazOrbit.SyntaxHighlight.Rules
- Assembly
- BlazOrbit.SyntaxHighlight.dll
Matches balanced delimited blocks (e.g., braces) with optional nested tokenization.
public sealed class BalancedRule : ITokenRule
- Inheritance
-
objectBalancedRule
- Implements
Constructors
BalancedRule(TokenType, string, char, char, Func<string, IReadOnlyList<Token>>?, int, int)
Initializes a new instance of the BalancedRule class.
public BalancedRule(TokenType tokenType, string prefix, char open, char close, Func<string, IReadOnlyList<Token>>? innerTokenizer = null, int priority = 0, int maxDepth = 100)
Parameters
tokenTypeTokenTypeprefixstringopencharclosecharinnerTokenizerFunc<string, IReadOnlyList<Token>>priorityintmaxDepthint
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 balanced block at the specified position.
public TokenMatch? TryMatch(string input, int position, TokenizerContext context)
Parameters
inputstringpositionintcontextTokenizerContext