mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-29 08:20:02 -05:00
patterns: Rewrite evaluation engine (#306)
* patterns: Rewrite most of the evaluator to mainly use polymorphism instead of just RTTI * patterns: Fixed a couple of AST memory leaks * patterns: Parse string operations correctly * patterns: Various fixes and cleanup * patterns: Implement primitive function definitions Function parameters now need to provide their type in the definition * patterns: Added function variable definition and assignment * patterns: Added remaining function statements * patterns: Added unsized and while-sized arrays * patterns: Added multi variable declarations to functions * patterns: Added std::format built-in function * patterns: Allow passing custom types to functions * patterns: Added attributes and new "format" attribute * patterns: Use libfmt for std::print instead of custom version * patterns: Remove unnecessary string compare function * pattern: Fix preprocessor directives * patterns: Fix unit tests * patterns: Added cast expression * patterns: Handle endianess in function parameters * patterns: Added casting to different endian * patterns: Added 'str' type for functions
This commit is contained in:
@@ -25,8 +25,9 @@ namespace hex::pl {
|
||||
output.reserve(code.length());
|
||||
|
||||
try {
|
||||
bool startOfLine = true;
|
||||
while (offset < code.length()) {
|
||||
if (code[offset] == '#') {
|
||||
if (code[offset] == '#' && startOfLine) {
|
||||
offset += 1;
|
||||
|
||||
if (code.substr(offset, 7) == "include") {
|
||||
@@ -164,8 +165,11 @@ namespace hex::pl {
|
||||
throwPreprocessorError("unterminated comment", lineNumber - 1);
|
||||
}
|
||||
|
||||
if (code[offset] == '\n')
|
||||
if (code[offset] == '\n') {
|
||||
lineNumber++;
|
||||
startOfLine = true;
|
||||
} else if (!std::isspace(code[offset]))
|
||||
startOfLine = false;
|
||||
|
||||
output += code[offset];
|
||||
offset += 1;
|
||||
|
||||
Reference in New Issue
Block a user