diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index 7d709fb..ce5ef71 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -105,6 +105,10 @@ namespace StandardComponents { using NamedIdentifier::NamedIdentifier; }; namespace types { + struct Integer: ParseComponent { + long double value; + Integer(const string& value): value(stold(value)) {} + }; struct String: ParseComponent { const string content; explicit String(const char* string): content(string) {} diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index 907bdf6..86afbb8 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -42,6 +42,16 @@ namespace Parser { const tok& current = lexed[i], next = hasNext ? lexed[i + 1] : tok(UNEXPECTED, current.line); switch (current.toktype) { + case NUMBER: { + types::Integer Int = current.toktext; + if (nextAre({DOT, NUMBER})) { + i += 2; + const string& right = lexed[i].toktext; + Int.value += stold(right) / pow(10, right.size()); + } + parseTree << Int; + break; + } case STRING: parseTree << types::String(current.toktext.data()); break; case IDENTIFIER: { if (current.toktext == "class" || current.toktext == "structure") { diff --git a/src/headers/transpiler/Target.hpp b/src/headers/transpiler/Target.hpp index ec8e129..dd6e32b 100644 --- a/src/headers/transpiler/Target.hpp +++ b/src/headers/transpiler/Target.hpp @@ -132,7 +132,8 @@ public: output << ((parseComponent.name == "print") ? print_functions.first : (parseComponent.name == "print_line") ? print_functions.second : parseComponent.name) << '('; separate_transpileTree(parseComponent, ", "); output << ')'; - ) + ), + make_task(StandardComponents::types::Integer, output << parseComponent.value;) })); return staticMap; };