C# Class idTech4.Text.idLexer

Lexicographical parser.
A number directly following the escape character '\' in a string is assumed to be in decimal format instead of octal. Binary numbers of the form 0b.. or 0B.. can also be used.
Show file Open project: iainmckay/idtech4.net Class Usage Examples

Public Properties

Property Type Description
DefaultPunctuation idTech4.Text.LexerPunctuation[]

Public Methods

Method Description
CheckTokenString ( string str ) : bool

Checks if the next token matches the given string.

CheckTokenType ( TokenType type, TokenSubType subType ) : idToken

Reads the token when a token with the given type is available.

Error ( string format ) : void
ExpectAnyToken ( ) : idToken
ExpectTokenString ( string str ) : bool
ExpectTokenType ( TokenType type, TokenSubType subType ) : idToken
GetPunctuationFromID ( TokenSubType id ) : string
LoadFile ( string fileName, bool osPath = false ) : bool
LoadMemory ( string text, string name ) : bool

Load a script from the given memory.

LoadMemory ( string text, string name, int startLine ) : bool

Load a script from the given memory and a specified line offset, so source strings extracted from a file can still refer to proper line numbers in the file.

Parse1DMatrix ( int elementCount ) : float[]
Parse2DMatrix ( int y, int x ) : ].float[
ParseBool ( ) : bool

Parses a bool.

ParseFloat ( ) : float

Parses a floating point number.

ParseFloat ( bool &errorFlag ) : float

Parses a floating point number.

If errorFlag is NULL, a non-numeric token will issue an Error(). If it isn't NULL, it will issue a Warning() and set *errorFlag = true.

ParseInt ( ) : int

Parses an int.

ParseRestOfLine ( ) : string
ReadToken ( ) : idToken

Reads the next token.

ReadTokenOnLine ( ) : idToken

Read a token only if on the same line.

SkipBracedSection ( ) : bool

Skips until a matching close brace is found.

SkipBracedSection ( bool parseFirstBrace ) : bool

Skips until a matching close brace is found.

SkipRestOfLine ( ) : bool

Skip the rest of the current line.

SkipUntilString ( string str ) : bool
Warning ( string format ) : void
idLexer ( ) : System
idLexer ( LexerOptions options ) : System

Private Methods

Method Description
CheckString ( string str ) : bool
GetBufferCharacter ( int position ) : char
ParseFloat ( bool &errorFlag, bool useErrorFlag ) : float
ReadEscapeCharacter ( char &escapeCharacter ) : bool

Reads two strings with only a white space between them as one string.

ReadName ( idToken token ) : bool
ReadNumber ( idToken token ) : bool
ReadPunctuation ( idToken token ) : bool
ReadString ( idToken token, char quote ) : bool
ReadWhiteSpace ( ) : bool

Reads spaces, tabs, C-like comments, etc.

When a newline character is found the scripts line counter is increased.

Method Details

CheckTokenString() public method

Checks if the next token matches the given string.
public CheckTokenString ( string str ) : bool
str string
return bool

CheckTokenType() public method

Reads the token when a token with the given type is available.
public CheckTokenType ( TokenType type, TokenSubType subType ) : idToken
type TokenType
subType TokenSubType
return idToken

Error() public method

public Error ( string format ) : void
format string
return void

ExpectAnyToken() public method

public ExpectAnyToken ( ) : idToken
return idToken

ExpectTokenString() public method

public ExpectTokenString ( string str ) : bool
str string
return bool

ExpectTokenType() public method

public ExpectTokenType ( TokenType type, TokenSubType subType ) : idToken
type TokenType
subType TokenSubType
return idToken

GetPunctuationFromID() public method

public GetPunctuationFromID ( TokenSubType id ) : string
id TokenSubType
return string

LoadFile() public method

public LoadFile ( string fileName, bool osPath = false ) : bool
fileName string
osPath bool
return bool

LoadMemory() public method

Load a script from the given memory.
public LoadMemory ( string text, string name ) : bool
text string
name string
return bool

LoadMemory() public method

Load a script from the given memory and a specified line offset, so source strings extracted from a file can still refer to proper line numbers in the file.
public LoadMemory ( string text, string name, int startLine ) : bool
text string
name string
startLine int
return bool

Parse1DMatrix() public method

public Parse1DMatrix ( int elementCount ) : float[]
elementCount int
return float[]

Parse2DMatrix() public method

public Parse2DMatrix ( int y, int x ) : ].float[
y int
x int
return ].float[

ParseBool() public method

Parses a bool.
public ParseBool ( ) : bool
return bool

ParseFloat() public method

Parses a floating point number.
public ParseFloat ( ) : float
return float

ParseFloat() public method

Parses a floating point number.
If errorFlag is NULL, a non-numeric token will issue an Error(). If it isn't NULL, it will issue a Warning() and set *errorFlag = true.
public ParseFloat ( bool &errorFlag ) : float
errorFlag bool
return float

ParseInt() public method

Parses an int.
public ParseInt ( ) : int
return int

ParseRestOfLine() public method

public ParseRestOfLine ( ) : string
return string

ReadToken() public method

Reads the next token.
public ReadToken ( ) : idToken
return idToken

ReadTokenOnLine() public method

Read a token only if on the same line.
public ReadTokenOnLine ( ) : idToken
return idToken

SkipBracedSection() public method

Skips until a matching close brace is found.
public SkipBracedSection ( ) : bool
return bool

SkipBracedSection() public method

Skips until a matching close brace is found.
public SkipBracedSection ( bool parseFirstBrace ) : bool
parseFirstBrace bool
return bool

SkipRestOfLine() public method

Skip the rest of the current line.
public SkipRestOfLine ( ) : bool
return bool

SkipUntilString() public method

public SkipUntilString ( string str ) : bool
str string
return bool

Warning() public method

public Warning ( string format ) : void
format string
return void

idLexer() public method

public idLexer ( ) : System
return System

idLexer() public method

public idLexer ( LexerOptions options ) : System
options LexerOptions
return System

Property Details

DefaultPunctuation public static property

public static LexerPunctuation[],idTech4.Text DefaultPunctuation
return idTech4.Text.LexerPunctuation[]