Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public Types | Public fields | Public static fields | Properties | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected static fields | List of all members
Loyc.LLParserGenerator.PGIntSet Class Reference

Represents a set of characters (e.g. 'A'..'Z' | 'a'..'z' | '_'), or a set of integers, used in the grammar of a parser. More...


Source file:
Inheritance diagram for Loyc.LLParserGenerator.PGIntSet:
Loyc.LLParserGenerator.IntSet Loyc.LLParserGenerator.IPGTerminalSet

Remarks

Represents a set of characters (e.g. 'A'..'Z' | 'a'..'z' | '_'), or a set of integers, used in the grammar of a parser.

This class extends IntSet to implement IPGTerminalSet, used by LLParserGenerator. It also contains a a couple of code generation helper methods.

-1 is assumed to represent EOF.

Public Types

enum  Match { Singles, Ranges, Set }
 

Public fields

const int EOF_int = -1
 
- Public fields inherited from Loyc.LLParserGenerator.IntSet
bool IsCharSet = false
 Controls the default stringization mode. When IsCharSet, the set "(36, 65..90, 126)" prints as "[$A-Z~]". IsCharSet is false by default. More...
 

Public static fields

static readonly PGIntSet EOF = PGIntSet.With(-1)
 
static new readonly PGIntSet All = new PGIntSet(false, true)
 
static readonly PGIntSet AllExceptEOF = PGIntSet.Without(-1)
 
static new readonly PGIntSet Empty = new PGIntSet()
 
- Public static fields inherited from Loyc.LLParserGenerator.IntSet
static readonly IntSet All = IntSet.Without(EmptyArray<int>.Value)
 
static readonly IntSet Empty = new IntSet()
 
static readonly Symbol S_Equivalent = GSymbol.Get("Equivalent")
 
static readonly Symbol S_SameRangeList = GSymbol.Get("SameRangeList")
 
static readonly Symbol S_Identical = GSymbol.Get("Identical")
 

Properties

bool ContainsEOF [get]
 
- Properties inherited from Loyc.LLParserGenerator.IntSet
bool IsInverted [get]
 When Inverted is true, the set behaves as if it contains the opposite set of items. That is, membership tests that succeeded when Inverted was false will fail, and vice versa. More...
 
bool IsEmptySet [get]
 Returns true iff the set is empty. When the set is inverted and contains the set of all integers, that also counts as empty. More...
 
bool ContainsEverything [get]
 Returns true iff the set covers all integers. This includes the common scenario that the set is empty but inverted. More...
 
long Size [get]
 Gets the number of integers whose membership test would succeed (the maximum possible value is 0x100000000L). More...
 
long SizeIgnoringInversion [get]
 
IntRange this[int index] [get]
 
int Count [get]
 
- Properties inherited from Loyc.LLParserGenerator.IPGTerminalSet
bool IsInverted [get]
 
bool ContainsEOF [get]
 
bool IsEmptySet [get]
 
bool ContainsEverything [get]
 
IPGTerminalSet Empty [get]
 Returns the empty set. More...
 

Public Member Functions

PGIntSet WithEOF (bool wantEOF=true)
 Adds or removes EOF from the set. If the set doesn't change, this method may return this. More...
 
 PGIntSet (bool isCharSet=false, bool inverted=false)
 
 PGIntSet (IntRange r, bool isCharSet=false, bool inverted=false)
 
 PGIntSet (bool isCharSet, bool inverted, params IntRange[] list)
 
PGIntSet Union (IntSet other)
 
new PGIntSet Intersection (IntSet other, bool subtract=false, bool subtractThis=false)
 
new PGIntSet Subtract (IntSet other)
 
PGIntSet Optimize (IntSet dontcare)
 
bool Equals (IPGTerminalSet other)
 
int ExprComplexity ()
 Returns the "complexity" of the set. More...
 
Match ChooseMatchType (int maxRanges, int maxSingles)
 
LNode GenerateTest (LNode subject, Symbol setName)
 
- Public Member Functions inherited from Loyc.LLParserGenerator.IntSet
IntSet Inverted ()
 
 IntSet (bool isCharSet=false, bool inverted=false)
 
 IntSet (IntRange r, bool isCharSet=false, bool inverted=false)
 
 IntSet (bool isCharSet, bool inverted, params IntRange[] list)
 
bool Contains (int ch)
 
IntSet Union (IntSet r, bool cloneWhenOneIsEmpty=false)
 
IntSet Intersection (IntSet r, bool subtract=false, bool subtractThis=false)
 
IntSet Subtract (IntSet other)
 
IntSet EquivalentInverted ()
 Computes the equivalent inverted set, e.g. if the set is 'b'..'y', the equivalent inverted set is ~(int.MinValue..'a' | 'z'..int.MaxValue). More...
 
IntSet Clone ()
 
override string ToString ()
 Prints the character set using regex syntax, e.g. [$a-z] means "EOF or a to z", [^
] means "not \n or \r". Use ToString(false) if this is an integer set. More...
 
string ToString (bool charSet)
 
IEnumerator< IntRangeGetEnumerator ()
 
IEnumerator< IntRangeGetEnumerator (bool obeyInversion)
 
IntRange TryGet (int index, out bool fail)
 
override bool Equals (object obj)
 
bool Equals (IntSet other)
 
override int GetHashCode ()
 
bool Equals (IntSet other, Symbol mode)
 
InternalList< IntRangeRuns ()
 
InternalList< IntRangeInternalRangeList ()
 
IEnumerable< int > IntegerSequence (bool obeyInversion)
 
IntSet Optimize (IntSet dontcare, bool mergeRuns=true)
 

Static Public Member Functions

static new PGIntSet With (params int[] members)
 
static new PGIntSet WithRanges (params int[] ranges)
 
static new PGIntSet Without (params int[] members)
 
static new PGIntSet WithoutRanges (params int[] ranges)
 
static new PGIntSet WithChars (params int[] members)
 
static new PGIntSet WithCharRanges (params int[] ranges)
 
static new PGIntSet WithoutChars (params int[] members)
 
static new PGIntSet WithoutCharRanges (params int[] ranges)
 
static new PGIntSet Parse (string members)
 
static new PGIntSet TryParse (string members)
 
static new PGIntSet TryParse (string members, out int errorIndex)
 
- Static Public Member Functions inherited from Loyc.LLParserGenerator.IntSet
static implicit operator IntSet (int c)
 
static implicit operator IntSet (IntRange r)
 
static IntSet With (params int[] members)
 
static IntSet WithRanges (params int[] ranges)
 
static IntSet Without (params int[] members)
 
static IntSet WithoutRanges (params int[] ranges)
 
static IntSet WithChars (params int[] members)
 
static IntSet WithCharRanges (params int[] ranges)
 
static IntSet WithoutChars (params int[] members)
 
static IntSet WithoutCharRanges (params int[] ranges)
 
static IntSet Parse (string members)
 
static IntSet TryParse (string members)
 
static IntSet TryParse (string members, out int errorIndex)
 

Protected Member Functions

 PGIntSet (bool isCharSet, InternalList< IntRange > ranges, bool inverted, bool autoSimplify)
 
 PGIntSet (bool isCharSet, bool inverted, bool ranges, params int[] list)
 
override IntSet New (IntSet basis, bool inverted, InternalList< IntRange > ranges)
 
- Protected Member Functions inherited from Loyc.LLParserGenerator.IntSet
 IntSet (bool isCharSet, InternalList< IntRange > ranges, bool inverted, bool autoSimplify)
 
 IntSet (bool isCharSet, bool inverted, bool ranges, params int[] list)
 

Protected static fields

static LNodeFactory F = new LNodeFactory(new EmptySourceFile("PGIntSet.cs"))
 

Additional Inherited Members

- Protected fields inherited from Loyc.LLParserGenerator.IntSet
readonly InternalList< IntRange_ranges = InternalList<IntRange>.Empty
 A list of non-overlapping character ranges, sorted by code point. EOF can be included in this list as character -1 (hence CharRange holds ints instead of chars). More...
 
readonly bool _inverted
 

Member Function Documentation

int Loyc.LLParserGenerator.PGIntSet.ExprComplexity ( )
inline

Returns the "complexity" of the set.

The parser generator tests simple sets such as "la0 == ' ' || la0 == '\t'" inline using an expression, but large sets are stored in variables and tested by calling a method. Complexity() is used to decide which approach is more appropriate.

PGIntSet Loyc.LLParserGenerator.PGIntSet.WithEOF ( bool  wantEOF = true)
inline

Adds or removes EOF from the set. If the set doesn't change, this method may return this.

Implements Loyc.LLParserGenerator.IPGTerminalSet.