Enhanced C#
Language of your choice: library documentation
Loyc.Syntax.BaseParserForList< Token, MatchType, List > Class Template Reference

An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator) and receive tokens from any IEnumerator<Token>. (Potentially also useful for parsers written by hand.) More...


Source file:
Inheritance diagram for Loyc.Syntax.BaseParserForList< Token, MatchType, List >:
Loyc.Syntax.ParserSource< Token >

Remarks

An base class designed for parsers that use LLLPG (Loyc LL(k) Parser Generator) and receive tokens from any IEnumerator<Token>. (Potentially also useful for parsers written by hand.)

The compiler will ensure that you use this base class correctly. All you have to do is call the base class constructor and override the abstract method ToString(MatchType).

This version of BaseParserForList has List (a token list) as a generic parameter. Compared to using IList{Token} directly, this can increase performance in case the List is a value type (e.g. InternalList<Token>).

Template Parameters
TokenData type of complete tokens in the token list. A token contains the type of a "word" in the program (string, identifier, plus sign, etc.), a value (e.g. the name of an identifier), and a range of characters in the source file. See ISimpleToken<MatchType>. Note: Token is usually a small struct; this class assumes that it will never be null.
MatchTypeA data type, usually int, that represents a token type (identifier, operator, etc.) and implements IEquatable<T> so it can be compared for equality with other token types; this is also the type of the ISimpleToken<Matchtype>.Type property. Unfortunately, MatchType cannot be an enum because, strangely, an enum does not implement IEquatable<T>. So if your token type is an enum, as it usually is, set this to int and use matchType: int when you invoke LLLPG: LLLPG(parser(matchType: int, laType: TokenEnum));.
ListData type of the list that contains the tokens (one often uses IList{Token}, but one could use Loyc.Collections.Impl.InternalList<T> for potentially higher performance.)
Type Constraints
Token :ISimpleToken<MatchType> 
MatchType :IEquatable<MatchType> 
List :IList<Token>