From c34b2c57219aa496a202c2be1e12332b4eeea440 Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Mon, 14 Apr 2025 15:43:20 +0000
Subject: [PATCH] add function parameter handling and contextes
---
src/ScriptInterpreterHelpers.hpp | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/ScriptInterpreterHelpers.hpp b/src/ScriptInterpreterHelpers.hpp
index 9238a06..bff499f 100644
--- a/src/ScriptInterpreterHelpers.hpp
+++ b/src/ScriptInterpreterHelpers.hpp
@@ -39,7 +39,8 @@
if (tokens[i].type != TokenType::StringDeclaration && tokens[i].type != TokenType::BooleanDeclaration &&
tokens[i].type != TokenType::IntDeclaration && tokens[i].type != TokenType::DoubleDeclaration &&
tokens[i].type != TokenType::RightParenthesis) {
- THROW_UNEXPECTED_TOKEN_ERROR_HELPER(tokens[i], "variable declaration", file, line);
+ THROW_UNEXPECTED_TOKEN_ERROR_HELPER(tokens[i], "variable declaration: 'type $" + tokens[i].lexeme + "'", file,
+ line);
}
if (tokens[i].type != TokenType::RightParenthesis) {
const auto parameter_type = getVariableTypeFromTokenTypeDeclaration(tokens[i].type);
@@ -47,9 +48,9 @@
THROW_UNEXPECTED_TOKEN_ERROR_HELPER(tokens[i], "valid type identifier", file, line);
}
- if (parameter_type == Variables::Type::VT_FUNCTION) {
- THROW_UNEXPECTED_TOKEN_ERROR_HELPER(tokens[i], "valid type identifier", file, line);
- }
+ // if (parameter_type == Variables::Type::VT_FUNCTION) {
+ // THROW_UNEXPECTED_TOKEN_ERROR_HELPER(tokens[i], "valid type identifier", file, line);
+ // }
if (parameter_type == Variables::Type::VT_NULL) {
THROW_UNEXPECTED_TOKEN_ERROR_HELPER(tokens[i], "valid type identifier", file, line);
@@ -74,9 +75,6 @@
static void getFunctionBody(const std::vector<Token> & tokens, std::size_t & i, std::size_t & start,
std::size_t & end) {
start = tokens[i].pos.end;
- std::cout << "START Token: " << tokens[i].lexeme << " start pos: " << std::to_string(tokens[i].pos.start)
- << " end pos: " << std::to_string(tokens[i].pos.end) << '\n';
-
if (i >= tokens.size() || tokens[i].type != TokenType::LeftCurlyBracket) {
THROW_UNEXPECTED_TOKEN_ERROR(tokens[i], "{");
}
@@ -88,15 +86,12 @@
continue;
}
if (tokens[i].type == TokenType::EndOfFile) {
- throw std::runtime_error("Unexpected end of file");
+ THROW_UNEXPECTED_END_OF_FILE_ERROR(tokens[i]);
break;
}
i++;
}
end = tokens[i].pos.start - 1;
-
- std::cout << "END Token: " << tokens[i].lexeme << " start pos: " << std::to_string(tokens[i].pos.start)
- << " end pos: " << std::to_string(tokens[i].pos.end) << '\n';
if (i >= tokens.size() || tokens[i].type != TokenType::RightCurlyBracket) {
THROW_UNEXPECTED_TOKEN_ERROR(tokens[i], "}");
--
Gitblit v1.9.3