diff --git a/DMS/Debug/DMS.obj b/DMS/Debug/DMS.obj index 7ced275..917cd27 100644 Binary files a/DMS/Debug/DMS.obj and b/DMS/Debug/DMS.obj differ diff --git a/DMS/Debug/DMS.tlog/CL.command.1.tlog b/DMS/Debug/DMS.tlog/CL.command.1.tlog index 44e8581..2191231 100644 Binary files a/DMS/Debug/DMS.tlog/CL.command.1.tlog and b/DMS/Debug/DMS.tlog/CL.command.1.tlog differ diff --git a/DMS/Debug/DMS.tlog/CL.read.1.tlog b/DMS/Debug/DMS.tlog/CL.read.1.tlog index f573d0d..1c7d212 100644 Binary files a/DMS/Debug/DMS.tlog/CL.read.1.tlog and b/DMS/Debug/DMS.tlog/CL.read.1.tlog differ diff --git a/DMS/Debug/DMS.tlog/CL.write.1.tlog b/DMS/Debug/DMS.tlog/CL.write.1.tlog index a248f36..2d93c87 100644 Binary files a/DMS/Debug/DMS.tlog/CL.write.1.tlog and b/DMS/Debug/DMS.tlog/CL.write.1.tlog differ diff --git a/DMS/Debug/DMS.tlog/link.read.1.tlog b/DMS/Debug/DMS.tlog/link.read.1.tlog index 58e18cf..2d620b8 100644 Binary files a/DMS/Debug/DMS.tlog/link.read.1.tlog and b/DMS/Debug/DMS.tlog/link.read.1.tlog differ diff --git a/DMS/Debug/LineParser.obj b/DMS/Debug/LineParser.obj index 588b284..2081b09 100644 Binary files a/DMS/Debug/LineParser.obj and b/DMS/Debug/LineParser.obj differ diff --git a/DMS/Debug/vc142.idb b/DMS/Debug/vc142.idb index 6e5346c..8b6aab8 100644 Binary files a/DMS/Debug/vc142.idb and b/DMS/Debug/vc142.idb differ diff --git a/DMS/Debug/vc142.pdb b/DMS/Debug/vc142.pdb index 2817db2..9ede252 100644 Binary files a/DMS/Debug/vc142.pdb and b/DMS/Debug/vc142.pdb differ diff --git a/DMS/LineParser.cpp b/DMS/LineParser.cpp index 75aaac4..9666288 100644 --- a/DMS/LineParser.cpp +++ b/DMS/LineParser.cpp @@ -146,7 +146,23 @@ namespace dms { } return true; } - // This function is broken + + // Handling functions are important. This method is a helper function that allows you to + bool LineParser::processFunc(tokenstream stream, chunk c) { + // + return false; + } + bool processFunc(tokenstream stream, chunk c, std::string gotoo) { + return true; + } + bool LineParser::processExpr(tokenstream stream, chunk c) { + // + return false; + } + bool LineParser::processLogic(tokenstream stream, chunk c) { + // + return false; + } std::map LineParser::tokenizer(dms_state* state,std::vector &toks) { std::map chunks; chunk* current_chunk = nullptr; @@ -311,11 +327,17 @@ namespace dms { bool good = true; size_t c = 0; while (good) { - if (match(stream, tokens::tab,tokens::string,tokens::name)) { + // We need to template the matches + if (match(stream, tokens::tab,tokens::string,tokens::name,tokens::parao)) { stream.next(); - std::string choice = stream.next().name; + std::string prompt = stream.next().name; + + // To handle the function stuff we need to consume and process that data + // We have a method to process function data since this will be used a lot in many different places + // We just grabbed the prompt, we don't yet know how many choices we have. So we have to figure out how we can + // Process and write the bytecode for this. std::string func = stream.next().name; - print("Choice: <",c,"> ",choice," Funcname: ",func); + print("Choice: <",c,"> ",prompt," Funcname: ",func); std::vector funcstuff = stream.next(tokens::newline); //We need to process the function data and finish creating @@ -600,6 +622,9 @@ namespace dms { else if (str == "goto") { t_vec.push_back(token{ tokens::gotoo,codes::NOOP,"",line }); } + else if (str == "jump") { + t_vec.push_back(token{ tokens::jump,codes::NOOP,"",line }); + } else if (utils::isalphanum(str) && str.size()>0) { t_vec.push_back(token{ tokens::name,codes::NOOP,stream.processBuffer(buffer),line }); } diff --git a/DMS/LineParser.h b/DMS/LineParser.h index 46642c6..33b1eb6 100644 --- a/DMS/LineParser.h +++ b/DMS/LineParser.h @@ -46,6 +46,14 @@ namespace dms { //Matches tokens from the stream, if the tokens match it will return true and YOU should call next on the stream. This method does not change the current position bool match(tokenstream stream, tokens::tokentype t1=tokens::none, tokens::tokentype t2 = tokens::none, tokens::tokentype t3 = tokens::none, tokens::tokentype t4 = tokens::none, tokens::tokentype t5 = tokens::none, tokens::tokentype t6 = tokens::none, tokens::tokentype t7 = tokens::none, tokens::tokentype t8 = tokens::none, tokens::tokentype t9 = tokens::none, tokens::tokentype t10 = tokens::none, tokens::tokentype t11 = tokens::none, tokens::tokentype t12 = tokens::none); bool match(tokenstream stream, tokens::tokentype* t1 = nullptr,tokens::tokentype* t2 = nullptr, tokens::tokentype* t3 = nullptr, tokens::tokentype* t4 = nullptr, tokens::tokentype* t5 = nullptr, tokens::tokentype* t6 = nullptr, tokens::tokentype* t7 = nullptr, tokens::tokentype* t8 = nullptr, tokens::tokentype* t9 = nullptr, tokens::tokentype* t10 = nullptr, tokens::tokentype* t11 = nullptr, tokens::tokentype* t12 = nullptr); + + bool buildLabel(chunk c, std::string label); + + bool processFunc(tokenstream stream, chunk c); + bool processFunc(tokenstream stream, chunk c, std::string gotoo); + bool processExpr(tokenstream stream, chunk c); + bool processLogic(tokenstream stream, chunk c); + void tolower(std::string &str); tokens::tokentype* expr(); tokens::tokentype* variable(); diff --git a/DMS/dump.txt b/DMS/dump.txt index 3be9521..12a3eda 100644 --- a/DMS/dump.txt +++ b/DMS/dump.txt @@ -297,31 +297,17 @@ Line <48>NOOP name func Line <48>NOOP parao Line <48>NOOP parac Line <48>NOOP newline +Line <49>NOOP tab +Line <49>NOOP tab Line <49>NOOP newline Line <50>NOOP tab -Line <50>NOOP for -Line <50>NOOP name x -Line <50>NOOP equal -Line <50>NOOP number 1 -Line <50>NOOP seperator -Line <50>NOOP number 10 +Line <50>NOOP tab +Line <50>NOOP gotoo Line <50>NOOP newline -Line <51>NOOP tab -Line <51>NOOP tab -Line <51>NOOP for -Line <51>NOOP name y -Line <51>NOOP equal -Line <51>NOOP number 1 -Line <51>NOOP seperator -Line <51>NOOP number 10 -Line <51>NOOP seperator -Line <51>NOOP number 1 Line <51>NOOP newline Line <52>NOOP tab -Line <52>NOOP tab -Line <52>NOOP tab Line <52>NOOP for -Line <52>NOOP name z +Line <52>NOOP name x Line <52>NOOP equal Line <52>NOOP number 1 Line <52>NOOP seperator @@ -329,204 +315,225 @@ Line <52>NOOP number 10 Line <52>NOOP newline Line <53>NOOP tab Line <53>NOOP tab -Line <53>NOOP tab -Line <53>NOOP tab -Line <53>NOOP string test +Line <53>NOOP for +Line <53>NOOP name y +Line <53>NOOP equal +Line <53>NOOP number 1 +Line <53>NOOP seperator +Line <53>NOOP number 10 +Line <53>NOOP seperator +Line <53>NOOP number 1 Line <53>NOOP newline Line <54>NOOP tab Line <54>NOOP tab Line <54>NOOP tab -Line <54>NOOP tab -Line <54>NOOP string $x$ $y$ $z$ +Line <54>NOOP for +Line <54>NOOP name z +Line <54>NOOP equal +Line <54>NOOP number 1 +Line <54>NOOP seperator +Line <54>NOOP number 10 Line <54>NOOP newline Line <55>NOOP tab -Line <55>NOOP name test -Line <55>NOOP equal -Line <55>NOOP true true +Line <55>NOOP tab +Line <55>NOOP tab +Line <55>NOOP tab +Line <55>NOOP string test Line <55>NOOP newline Line <56>NOOP tab -Line <56>NOOP name test2 -Line <56>NOOP number -Line <56>NOOP equal -Line <56>NOOP false false +Line <56>NOOP tab +Line <56>NOOP tab +Line <56>NOOP tab +Line <56>NOOP string $x$ $y$ $z$ Line <56>NOOP newline Line <57>NOOP tab +Line <57>NOOP name test +Line <57>NOOP equal +Line <57>NOOP true true Line <57>NOOP newline Line <58>NOOP tab -Line <58>NOOP name count +Line <58>NOOP name test2 +Line <58>NOOP number Line <58>NOOP equal -Line <58>NOOP number 0 +Line <58>NOOP false false Line <58>NOOP newline Line <59>NOOP tab Line <59>NOOP newline Line <60>NOOP tab -Line <60>WHLE control Line <60>NOOP name count -Line <60>NOOP not Line <60>NOOP equal -Line <60>NOOP number 100 +Line <60>NOOP number 0 Line <60>NOOP newline Line <61>NOOP tab -Line <61>NOOP tab -Line <61>NOOP name count -Line <61>NOOP plus -Line <61>NOOP plus Line <61>NOOP newline Line <62>NOOP tab -Line <62>NOOP tab -Line <62>NOOP string Count = $count$ +Line <62>WHLE control +Line <62>NOOP name count +Line <62>NOOP not +Line <62>NOOP equal +Line <62>NOOP number 100 Line <62>NOOP newline Line <63>NOOP tab +Line <63>NOOP tab +Line <63>NOOP name count +Line <63>NOOP plus +Line <63>NOOP plus Line <63>NOOP newline Line <64>NOOP tab -Line <64>IFFF control -Line <64>NOOP parao -Line <64>NOOP name func -Line <64>NOOP parao -Line <64>NOOP number 123 -Line <64>NOOP parac -Line <64>NOOP not -Line <64>NOOP equal -Line <64>NOOP name name -Line <64>NOOP bracketo -Line <64>NOOP number 1 -Line <64>NOOP bracketc -Line <64>NOOP or -Line <64>NOOP true -Line <64>NOOP equal -Line <64>NOOP equal -Line <64>NOOP string Bob -Line <64>NOOP parac -Line <64>NOOP and -Line <64>NOOP name foodCount -Line <64>NOOP equal -Line <64>NOOP number 10.34 +Line <64>NOOP tab +Line <64>NOOP string Count = $count$ Line <64>NOOP newline Line <65>NOOP tab -Line <65>NOOP tab -Line <65>NOOP string test=true or test2=false! -Line <65>NOOP number Line <65>NOOP newline Line <66>NOOP tab -Line <66>NOOP tab -Line <66>NOOP string help me +Line <66>IFFF control +Line <66>NOOP parao +Line <66>NOOP name func +Line <66>NOOP parao +Line <66>NOOP number 123 +Line <66>NOOP parac +Line <66>NOOP not +Line <66>NOOP equal +Line <66>NOOP name name +Line <66>NOOP bracketo +Line <66>NOOP number 1 +Line <66>NOOP bracketc +Line <66>NOOP or +Line <66>NOOP true +Line <66>NOOP equal +Line <66>NOOP equal +Line <66>NOOP string Bob +Line <66>NOOP parac +Line <66>NOOP and +Line <66>NOOP name foodCount +Line <66>NOOP equal +Line <66>NOOP number 10.34 Line <66>NOOP newline Line <67>NOOP tab Line <67>NOOP tab -Line <67>IFFF control -Line <67>NOOP name cool -Line <67>NOOP equal -Line <67>NOOP equal -Line <67>NOOP true true +Line <67>NOOP string test=true or test2=false! +Line <67>NOOP number Line <67>NOOP newline Line <68>NOOP tab Line <68>NOOP tab -Line <68>NOOP tab -Line <68>NOOP string We are here +Line <68>NOOP string help me Line <68>NOOP newline Line <69>NOOP tab Line <69>NOOP tab -Line <69>NOOP tab -Line <69>NOOP string Nested if +Line <69>IFFF control +Line <69>NOOP name cool +Line <69>NOOP equal +Line <69>NOOP equal +Line <69>NOOP true true Line <69>NOOP newline Line <70>NOOP tab Line <70>NOOP tab -Line <70>ELIF control -Line <70>NOOP name food -Line <70>NOOP equal -Line <70>NOOP number 21 +Line <70>NOOP tab +Line <70>NOOP string We are here Line <70>NOOP newline Line <71>NOOP tab Line <71>NOOP tab Line <71>NOOP tab -Line <71>NOOP string This is getting weird +Line <71>NOOP string Nested if Line <71>NOOP newline Line <72>NOOP tab Line <72>NOOP tab -Line <72>NOOP string Hi +Line <72>ELIF control +Line <72>NOOP name food +Line <72>NOOP equal +Line <72>NOOP number 21 Line <72>NOOP newline Line <73>NOOP tab -Line <73>ELIF control -Line <73>NOOP parao -Line <73>NOOP name func2 -Line <73>NOOP parao -Line <73>NOOP number 321 -Line <73>NOOP parac -Line <73>NOOP not -Line <73>NOOP equal -Line <73>NOOP name name2 -Line <73>NOOP bracketo -Line <73>NOOP number 1 -Line <73>NOOP bracketc -Line <73>NOOP or -Line <73>NOOP true -Line <73>NOOP equal -Line <73>NOOP equal -Line <73>NOOP string Bob2 -Line <73>NOOP number -Line <73>NOOP parac -Line <73>NOOP and -Line <73>NOOP name foodCount2 -Line <73>NOOP number -Line <73>NOOP equal -Line <73>NOOP number 1.78 +Line <73>NOOP tab +Line <73>NOOP tab +Line <73>NOOP string This is getting weird Line <73>NOOP newline Line <74>NOOP tab Line <74>NOOP tab -Line <74>NOOP string This Block +Line <74>NOOP string Hi Line <74>NOOP newline Line <75>NOOP tab -Line <75>NOOP name else +Line <75>ELIF control +Line <75>NOOP parao +Line <75>NOOP name func2 +Line <75>NOOP parao +Line <75>NOOP number 321 +Line <75>NOOP parac +Line <75>NOOP not +Line <75>NOOP equal +Line <75>NOOP name name2 +Line <75>NOOP bracketo +Line <75>NOOP number 1 +Line <75>NOOP bracketc +Line <75>NOOP or +Line <75>NOOP true +Line <75>NOOP equal +Line <75>NOOP equal +Line <75>NOOP string Bob2 +Line <75>NOOP number +Line <75>NOOP parac +Line <75>NOOP and +Line <75>NOOP name foodCount2 +Line <75>NOOP number +Line <75>NOOP equal +Line <75>NOOP number 1.78 Line <75>NOOP newline Line <76>NOOP tab Line <76>NOOP tab -Line <76>NOOP string That Block +Line <76>NOOP string This Block Line <76>NOOP newline Line <77>NOOP tab -Line <77>NOOP string ah this is why no pop +Line <77>NOOP name else Line <77>NOOP newline +Line <78>NOOP tab +Line <78>NOOP tab +Line <78>NOOP string That Block Line <78>NOOP newline -Line <79>NOOP bracketo -Line <79>NOOP name Bob -Line <79>NOOP colon -Line <79>NOOP name char -Line <79>NOOP bracketc +Line <79>NOOP tab +Line <79>NOOP string ah this is why no pop Line <79>NOOP newline -Line <80>NOOP tab -Line <80>NOOP name age -Line <80>NOOP equal -Line <80>NOOP number 24 Line <80>NOOP newline -Line <81>NOOP tab -Line <81>NOOP name money -Line <81>NOOP equal -Line <81>NOOP number 100 +Line <81>NOOP bracketo +Line <81>NOOP name Bob +Line <81>NOOP colon +Line <81>NOOP name char +Line <81>NOOP bracketc Line <81>NOOP newline Line <82>NOOP tab +Line <82>NOOP name age +Line <82>NOOP equal +Line <82>NOOP number 24 Line <82>NOOP newline -Line <83>NOOP bracketo -Line <83>NOOP name test -Line <83>NOOP colon -Line <83>NOOP name env -Line <83>NOOP bracketc +Line <83>NOOP tab +Line <83>NOOP name money +Line <83>NOOP equal +Line <83>NOOP number 100 Line <83>NOOP newline Line <84>NOOP tab -Line <84>NOOP string test Line <84>NOOP newline +Line <85>NOOP bracketo +Line <85>NOOP name test +Line <85>NOOP colon +Line <85>NOOP name env +Line <85>NOOP bracketc Line <85>NOOP newline -Line <86>NOOP bracketo -Line <86>NOOP name newblock -Line <86>NOOP colon -Line <86>NOOP name function -Line <86>NOOP parao -Line <86>NOOP parac -Line <86>NOOP bracketc +Line <86>NOOP tab +Line <86>NOOP string test Line <86>NOOP newline -Line <87>NOOP tab -Line <87>NOOP string Test #2 -Line <87>NOOP number Line <87>NOOP newline -Line <88>NOOP tab -Line <88>NOOP string Does it parse this part properly? +Line <88>NOOP bracketo +Line <88>NOOP name newblock +Line <88>NOOP colon +Line <88>NOOP name function +Line <88>NOOP parao +Line <88>NOOP parac +Line <88>NOOP bracketc Line <88>NOOP newline -Line <90>NOOP eof +Line <89>NOOP tab +Line <89>NOOP string Test #2 +Line <89>NOOP number +Line <89>NOOP newline +Line <90>NOOP tab +Line <90>NOOP string Does it parse this part properly? +Line <90>NOOP newline +Line <92>NOOP eof diff --git a/DMS/test.dms b/DMS/test.dms index be19a05..6e03b04 100644 --- a/DMS/test.dms +++ b/DMS/test.dms @@ -1,87 +1,94 @@ entry main enable warnings +disable omniscient //enable debugging //loadfile "loadtest.dms" version 1.2 using extendedDefine - +[default:char] + // The default stats for all characters. + money = 0 [Ryan:char] age = 21 money = 1000 + // Inside a character block this syntax defines animation/image file for an emotion + calm: "./path/to/file" + excited: "./path/to/file" [step:function(a,b,c)] "Testing..." d = (100 + b) / c + e = "somestring" e = nil - f = true g = false return d +[inventory:env] + slot1 = "" + slot2 = "" + slot3 = "" + slot4 = "" + slot5 = "" + slot6 = "" + slot7 = "" + slot8 = "" + [main] - "This works!" - "What's up" - - Ryan "Hello \"how\" are you doing?" // this is a comment - Bob "I'm good you?" - + Ryan: "This works!" + DEBUG "What's up" // Debug lines are removed when debug mode is disabled + Ryan: + speed 100% + calm "Hello Bob, " + wait 0.455 + excited "how are you doing?" + // Becomes: Hello Bob, how are you doing? + tester = "Hello" - food = 3 - - hi = {1,2,3} - - list = {{1,2+food,hi[3]},true,tester,123,"This is a string!",false, {3,2,1}} a = list[1] hungry = (-2+4-((5*5)/sqrt(144+5)))^2*2+2 list[1] = "Hello" - var1,var2 = func(1,"string", 2+5) + var1 = func(1,"string", 2+5) a = 100 + func(1,"string", 2+5) + 100 func(1,"string", 2+5) ::label:: //Hello im testing stuff - CHOICE "Pick one:" + if statment then + "test" + elseif statement then + "test" + if statement then + "test" + "test" + if statement then + "test" + else + "test" + elseif statement then + "test" + else + "test" + + goto "somewhere" + jump "overhere" + + CHOICE "Pick one:" { "first" func() "second" func() "third" func() "forth" func() + "fifth" goto "here" + "sixth" goto name + "sevinth" jump "there" + "eight" jump name + } - for x = 1,10 - for y = 1,10,1 - for z = 1,10 - "test" - "$x$ $y$ $z$" - test = true - test2 = false - - count = 0 - - while count != 100 - count++; - "Count = $count$" - - if (func(123)!=name[1] or true == "Bob") and foodCount >= 10.34 - "test=true or test2=false!" - "help me" - if cool == true - "We are here" - "Nested if" - elseif food >= 21 - "This is getting weird" - "Hi" - elseif (func2(321)!=name2[1] or true == "Bob2") and foodCount2 >= 1.78 - "This Block" - else - "That Block" - "ah this is why no pop" [Bob:char] age = 24 money = 100 - -[test:env] - "test" [newblock:function()] "Test #2" diff --git a/DMS/token.h b/DMS/token.h index 2c43c38..ef6e6d9 100644 --- a/DMS/token.h +++ b/DMS/token.h @@ -38,6 +38,7 @@ namespace dms::tokens { eof, ret, gotoo, + jump, nil };//stream, t_vec, line, isNum, buffer struct token { @@ -95,6 +96,7 @@ namespace dms::tokens { "eof", "ret", "gotoo", + "jump", "nil" }; out << "Line <" << c.line_num << ">" << codes::list[c.raw] << " " << temp1[c.type] << " \t\t " << c.name; diff --git a/Debug/DMS.exe b/Debug/DMS.exe index f7e6290..aac7cdd 100644 Binary files a/Debug/DMS.exe and b/Debug/DMS.exe differ diff --git a/Debug/DMS.ilk b/Debug/DMS.ilk index 883ffbf..373e82a 100644 Binary files a/Debug/DMS.ilk and b/Debug/DMS.ilk differ diff --git a/Debug/DMS.pdb b/Debug/DMS.pdb index 43a4769..e7e5f6f 100644 Binary files a/Debug/DMS.pdb and b/Debug/DMS.pdb differ