Class LineParser
Contains methods used to parse tokens from a LoliScript line of code.
Inheritance
Inherited Members
Namespace: RuriLib.LS
Assembly: RuriLib.dll
Syntax
public static class LineParser
Methods
| Improve this Doc View SourceCheckIdentifier(ref String, String)
Checks if the next token is a given identifier.
Declaration
public static bool CheckIdentifier(ref string input, string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
System.String | id | The identifier to check |
Returns
Type | Description |
---|---|
System.Boolean | Whether the token and the identifier are equal |
EnsureIdentifier(ref String, String)
Makes sure that a specified identifier is present and moves past it. An exception will be thrown if the identifier is not present.
Declaration
public static void EnsureIdentifier(ref string input, string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
System.String | id | The expected identifier |
Lookahead(ref String)
Gets the type of the first token in the given line of code.
Declaration
public static TokenType Lookahead(ref string input)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
Returns
Type | Description |
---|---|
TokenType | The type of the token |
ParseEnum(ref String, String, Type)
Parses an enum value from a line.
Declaration
public static dynamic ParseEnum(ref string input, string label, Type enumType)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
System.String | label | Debug information about the expected enum |
System.Type | enumType | The type of the enum |
Returns
Type | Description |
---|---|
System.Object | An enum of the provided enumType |
ParseInt(ref String, String)
Parses an integer value from a line.
Declaration
public static int ParseInt(ref string input, string label)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
System.String | label | Debug information about the expected integer |
Returns
Type | Description |
---|---|
System.Int32 | The integer value |
ParseLabel(ref String)
Parses a block label from a line.
Declaration
public static string ParseLabel(ref string input)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
Returns
Type | Description |
---|---|
System.String | The label of the block, if defined |
ParseLiteral(ref String, String, Boolean, BotData)
Parses a literal value from a line.
Declaration
public static string ParseLiteral(ref string input, string label, bool replace = false, BotData data = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
System.String | label | Debug information about the expected literal |
System.Boolean | replace | Whether to perform variable replacement in the literal |
BotData | data | The BotData needed for variable replacement |
Returns
Type | Description |
---|---|
System.String | The literal without the leading and trailing double quotes |
ParseToken(ref String, TokenType, Boolean, Boolean)
Parses a token of a given type from a line.
Declaration
public static string ParseToken(ref string input, TokenType type, bool essential, bool proceed = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
TokenType | type | The type of token to parse |
System.Boolean | essential | Whether an exception should be thrown if the token cannot be parsed |
System.Boolean | proceed | Whether to remove the token from the original line after parsing it |
Returns
Type | Description |
---|---|
System.String | The parsed token or, if parse fails but the token is not essential, an empty string |
SetBool(ref String, Object)
Sets a boolean property by parsing its name and value from a line.
Declaration
public static void SetBool(ref string input, object instance)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The reference to the line of code |
System.Object | instance | The instance of the object containing the boolean property |