C# Class Nexus.Client.Util.Antlr.AntlrLexerBase

The base lexer for ANTRL lexers.
This extends the generated lexer in order to make error handling sane, and to make the errors friendlier.
Inheritance: Antlr.Runtime.Lexer
Exibir arquivo Open project: NexusMods/NexusModManager-4.5

Public Methods

Method Description
AntlrLexerBase ( ) : System

The default constructor.

AntlrLexerBase ( ICharStream input, Antlr.Runtime.RecognizerSharedState state ) : System

A simple constructor.

DisplayRecognitionError ( String tokenNames, RecognitionException e ) : void

Logs the given error to the ErrorTracker.

GetErrorMessage ( RecognitionException e, string tokenNames ) : string

Generates a human-readable error message for the given error.

NextToken ( ) : IToken

This reads the next token from the input.

If there is a lexing error, this method inserts an error token containing the bad input, and continues lexing.

ReportError ( RecognitionException e ) : void

Reports the given error.

This ensures that the error is thrown so that our NextToken() override can handle it.

Method Details

AntlrLexerBase() public method

The default constructor.
public AntlrLexerBase ( ) : System
return System

AntlrLexerBase() public method

A simple constructor.
public AntlrLexerBase ( ICharStream input, Antlr.Runtime.RecognizerSharedState state ) : System
input ICharStream The code to lex.
state Antlr.Runtime.RecognizerSharedState The to use.
return System

DisplayRecognitionError() public method

Logs the given error to the ErrorTracker.
public DisplayRecognitionError ( String tokenNames, RecognitionException e ) : void
tokenNames String The names of the tokens in the current language.
e Antlr.Runtime.RecognitionException The error.
return void

GetErrorMessage() public method

Generates a human-readable error message for the given error.
public GetErrorMessage ( RecognitionException e, string tokenNames ) : string
e Antlr.Runtime.RecognitionException The error.
tokenNames string The names of the tokens in the current language.
return string

NextToken() public method

This reads the next token from the input.
If there is a lexing error, this method inserts an error token containing the bad input, and continues lexing.
public NextToken ( ) : IToken
return IToken

ReportError() public method

Reports the given error.
This ensures that the error is thrown so that our NextToken() override can handle it.
public ReportError ( RecognitionException e ) : void
e Antlr.Runtime.RecognitionException The error.
return void