summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..ee376c2
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,39 @@
+#include <iterator>
+#include <string>
+#include <vector>
+#include <iostream>
+#include "include/lexer.hpp"
+
+using std::string, std::cin, std::cout, std::getline, std::vector,
+ std::begin, std::end;
+
+string types[] = {string(1, '+'), string(1, '-'), string(1, '/'), string(1, '*'),
+ string(1, '^'), "variable", "número", "función", string(1, '('), string(1, ')'), "nil"};
+
+
+void print_tokens(const vector< Token > &tokens){
+ for(auto i = begin(tokens); i != end(tokens); ++i)
+ {
+ if(i->type == variable || i->type == number || i->type == function)
+ cout << "Tipo: " << types[i->type] << "\nValor: " << i->value << '\n';
+ else
+ cout << "Tipo: " << types[i->type] << '\n';
+ }
+}
+
+int main(){
+ vector< Token > tokens;
+ string input;
+ Lexer lexer;
+ getline(cin, input);
+ lexer.setText(input);
+
+ while(lexer.getCurrentToken().type != nil)
+ {
+ tokens.push_back(lexer.getCurrentToken());
+ lexer.nextToken();
+ }
+ print_tokens(tokens);
+
+ return 0;
+}