In This Article

DynamicLexer Class

Represents a dynamic lexer (lexical analyzer), one that is pattern-based.

public class DynamicLexer : MergeableLexerBase, IDynamicLexer, IMergeableLexer, ILexer, IKeyedObject
Inheritance:
object MergeableLexerBase object
Derived:
XmlLexer
Implements:
IDynamicLexer IMergeableLexer ILexer IKeyedObject

Remarks

Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(object, object) method. Once an instance is registered with the language for the ILexer interface type, its features can be used by the language.

Constructors

DynamicLexer()

Initializes an instance of the class.

public DynamicLexer()

Properties

CanLineFeedMatchAnyLineTerminator

Whether a line feed ('\n') character in regex patterns should match any line terminator, not just LF-only characters.

public bool CanLineFeedMatchAnyLineTerminator { get; set; }

Property Value

bool:

The default value is true.

Remarks

This property simplifies regex patterns by replacing '\n' usage in two scenarios. First, a \n in a character class will add all other line terminators characters to the character class. Second, a \n outside of a character class will match any valid line terminator sequence.

DefaultLexicalState

The root ILexicalState for when the language is entered.

public DynamicLexicalState? DefaultLexicalState { get; set; }

Property Value

DynamicLexicalState

Key

A string that identifies the lexer, generally the related language name.

public string Key { get; set; }

Property Value

string

LexicalMacros

The collection of lexical macros.

public IDynamicLexicalMacroCollection LexicalMacros { get; }

Property Value

IDynamicLexicalMacroCollection

LexicalStateIdProvider

The ILexicalStateIdProvider that provides access to all the lexical state IDs and keys used by this lexer.

public ILexicalStateIdProvider? LexicalStateIdProvider { get; set; }

Property Value

ILexicalStateIdProvider

LexicalStates

The collection of lexical states.

public IDynamicLexicalStateCollection LexicalStates { get; }

Property Value

IDynamicLexicalStateCollection

TokenIdProvider

The ITokenIdProvider that provides access to all the token IDs and keys used by this lexer.

public ITokenIdProvider? TokenIdProvider { get; set; }

Property Value

ITokenIdProvider

Methods

GetAllLexicalStateTransitions()

Returns a collection containing all ILexicalStateTransition objects within the lexer.

public override IEnumerable<ILexicalStateTransition>? GetAllLexicalStateTransitions()

Returns

IEnumerable<ILexicalStateTransition>

Remarks

This method allows consumers to see which language transitions can be made within the lexer.

GetDefaultToken(ITextBufferReader, ILexicalState)

Returns a single-character MergeableLexerResult representing the lexer result for the default token in the ILexicalState and seeks forward one position in the ITextBufferReader

public override MergeableLexerResult GetDefaultToken(ITextBufferReader reader, ILexicalState lexicalState)
Parameter Type Description
reader ITextBufferReader

An ITextBufferReader that is reading a text source.

lexicalState ILexicalState

The ILexicalState that specifies the current state.

Returns

MergeableLexerResult

GetNextToken(ITextBufferReader, ILexicalState)

Performs a lex to return the next MergeableLexerResult from a ITextBufferReader and seeks past it if there is a match.

public override MergeableLexerResult GetNextToken(ITextBufferReader reader, ILexicalState lexicalState)
Parameter Type Description
reader ITextBufferReader

An ITextBufferReader that is reading a text source.

lexicalState ILexicalState

The ILexicalState that specifies the current state.

Returns

MergeableLexerResult

OnChanged(EventArgs)

Raises the OnChanged(EventArgs) event.

protected override void OnChanged(EventArgs e)
Parameter Type Description
e EventArgs

The event data.

Inherited Members

Extension Methods