Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.3 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

PerCederberg.Grammatica.Parser
Class LookAheadSet.Sequence

System.Object
   |
   +--LookAheadSet.Sequence

   in LookAheadSet.cs

class LookAheadSet.Sequence
extends System.Object

A token sequence. This class contains a list of token ids. It is immutable after creation, meaning that no changes will be made to an instance after creation.


Constructor Summary
Sequence()
          Creates a new empty token sequence.
Sequence( bool repeat, int token )
          Creates a new token sequence with a single token.
Sequence( int length, Sequence seq )
          Creates a new token sequence that is a duplicate of another sequence.
Sequence( bool repeat, Sequence seq )
          Creates a new token sequence that is a duplicate of another sequence.
 
Method Summary
 Sequence Concat( int length, Sequence seq )
          Creates a new token sequence that is the concatenation of this sequence and another.
 override bool Equals( object obj )
          Checks if this sequence is equal to another object.
 bool Equals( Sequence seq )
          Checks if this sequence is equal to another sequence.
 object GetToken( int pos )
          Returns a token at a specified position in the sequence.
 bool IsNext( Parser parser )
          Checks if the next token(s) in the parser matches this token sequence.
 bool IsNext( Parser parser, int length )
          Checks if the next token(s) in the parser matches this token sequence.
 bool IsRepetitive()
          Checks if this token sequence is repetitive.
 int Length()
          Returns the length of the token sequence.
 bool StartsWith( Sequence seq )
          Checks if this token sequence starts with the tokens from another sequence.
 Sequence Subsequence( int start )
          Creates a new token sequence that is a subsequence of this one.
 override string ToString()
          Returns a string representation of this object.
 string ToString( Tokenizer tokenizer )
          Returns a string representation of this object.
 

Constructor Detail

Sequence

public Sequence();
Creates a new empty token sequence. The repeat flag will be set to false.

Sequence

public Sequence( bool repeat, int token );
Creates a new token sequence with a single token.
Parameters:
repeat - the repeat flag value
token - the token to add

Sequence

public Sequence( int length, Sequence seq );
Creates a new token sequence that is a duplicate of another sequence. Only a limited number of tokens will be copied however. The repeat flag from the original will be kept intact.
Parameters:
length - the maximum number of tokens to copy
seq - the sequence to copy

Sequence

public Sequence( bool repeat, Sequence seq );
Creates a new token sequence that is a duplicate of another sequence. The new value of the repeat flag will be used however.
Parameters:
repeat - the new repeat flag value
seq - the sequence to copy


Method Detail

Concat

public Sequence Concat( int length, Sequence seq );
Creates a new token sequence that is the concatenation of this sequence and another. A maximum length for the new sequence is also specified.
Parameters:
length - the maximum length of the result
seq - the other sequence
Returns:
the concatenated token sequence

Equals

public override bool Equals( object obj );
Checks if this sequence is equal to another object. Only token sequences with the same tokens in the same order will be considered equal. The repeat flag will be disregarded.
Parameters:
obj - the object to compare with
Returns:
true if the objects are equal, or false otherwise

Equals

public bool Equals( Sequence seq );
Checks if this sequence is equal to another sequence. Only sequences with the same tokens in the same order will be considered equal. The repeat flag will be disregarded.
Parameters:
seq - the sequence to compare with
Returns:
true if the sequences are equal, or false otherwise

GetToken

public object GetToken( int pos );
Returns a token at a specified position in the sequence.
Parameters:
pos - the sequence position
Returns:
the token id found, or null

IsNext

public bool IsNext( Parser parser );
Checks if the next token(s) in the parser matches this token sequence.
Parameters:
parser - the parser to check
Returns:
true if the next tokens are in the sequence, or false otherwise

IsNext

public bool IsNext( Parser parser, int length );
Checks if the next token(s) in the parser matches this token sequence.
Parameters:
parser - the parser to check
length - the maximum number of tokens to check
Returns:
true if the next tokens are in the sequence, or false otherwise

IsRepetitive

public bool IsRepetitive();
Checks if this token sequence is repetitive. A repetitive token sequence is one with the repeat flag set.
Returns:
true if this token sequence is repetitive, or false otherwise

Length

public int Length();
Returns the length of the token sequence.
Returns:
the number of tokens in the sequence

StartsWith

public bool StartsWith( Sequence seq );
Checks if this token sequence starts with the tokens from another sequence. If the other sequence is longer than this sequence, this method will always return false.
Parameters:
seq - the token sequence to check
Returns:
true if this sequence starts with the other, or false otherwise

Subsequence

public Sequence Subsequence( int start );
Creates a new token sequence that is a subsequence of this one.
Parameters:
start - the subsequence start position
Returns:
the new token subsequence

ToString

public override string ToString();
Returns a string representation of this object.
Returns:
a string representation of this object

ToString

public string ToString( Tokenizer tokenizer );
Returns a string representation of this object.
Parameters:
tokenizer - the tokenizer containing the tokens
Returns:
a string representation of this object

 Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.3 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD