An implementation of the LLLPG Lexer API, used with the LLLPG options inputSource
and inputClass
.
A synonym for LexerSource<C> where C is ICharSource.
This derived class simply makes public all of the LLLPG APIs which are marked protected in BaseLexer<CharSrc>.
LLLPG(lexer(inputSource(src), inputClass(LexerSource))) { static rule int ParseInt(string input) { var src = (LexerSource<UString>)input; @[ (d:='0'..'9' {$result = $result * 10 + (d - '0');})+ ]; } }
- Template Parameters
-
CharSrc | A class that implements ICharSource. In order to write lexers that can accept any source of characters, set CharSrc=ICharSource. For maximum performance when parsing strings (or to avoid memory allocation), set CharSrc=UString (UString is a wrapper around System.String that, among other things, implements ICharSource ; please note that C# will implicitly convert normal strings to UString for you). |
|
| LexerSource (CharSrc source, string fileName="", int inputPosition=0, bool newSourceFile=true) |
| Initializes LexerSource. More...
|
|
virtual new void | Reset (CharSrc source, string fileName="", int inputPosition=0, bool newSourceFile=true) |
| Reinitializes the object. This method is called by the constructor.
|
|
new void | Reset () |
|
new int | LA (int i) |
|
new void | Skip () |
|
virtual new void | AfterNewline () |
| The lexer must call this method exactly once after it advances past each newline, even inside comments and strings. This method keeps the LineNumber and LineStartAt properties updated.
|
|
new void | Newline () |
|
new int | MatchAny () |
|
new int | Match (HashSet< int > set) |
|
new int | Match (int a) |
|
new int | Match (int a, int b) |
|
new int | Match (int a, int b, int c) |
|
new int | Match (int a, int b, int c, int d) |
|
new int | MatchRange (int aLo, int aHi) |
|
new int | MatchRange (int aLo, int aHi, int bLo, int bHi) |
|
new int | MatchExcept () |
|
new int | MatchExcept (HashSet< int > set) |
|
new int | MatchExcept (int a) |
|
new int | MatchExcept (int a, int b) |
|
new int | MatchExcept (int a, int b, int c) |
|
new int | MatchExcept (int a, int b, int c, int d) |
|
new int | MatchExceptRange (int aLo, int aHi) |
|
new int | MatchExceptRange (int aLo, int aHi, int bLo, int bHi) |
|
new bool | TryMatch (HashSet< int > set) |
|
new bool | TryMatch (int a) |
|
new bool | TryMatch (int a, int b) |
|
new bool | TryMatch (int a, int b, int c) |
|
new bool | TryMatch (int a, int b, int c, int d) |
|
new bool | TryMatchRange (int aLo, int aHi) |
|
new bool | TryMatchRange (int aLo, int aHi, int bLo, int bHi) |
|
new bool | TryMatchExcept () |
|
new bool | TryMatchExcept (HashSet< int > set) |
|
new bool | TryMatchExcept (int a) |
|
new bool | TryMatchExcept (int a, int b) |
|
new bool | TryMatchExcept (int a, int b, int c) |
|
new bool | TryMatchExcept (int a, int b, int c, int d) |
|
new bool | TryMatchExceptRange (int aLo, int aHi) |
|
new bool | TryMatchExceptRange (int aLo, int aHi, int bLo, int bHi) |
|
virtual new void | Check (bool expectation, string expectedDescr="") |
|
virtual new void | Error (int lookaheadIndex, string format) |
| This method is called to handle errors that occur during lexing. More...
|
|
virtual new void | Error (int lookaheadIndex, string format, params object[] args) |
| This method is called to format and handle errors that occur during lexing. The default implementation sends errors to ErrorSink, which, by default, throws a FormatException. More...
|
|
new void | PrintChar (int c, StringBuilder sb) |
|
| LexerSource (ICharSource source, string fileName="", int inputPosition=0, bool newSourceFile=true) |
|
| LexerSourceWorkaround (CharSrc source, string fileName="", int inputPosition=0, bool newSourceFile=true) |
|
| BaseLexer (CharSrc chars, string fileName="", int inputPosition=0, bool newSourceFile=true) |
| Initializes BaseLexer. More...
|
|
LineColumnFile | IndexToLine (int charIndex) |
| Returns the position in a source file of the specified index. More...
|
|
Token | MatchRange (int aLo, int aHi) |
|
Token | MatchRange (int aLo, int aHi, int bLo, int bHi) |
|
Token | MatchExceptRange (int aLo, int aHi) |
|
Token | MatchExceptRange (int aLo, int aHi, int bLo, int bHi) |
|
bool | TryMatchRange (int aLo, int aHi) |
|
bool | TryMatchRange (int aLo, int aHi, int bLo, int bHi) |
|
bool | TryMatchExceptRange (int aLo, int aHi) |
|
bool | TryMatchExceptRange (int aLo, int aHi, int bLo, int bHi) |
|
|
override void | Error_Renamed (int lookaheadIndex, string format, params object[] args) |
|
override void | Error_Renamed (int lookaheadIndex, string format) |
|
override void | Error (int lookaheadIndex, string format) |
| This method is called to handle errors that occur during lexing. More...
|
|
override void | Error (int lookaheadIndex, string format, params object[] args) |
| This method is called to format and handle errors that occur during lexing. The default implementation sends errors to ErrorSink, which, by default, throws a FormatException. More...
|
|
void | Reset () |
|
int | LA (int i) |
|
void | Skip () |
| Increments InputPosition. Called by LLLPG when prediction already verified the input (and caller doesn't save LA(0)) More...
|
|
| BaseLexer (ICharSource source, string fileName="", int inputPosition=0, bool newSourceFile=true) |
|
void | Newline () |
| Default newline parser that matches '
' or '\r' unconditionally. More...
|
|
void | Spaces () |
| Skips past any spaces at the current position. Equivalent to rule Spaces @[ (' '|'\t')* ] in LLLPG. More...
|
|
int | MatchAny () |
|
int | Match (HashSet< int > set) |
|
int | Match (int a) |
|
int | Match (int a, int b) |
|
int | Match (int a, int b, int c) |
|
int | Match (int a, int b, int c, int d) |
|
int | MatchRange (int aLo, int aHi) |
|
int | MatchRange (int aLo, int aHi, int bLo, int bHi) |
|
int | MatchExcept () |
|
int | MatchExcept (HashSet< int > set) |
|
int | MatchExcept (int a) |
|
int | MatchExcept (int a, int b) |
|
int | MatchExcept (int a, int b, int c) |
|
int | MatchExcept (int a, int b, int c, int d) |
|
int | MatchExceptRange (int aLo, int aHi) |
|
int | MatchExceptRange (int aLo, int aHi, int bLo, int bHi) |
|
bool | TryMatch (HashSet< int > set) |
|
bool | TryMatch (int a) |
|
bool | TryMatch (int a, int b) |
|
bool | TryMatch (int a, int b, int c) |
|
bool | TryMatch (int a, int b, int c, int d) |
|
bool | TryMatchRange (int aLo, int aHi) |
|
bool | TryMatchRange (int aLo, int aHi, int bLo, int bHi) |
|
bool | TryMatchExcept () |
|
bool | TryMatchExcept (HashSet< int > set) |
|
bool | TryMatchExcept (int a) |
|
bool | TryMatchExcept (int a, int b) |
|
bool | TryMatchExcept (int a, int b, int c) |
|
bool | TryMatchExcept (int a, int b, int c, int d) |
|
bool | TryMatchExceptRange (int aLo, int aHi) |
|
bool | TryMatchExceptRange (int aLo, int aHi, int bLo, int bHi) |
|
virtual object | IndexToPositionObject (int charIndex) |
|
virtual void | MatchError (bool inverted, params int[] ranges) |
|
virtual void | MatchError (bool inverted, IList< int > ranges) |
| Handles an error that occurs during Match(), MatchExcept(), MatchRange() or MatchExceptRange() More...
|
|
virtual void | Error (bool inverted, HashSet< int > set) |
|
string | RangesToString (IList< int > ranges) |
| Converts a list of character ranges to a string, e.g. for input list {'*','*','a','z'}, the output is "'*' 'a'..'z'". More...
|
|
void | PrintChar (int c, StringBuilder sb) |
| Prints a character as a string, e.g. 'a' -> "'a'" , with the special value -1 representing EOF, so PrintChar(-1, ...) == "EOF". More...
|
|