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 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.\n
DefaultLexicalState
The root ILexicalState for when the language is entered.
Key
A string that identifies the lexer, generally the related language name.
LexicalMacros
The collection of lexical macros.
public IDynamicLexicalMacroCollection LexicalMacros { get; }
Property Value
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
LexicalStates
The collection of lexical states.
public IDynamicLexicalStateCollection LexicalStates { get; }
Property Value
TokenIdProvider
The ITokenIdProvider that provides access to all the token IDs and keys used by this lexer.
Methods
GetAllLexicalStateTransitions()
Returns a collection containing all ILexicalStateTransition objects within the lexer.
public override IEnumerable<ILexicalStateTransition>? GetAllLexicalStateTransitions()
Returns
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
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
OnChanged(EventArgs)
Raises the OnChanged(EventArgs) event.
protected override void OnChanged(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
Inherited Members
- MergeableLexerBase.CreateChangeBatch()
- MergeableLexerBase.CreateDocumentEndToken(int, TextPosition, ILexicalState)
- MergeableLexerBase.CreateToken(int, int, TextPosition, TextPosition, MergeableLexerFlags, ILexicalState, IMergeableTokenLexerData)
- MergeableLexerBase.GetIncrementalParseRange(TextSnapshotRange)
- MergeableLexerBase.Parse(TextSnapshotRange, ILexerTarget)
- MergeableLexerBase.DefaultLexicalStateCore
- MergeableLexerBase.KeyCore
- MergeableLexerBase.LexicalStateIdProviderCore
- MergeableLexerBase.TokenIdProviderCore
- MergeableLexerBase.Changed
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()