Detailed Description

A Markup Language (ML) lexer reads xml-like markup languages from a string. It's used to help form a DOM like structure from any markup string such as html, sml, xml etc.

Inheritance diagram for Wrench.MLLexer:
Wrench.StringReader

Public Member Functions

 MLLexer (string str, bool literal)
 Starts a new lexer, optionally placing it immediately in literal mode. More...
 
 MLLexer (string str)
 
override char Read ()
 Reads a character from the string. More...
 
void ExitLiteral ()
 Call this to exit literal mode. More...
 
bool PeekJunk ()
 Checks if there is any junk such as tabs next in the lexer. More...
 
bool ReadJunk ()
 Reads junk such as tabs from the lexer. More...
 
void SkipSpaces ()
 Skips any whitespaces that occur next. More...
 
- Public Member Functions inherited from Wrench.StringReader
 StringReader (byte[] str)
 Creates a new reader for the raw single-byte encoded string. Useful if you're talking to e.g. a webserver with a binary protocol. More...
 
 StringReader (string str)
 Creates a new reader for the given string. More...
 
bool More ()
 Checks if there is anything left to read. More...
 
char Peek ()
 Takes a peek at the next character in the stream without reading it. More...
 
char Peek (int delta)
 Takes a peek at the character that is a number of characters away from the next one without actually reading it. Peek(0) is the next character, Peek(1) is the one after that etc. More...
 
void StepBack ()
 Steps back one place in the stream. More...
 
void Advance ()
 Steps forward one place in the stream. More...
 
void Advance (int places)
 Steps forward the given number of places in the stream. More...
 
int Length ()
 The length of the string. More...
 
void ReadUntil (char character)
 Keeps reading the given character from the stream until it's no longer next. Used for e.g. stripping an unknown length block of whitespaces in the stream. More...
 
void ReadOff (char[] chars)
 Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream. More...
 
void ReadOff (char[] chars, out int count)
 Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream. More...
 
int GetLineNumber ()
 Gets the line number that the pointer is currently at. More...
 
int GetLineNumber (out int charOnLine)
 Gets the line number and character number that the pointer is currently at. More...
 
string ReadLine (int lineNumber)
 Reads the numbered line from this stream. More...
 

Public Attributes

bool Literal
 Set this to true if the lexer should be in literal mode. This prevents it stripping any junk such as tabs. More...
 
bool DidReadJunk
 True if the lexer read some junk such as tabs from the string. More...
 
- Public Attributes inherited from Wrench.StringReader
string Input
 The original string. More...
 
int Position
 The current position this reader is at in the string. More...
 
int InputLength
 The length of the input string. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Wrench.StringReader
static char NULL ='\0'
 The null character. This is returned when operations are working beyond the end of the stream. More...
 

Constructor & Destructor Documentation

Wrench.MLLexer.MLLexer ( string  str,
bool  literal 
)
inline

Starts a new lexer, optionally placing it immediately in literal mode.

summary>Creates a new lexer for the given xml-like string.

Wrench.MLLexer.MLLexer ( string  str)
inline

Member Function Documentation

void Wrench.MLLexer.ExitLiteral ( )
inline

Call this to exit literal mode.

bool Wrench.MLLexer.PeekJunk ( )
inline

Checks if there is any junk such as tabs next in the lexer.

Returns
True if any junk was next. Note that it has already been read off.
override char Wrench.MLLexer.Read ( )
inlinevirtual

Reads a character from the string.

Returns
The character that was read. Wrench.StringReader.NULL is returned if the end of the input is reached.

Reimplemented from Wrench.StringReader.

bool Wrench.MLLexer.ReadJunk ( )
inline

Reads junk such as tabs from the lexer.

Returns
True if any junk was read.
void Wrench.MLLexer.SkipSpaces ( )
inline

Skips any whitespaces that occur next.

Member Data Documentation

bool Wrench.MLLexer.DidReadJunk

True if the lexer read some junk such as tabs from the string.

bool Wrench.MLLexer.Literal

Set this to true if the lexer should be in literal mode. This prevents it stripping any junk such as tabs.