Table of Contents

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
object
BalancedRule
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

tokenType TokenType
prefix string
open char
close char
innerTokenizer Func<string, IReadOnlyList<Token>>
priority int
maxDepth 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 balanced block at the specified position.

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

Parameters

input string
position int
context TokenizerContext

Returns

TokenMatch?