CodeToHscript
loreline.CodeToHscript (Class)
Preprocesses Loreline script code to make it compatible with HScript.
This class converts Loreline syntax into valid HScript syntax by:
- Converting 'and' and 'or' operators to '&&' and '||'
- Adding parentheses around control structure conditions
- Adding semicolons and braces where needed
- Processing string literals and comments
Instance Members
The input Loreline script code
Buffer for the processed output
Processes a Loreline script code string and converts it to HScript compatible code.
| Name |
Type |
Description |
input |
String |
The Loreline script code to process |
| Returns |
Description |
| String |
The processed HScript compatible code |
Creates a new CodeToHscript instance.
Private Members
List of control flow keywords that may need special handling
Current position in the input string
Buffer for tracking the current line
Length of the input string
Current indentation level
Whether currently processing a comment
Whether currently processing a string literal
Tracks position offsets for error reporting
Current position offset
Whether currently processing a control structure
inControlWithoutParens: Bool
Whether currently processing a control structure without explicit parentheses
Current indentation level
Stack of indentation levels
A stack to keep track of whether we are inside an object or array literal or not
Main input processing loop that handles each character in the input.
| Name |
Type |
Default |
until |
Int |
-1 |
Processes a string literal, preserving its content and escape sequences.
processComplexInterpolation(): Void
processFieldAccessInterpolation(): Void
processIdentifier(): Void
Checks if a character is a digit (0-9).
@*
| Name |
Type |
Description |
c |
Int |
Character code to check |
| Returns |
Description |
| Bool |
Whether the character is a digit |
Checks if a character is valid as the start of an identifier.
Valid identifier starts are letters and underscore.
| Name |
Type |
Description |
c |
Int |
Character code to check |
| Returns |
Description |
| Bool |
Whether the character can start an identifier |
Checks if a character is valid as part of an identifier.
Valid identifier parts are letters, numbers, and underscore.
| Name |
Type |
Description |
c |
Int |
Character code to check |
| Returns |
Description |
| Bool |
Whether the character can be part of an identifier |
Processes comments, preserving their layout while replacing content with spaces
to maintain character positions for error reporting.
Checks if a line ends with a specific character.
| Name |
Type |
Description |
line |
String |
The line to check |
c |
Int |
The character code to look for |
| Returns |
Description |
| Bool |
True if the line ends with the character, false otherwise |
Checks if the next non-whitespace, non-comment character in the input is a specific character.
| Name |
Type |
Description |
c |
Int |
The character code to look for |
pos |
Int |
The position to start looking from |
| Returns |
Description |
| Bool |
True if the next meaningful character is the one we're looking for, false otherwise |
Checks if a line ends with a specific character or if the character follows in the input.
| Name |
Type |
Default |
Description |
line |
String |
|
The line to check |
c |
Int |
|
The character code to look for |
pos |
Int |
|
The position to start looking from if the character is not at the end of the line |
hxpos |
Null<haxe.PosInfos> |
(optional) |
|
| Returns |
Description |
| Bool |
True if the character is found at the end of the line or as the next meaningful character |
Calculates the indentation change between the current line and the next non-empty line.
| Name |
Type |
Description |
line |
String |
The current line |
pos |
Int |
The position to start looking from for the next line |
| Returns |
Description |
| Int |
A positive number for indent, negative for dedent, or zero for no change |
Checks if the next non-whitespace, non-comment token is the "if" keyword.
Used to detect "else if" constructs that shouldn't add braces between else and if.
| Name |
Type |
Description |
pos |
Int |
The position to start looking from |
| Returns |
Description |
| Bool |
True if the next token is "if", false otherwise |
Checks if a line ends with a control flow keyword (if, for, while, etc.).
| Name |
Type |
Description |
line |
String |
The line to check |
pos |
Int |
The position to use for validating what follows the potential keyword |
| Returns |
Description |
| Bool |
True if the line ends with a control keyword, false otherwise |
Checks if a character is a whitespace character.
| Name |
Type |
Description |
c |
Int |
The character code to check |
| Returns |
Description |
| Bool |
True if the character is whitespace, false otherwise |
Checks if a character is alphanumeric or underscore.
| Name |
Type |
Description |
c |
Int |
The character code to check |
| Returns |
Description |
| Bool |
True if the character is alphanumeric or underscore, false otherwise |
Adds a character to the output, and increment index
Adds a character to the output without incrementing index
inStatementsBlock(): Bool
Returns whether the input at the given position begins with a label pattern (identifier:).
| Name |
Type |
Description |
pos |
Int |
Position to check from |
| Returns |
Description |
| Bool |
True if a label starts at the position, false otherwise |