C# Class Antlr4.Runtime.UnbufferedCharStream

Do not buffer up the entire char stream.
Do not buffer up the entire char stream. It does keep a small buffer for efficiency and also buffers while a mark exists (set by the lookahead prediction in parser). "Unbuffered" here refers to fact that it doesn't buffer all data, not that's it's on demand loading of char.
Inheritance: ICharStream
Afficher le fichier Open project: sharwell/antlr4cs

Méthodes publiques

Свойство Type Description
name string

Protected Properties

Свойство Type Description
currentCharIndex int
data char[]
input System.IO.TextReader
lastChar int
lastCharBufferStart int
n int
numMarkers int
p int

Méthodes publiques

Méthode Description
Consume ( ) : void
GetText ( Interval interval ) : string
La ( int i ) : int
Mark ( ) : int

Return a marker that we can release later.

Return a marker that we can release later.

The specific marker value used for this class allows for some level of protection against misuse where seek() is called on a mark or release() is called in the wrong order.

Release ( int marker ) : void

Decrement number of markers, resetting buffer if we hit 0.

Seek ( int index ) : void

Seek to absolute character index, which might not be in the current sliding window.

Seek to absolute character index, which might not be in the current sliding window. Move p to index-bufferStartIndex .

UnbufferedCharStream ( ) : System

Useful for subclasses that pull char from other than this.input.

UnbufferedCharStream ( Stream input ) : System
UnbufferedCharStream ( Stream input, int bufferSize ) : System
UnbufferedCharStream ( TextReader input ) : System
UnbufferedCharStream ( TextReader input, int bufferSize ) : System
UnbufferedCharStream ( int bufferSize ) : System

Useful for subclasses that pull char from other than this.input.

Méthodes protégées

Méthode Description
Add ( int c ) : void
Fill ( int n ) : int

Add n characters to the buffer. Returns the number of characters actually added to the buffer. If the return value is less than n , then EOF was reached before n characters could be added.

NextChar ( ) : int

Override to provide different source of characters than input .

Sync ( int want ) : void

Make sure we have 'need' elements from current position p . Last valid p index is data.length-1 . p+need-1 is the char index 'need' elements ahead. If we need 1 element, (p+1-1)==p must be less than data.length .

Method Details

Add() protected méthode

protected Add ( int c ) : void
c int
Résultat void

Consume() public méthode

public Consume ( ) : void
Résultat void

Fill() protected méthode

Add n characters to the buffer. Returns the number of characters actually added to the buffer. If the return value is less than n , then EOF was reached before n characters could be added.
protected Fill ( int n ) : int
n int
Résultat int

GetText() public méthode

public GetText ( Interval interval ) : string
interval Antlr4.Runtime.Misc.Interval
Résultat string

La() public méthode

public La ( int i ) : int
i int
Résultat int

Mark() public méthode

Return a marker that we can release later.
Return a marker that we can release later.

The specific marker value used for this class allows for some level of protection against misuse where seek() is called on a mark or release() is called in the wrong order.

public Mark ( ) : int
Résultat int

NextChar() protected méthode

Override to provide different source of characters than input .
protected NextChar ( ) : int
Résultat int

Release() public méthode

Decrement number of markers, resetting buffer if we hit 0.
public Release ( int marker ) : void
marker int
Résultat void

Seek() public méthode

Seek to absolute character index, which might not be in the current sliding window.
Seek to absolute character index, which might not be in the current sliding window. Move p to index-bufferStartIndex .
public Seek ( int index ) : void
index int
Résultat void

Sync() protected méthode

Make sure we have 'need' elements from current position p . Last valid p index is data.length-1 . p+need-1 is the char index 'need' elements ahead. If we need 1 element, (p+1-1)==p must be less than data.length .
protected Sync ( int want ) : void
want int
Résultat void

UnbufferedCharStream() public méthode

Useful for subclasses that pull char from other than this.input.
public UnbufferedCharStream ( ) : System
Résultat System

UnbufferedCharStream() public méthode

public UnbufferedCharStream ( Stream input ) : System
input Stream
Résultat System

UnbufferedCharStream() public méthode

public UnbufferedCharStream ( Stream input, int bufferSize ) : System
input Stream
bufferSize int
Résultat System

UnbufferedCharStream() public méthode

public UnbufferedCharStream ( TextReader input ) : System
input System.IO.TextReader
Résultat System

UnbufferedCharStream() public méthode

public UnbufferedCharStream ( TextReader input, int bufferSize ) : System
input System.IO.TextReader
bufferSize int
Résultat System

UnbufferedCharStream() public méthode

Useful for subclasses that pull char from other than this.input.
public UnbufferedCharStream ( int bufferSize ) : System
bufferSize int
Résultat System

Property Details

currentCharIndex protected_oe property

Absolute character index.
Absolute character index. It's the index of the character about to be read via LA(1) . Goes from 0 to the number of characters in the entire stream, although the stream size is unknown before the end is reached.
protected int currentCharIndex
Résultat int

data protected_oe property

A moving window buffer of the data being scanned.
A moving window buffer of the data being scanned. While there's a marker, we keep adding to buffer. Otherwise, consume() resets so we start filling at index 0 again.
protected char[] data
Résultat char[]

input protected_oe property

protected TextReader,System.IO input
Résultat System.IO.TextReader

lastChar protected_oe property

This is the LA(-1) character for the current position.
protected int lastChar
Résultat int

lastCharBufferStart protected_oe property

When numMarkers > 0 , this is the LA(-1) character for the first character in data . Otherwise, this is unspecified.
protected int lastCharBufferStart
Résultat int

n protected_oe property

The number of characters currently in data .

This is not the buffer capacity, that's data.length .

protected int n
Résultat int

name public_oe property

The name or source of this char stream.
public string name
Résultat string

numMarkers protected_oe property

Count up with mark() and down with release() . When we release() the last mark, numMarkers reaches 0 and we reset the buffer. Copy data[p]..data[n-1] to data[0]..data[(n-1)-p] .
protected int numMarkers
Résultat int

p protected_oe property

0..n-1 index into data of next character.

The LA(1) character is data[p] . If p == n , we are out of buffered characters.

protected int p
Résultat int