diff --git a/DMS/Character.h b/DMS/Character.h index 7622d00..dda4029 100644 --- a/DMS/Character.h +++ b/DMS/Character.h @@ -7,6 +7,7 @@ namespace dms { struct character : enviroment { bool seen = false; double spd = 100; + bool fullname = true; std::unordered_map paths; std::string getName(); }; diff --git a/DMS/DMS.cpp b/DMS/DMS.cpp index b641f58..5f1ca91 100644 --- a/DMS/DMS.cpp +++ b/DMS/DMS.cpp @@ -1,5 +1,5 @@ #include "dms.h" -#include +//#include #include using namespace dms; typedef void(*FNPTR)(); diff --git a/DMS/DMS.vcxproj b/DMS/DMS.vcxproj index 36c5bd0..0494afa 100644 --- a/DMS/DMS.vcxproj +++ b/DMS/DMS.vcxproj @@ -119,6 +119,8 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 + Disabled + Speed Console @@ -134,7 +136,7 @@ NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 - MaxSpeed + MinSpace Console diff --git a/DMS/LineParserMatchProcess.cpp b/DMS/LineParserMatchProcess.cpp index 1e871df..a593007 100644 --- a/DMS/LineParserMatchProcess.cpp +++ b/DMS/LineParserMatchProcess.cpp @@ -526,8 +526,10 @@ namespace dms { } else if (tempstream.match(tokens::newline)) { tempstream.next(); - //badSymbol(stream); - //return false; + } + else { + badSymbol(&tempstream); + return false; } } diff --git a/DMS/codes.cpp b/DMS/codes.cpp index 6e32068..8203645 100644 --- a/DMS/codes.cpp +++ b/DMS/codes.cpp @@ -46,5 +46,6 @@ const std::string dms::codes::list[] = { "LIST", "LINE", "HALT", - "FILE" + "FILE", + "GC" }; \ No newline at end of file diff --git a/DMS/codes.h b/DMS/codes.h index 4e3b644..43b6191 100644 --- a/DMS/codes.h +++ b/DMS/codes.h @@ -48,7 +48,8 @@ namespace dms::codes { LIST, LINE, HALT, - FILE + FILE, + GC }; extern const std::string list[]; static bool isControl(const op code) { diff --git a/DMS/dms_state.cpp b/DMS/dms_state.cpp index d9cfc14..9ac3d0b 100644 --- a/DMS/dms_state.cpp +++ b/DMS/dms_state.cpp @@ -19,7 +19,6 @@ namespace dms { } } - c->opcode = codes::JUMP; if (entry != "$undefined") c->args.push(buildValue(entry)); @@ -107,6 +106,7 @@ namespace dms { else utils::print("> so we have a variable"); // This print should be a reminder for me to do something about this. (*mem)[var->s->getValue()] = val; + return true; } } void dms_state::dump(bool print) { @@ -124,7 +124,10 @@ namespace dms { chunks.insert_or_assign(s, c); } void dms_state::push_error(errors::error err) { - if (isEnabled("debugging")) { + if (err.linenum != 0) { + std::cout << err.err_msg << " On Line <" << err.linenum << ">" << std::endl; + } + else if (isEnabled("debugging")) { std::cout << err.err_msg << " On Line <" << cur_line << ">" << std::endl; } else { diff --git a/DMS/dms_state_interpret.cpp b/DMS/dms_state_interpret.cpp index 057f17e..d0a0bc1 100644 --- a/DMS/dms_state_interpret.cpp +++ b/DMS/dms_state_interpret.cpp @@ -55,6 +55,7 @@ namespace dms { else { if (blockExists(cha)) { character* cc = new character; + cc->fullname = isEnabled("fullname"); cc->set("fname", buildValue(cha)); cc->set("lname", buildValue("")); cc->set("unknown", buildValue("Unknown")); @@ -112,6 +113,10 @@ namespace dms { return run("$INIT",&memory); } bool dms_state::run(std::string ent, std::unordered_map* mem) { + if (stop) { + exitcode = 1; + return false; + } codes::op code; cmd* c = nullptr; bool halt = false; @@ -169,6 +174,36 @@ namespace dms { } return true; break; + case INDX: + { + value* assn = c->args.args[0]; + value* env = c->args.args[1]; + value* indx = c->args.args[2]->resolve(*mem); + if (env->type == datatypes::block && blockExists(env->getPrintable())) { // If this is a block let's handle this + enviroment* e = nullptr; + if (enviroments.count(env->getPrintable())) { + e = enviroments[env->getPrintable()]; + } + else if (characters.count(env->getPrintable())) { + e = characters[env->getPrintable()]; + } + assign(mem, assn, e->values[indx->getPrintable()]); + } + else if (env->type == datatypes::env) { + if (indx->type == datatypes::number) { + assign(mem, assn, env->e->getValue(indx)); + } + else { + push_error(errors::error{ errors::invalid_type ,concat("Expected a number value got ",datatype[indx->type]) }); + return false; + } + } + else if (env->type == datatypes::custom) { + assign(mem, assn, env->c->Index(indx)); + // Call the method within the custom data + } + } + break; case LIST: //We need to create an enviroment value then set that { diff --git a/DMS/dump.bin b/DMS/dump.bin index c9421b3..d26b7a2 100644 Binary files a/DMS/dump.bin and b/DMS/dump.bin differ diff --git a/DMS/dump.txt b/DMS/dump.txt index 893c2d4..3b399d2 100644 --- a/DMS/dump.txt +++ b/DMS/dump.txt @@ -71,22 +71,11 @@ Line <21> name test Line <21> equal = Line <21> name Bob Line <21> bracketo [ -Line <21> name a_test -Line <21> parao ( -Line <21> cbracketo { -Line <21> number 4 -Line <21> seperator , -Line <21> name hi -Line <21> bracketo [ -Line <21> string testing -Line <21> bracketc ] -Line <21> seperator , -Line <21> number 6 -Line <21> cbracketc } -Line <21> parac ) +Line <21> string fname Line <21> bracketc ] Line <21> newline Line <21> newline +Line <22> string `Bob`'s First Name is: `test` Line <22> newline Line <22> newline Line <23> newline diff --git a/DMS/test.dms b/DMS/test.dms index 05b31f7..3375ca3 100644 --- a/DMS/test.dms +++ b/DMS/test.dms @@ -18,8 +18,8 @@ using extendedDefine "how are `inv:slot2` you doing?" } - test = Bob[a_test({4,hi["testing"],6})] - + test = Bob["fname"] + "`Bob`'s First Name is: `test`" //Ryan:setNickname(Bob,"Bobby") // Not yet implemeted! Ryan: { diff --git a/DMS/value.cpp b/DMS/value.cpp index d783b60..d175bbf 100644 --- a/DMS/value.cpp +++ b/DMS/value.cpp @@ -11,7 +11,7 @@ namespace dms { // At the end we actually delete them! } value* value::resolve(std::unordered_map memory) { - if (type == datatypes::variable) { + if (type == datatypes::variable && this!=memory[this->s->getValue()]) { return memory[s->getValue()]->resolve(memory); // Variable types return the value } return this; @@ -101,7 +101,7 @@ namespace dms { } } else { - temp << v->getPrintable(); + temp << v->resolve(state->memory)->getPrintable(); } } else {