C# Class Antlr4.Runtime.CommonTokenFactory

This default implementation of ITokenFactory creates CommonToken objects.
Inheritance: ITokenFactory
Show file Open project: antlr/antlr4

Public Properties

Property Type Description
Default ITokenFactory

Protected Properties

Property Type Description
copyText bool

Public Methods

Method Description
CommonTokenFactory ( ) : System

Constructs a CommonTokenFactory with copyText set to .

The Default instance should be used instead of calling this directly.

CommonTokenFactory ( bool copyText ) : System

Constructs a CommonTokenFactory with the specified value for copyText .

When copyText is , the Default instance should be used instead of constructing a new instance.

Create ( ICharStream>.Tuple source, int type, string text, int channel, int start, int stop, int line, int charPositionInLine ) : CommonToken
Create ( int type, string text ) : CommonToken

Private Methods

Method Description
ITokenFactory ( ICharStream>.Tuple source, int type, string text, int channel, int start, int stop, int line, int charPositionInLine ) : IToken
ITokenFactory ( int type, string text ) : IToken

Method Details

CommonTokenFactory() public method

Constructs a CommonTokenFactory with copyText set to .

The Default instance should be used instead of calling this directly.

public CommonTokenFactory ( ) : System
return System

CommonTokenFactory() public method

Constructs a CommonTokenFactory with the specified value for copyText .

When copyText is , the Default instance should be used instead of constructing a new instance.

public CommonTokenFactory ( bool copyText ) : System
copyText bool /// The value for /// /// . ///
return System

Create() public method

public Create ( ICharStream>.Tuple source, int type, string text, int channel, int start, int stop, int line, int charPositionInLine ) : CommonToken
source ICharStream>.Tuple
type int
text string
channel int
start int
stop int
line int
charPositionInLine int
return CommonToken

Create() public method

public Create ( int type, string text ) : CommonToken
type int
text string
return CommonToken

Property Details

Default public static property

The default CommonTokenFactory instance.

This token factory does not explicitly copy token text when constructing tokens.

public static ITokenFactory Default
return ITokenFactory

copyText protected property

Indicates whether CommonToken.Text should be called after constructing tokens to explicitly set the text. This is useful for cases where the input stream might not be able to provide arbitrary substrings of text from the input after the lexer creates a token (e.g. the implementation of ICharStream.GetText(Antlr4.Runtime.Misc.Interval) in UnbufferedCharStream throws an System.NotSupportedException ). Explicitly setting the token text allows IToken.Text() to be called at any time regardless of the input stream implementation.

The default value is to avoid the performance and memory overhead of copying text for every token unless explicitly requested.

protected bool copyText
return bool