diff --git a/compiler.cpp b/compiler.cpp index fdac1cf..335ddd4 100644 --- a/compiler.cpp +++ b/compiler.cpp @@ -9,12 +9,13 @@ 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 +long numVal; // filled if integer int getTok() { int lastChar = ' '; @@ -28,9 +29,29 @@ int getTok() { while( isalnum((lastChar = getchar())) ) identifierStr += lastChar; - if( identifierStr == "" ) + 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; } } diff --git a/readme.md b/readme.md index 7e8bcd7..c66baee 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,16 @@ # TreeLang -Treeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee +TreeLang is an half esolang thingy with trees + +## Examples + +```TreeLang +# assigning to treeThing +treeThing <- 93 { # root node + "childNode1", # child node 1: the legacy of the root + 1942 { # child node with children + "AAA", # child of child + "AUGH" + } +} +```