In This Article

PythonLexer Class

Represents a Python lexer (lexical analyzer) implementation.

public class PythonLexer : MergableLexerBase, IMergableLexer, ILexer, IKeyedObject
Inheritance:
object MergableLexerBase object
Implements:
IMergableLexer ILexer IKeyedObject

Constructors

PythonLexer()

Initializes a new instance of the PythonLexer class.

public PythonLexer()

Properties

LexicalStates

Gets the collection of lexical states used by this lexer.

public ILexicalStateCollection LexicalStates { get; }

Property Value

ILexicalStateCollection:

The collection of lexical states used by this lexer.

Methods

GetAllLexicalStateTransitions()

Returns a collection containing all ILexicalStateTransition objects within the lexer.

public override IEnumerable<ILexicalStateTransition> GetAllLexicalStateTransitions()

Returns

IEnumerable<ILexicalStateTransition>:

A collection containing all ILexicalStateTransition objects within the lexer.

Remarks

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

GetNextToken(ITextBufferReader, ILexicalState)

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

public override MergableLexerResult 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

MergableLexerResult:

A MergableLexerResult indicating the lexer result.

IsIdentifierPartCharacter(char)

Returns whether the specified character is an identifier part character.

public static bool IsIdentifierPartCharacter(char ch)
Parameter Type Description
ch char

The character to examine.

Returns

bool:

true if the specified character is an identifier part character; otherwise, false.

IsIdentifierStartCharacter(char)

Returns whether the specified character is an identifier start character.

public static bool IsIdentifierStartCharacter(char ch)
Parameter Type Description
ch char

The character to examine.

Returns

bool:

true if the specified character is an identifier start character; otherwise, false.

IsValidIdentifier(string)

Returns whether the specified text is a valid identifier.

public static bool IsValidIdentifier(string text)
Parameter Type Description
text string

The text to examine.

Returns

bool:

true if the specified text is a valid identifier; otherwise, false.

Inherited Members