diff --git a/compiler.cpp b/compiler.cpp index 335ddd4..15a4b8d 100644 --- a/compiler.cpp +++ b/compiler.cpp @@ -4,59 +4,9 @@ // derived from https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl01.html -// any non tokens get to be returned as ascii val from 0 to -255 -enum token { - eof, // End of File - external, // C stuff - variable, // Name of a variable - tree, // tree{tree, tree{tree{tree, tree}, tree, tree{tree}}} - integer, // integer ._. - string, // string O_O -}; - -std::string identifierStr; // filled if string -long numVal; // filled if integer - -int getTok() { - int lastChar = ' '; - - // skip le whitespace - while( isspace(lastChar) ) - lastChar = getchar(); - - if( isalpha(lastChar) ) { // identifier: [a-zA-Z][a-zA-Z0-9]* - identifierStr = lastChar; - while( isalnum((lastChar = getchar())) ) - identifierStr += lastChar; - - if( identifierStr == "external" ) - return external; - - if( isdigit(lastChar) ) { - std::string numStr; - do { - numStr += lastChar; - lastChar = getchar(); - } while( isdigit(lastChar) ); - - numVal = atol(numStr.c_str()); - return integer; - } - - if( lastChar == '#' ) { - do - lastChar = getchar(); - while (lastChar != EOF && lastChar != '\n' && lastChar != '\r'); - - if (lastChar != EOF) - return getTok(); - } - - return variable; - } -} +#include "lexer.cpp" +#include "parser.cpp" void compiler( char filename[] ) { - getTok(); - + while(true) LOG(getTok()) } diff --git a/global.h b/global.h index 48242b7..03136de 100644 --- a/global.h +++ b/global.h @@ -1,4 +1,5 @@ #pragma once +#include #define DEBUG 1 #if DEBUG == 1 diff --git a/main.cpp b/main.cpp index 88f036d..f376e09 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,3 @@ -#include - #include "compiler.cpp" #include "global.h"