diff --git a/DMS/Character.h b/DMS/Character.h index eefa71a..7622d00 100644 --- a/DMS/Character.h +++ b/DMS/Character.h @@ -2,16 +2,12 @@ #include #include #include "value.h" +#include "enviroment.h" namespace dms { - struct character { - std::string fname = ""; - std::string lname = ""; - std::string unknown = "Unknown"; - std::string nickname = ""; + struct character : enviroment { bool seen = false; double spd = 100; std::unordered_map paths; - std::unordered_map values; std::string getName(); }; } \ No newline at end of file diff --git a/DMS/DMS.cpp b/DMS/DMS.cpp index b839caf..6dd3c35 100644 --- a/DMS/DMS.cpp +++ b/DMS/DMS.cpp @@ -1,28 +1,11 @@ #include "dms.h" #include using namespace dms; -// You can use your own choice handler! -class myHandler : public Handler { - uint8_t handleChoice(dms_state* state, std::string prompt, std::vector args) const override { - std::string pos; - for (size_t i = 0; i < args.size(); i++) - std::cout << i << ": " << args[i] << std::endl; - std::cout << prompt << " "; - std::cin >> pos; - return std::stoi(pos) - 1; - } -}; int main() { LineParser parser = LineParser("test.dms"); dms_state* state = parser.Parse(); - try { - //state->setHandler(new myHandler); - } - catch (std::exception& e) { - std::cout << e.what() << '\n'; - return -1; - } state->dump(); state->run(); + utils::print("Exitcode: ",state->exitcode); } \ No newline at end of file diff --git a/DMS/DMS.vcxproj b/DMS/DMS.vcxproj index dd463cb..6a11778 100644 --- a/DMS/DMS.vcxproj +++ b/DMS/DMS.vcxproj @@ -133,6 +133,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp17 Console diff --git a/DMS/Handlers.cpp b/DMS/Handlers.cpp index f542385..ac8421f 100644 --- a/DMS/Handlers.cpp +++ b/DMS/Handlers.cpp @@ -20,22 +20,26 @@ namespace dms { bool Handler::handleSpeaker(dms_state* state, character* speaker) const { if (speaker == nullptr) return false; // Something went wrong and we pushed the error! - if (speaker->seen) { - if (speaker->lname != "") { - utils::write(speaker->fname, " ", speaker->lname, ": "); - } - else { - utils::write(speaker->fname, ": "); - } - } - else { - utils::write(speaker->unknown, ": "); - speaker->seen = true; - } + utils::write(speaker->getName(), ": "); + return true; + } + + bool Handler::handleMessageDisplay(dms_state* state, std::string msg) const { + utils::write(msg); + return true; + } + + bool Handler::handleMessageAppend(dms_state* state, std::string msg) const { + utils::write(msg); + return true; } // Simple one conn event bool Handler::OnSpeakerCreated(dms_state* state, character* chara) const { return true; } + + bool Handler::OnStateInit(dms_state* state) const { + return true; + } } \ No newline at end of file diff --git a/DMS/Handlers.h b/DMS/Handlers.h index ec284c8..031a334 100644 --- a/DMS/Handlers.h +++ b/DMS/Handlers.h @@ -8,9 +8,12 @@ namespace dms { { virtual uint8_t handleChoice(dms_state* state, std::string prompt, std::vector args) const; virtual bool handleSpeaker(dms_state* state, character* chara) const; + virtual bool handleMessageDisplay(dms_state* state, std::string msg) const; + virtual bool handleMessageAppend(dms_state* state, std::string msg) const; //virtual bool manageMessage(dms_state* state, value* msg) const; // Simple Events: only one connector! virtual bool OnSpeakerCreated(dms_state* state, character* chara) const; + virtual bool OnStateInit(dms_state* state) const; }; } diff --git a/DMS/LineParser.h b/DMS/LineParser.h index 7a4c2a5..a1a4a24 100644 --- a/DMS/LineParser.h +++ b/DMS/LineParser.h @@ -72,6 +72,7 @@ namespace dms { bool match_process_IFFF(tokenstream* stream); bool match_process_assignment(tokenstream* stream); bool match_process_list(tokenstream* stream, value* v = nullptr); + bool match_process_wait(tokenstream* stream); bool match_process_standard(tokenstream* stream, value* v = nullptr); // All types that are matchable are handled here! diff --git a/DMS/LineParserMatchProcess.cpp b/DMS/LineParserMatchProcess.cpp index 097603c..9600f3c 100644 --- a/DMS/LineParserMatchProcess.cpp +++ b/DMS/LineParserMatchProcess.cpp @@ -565,6 +565,7 @@ namespace dms { } bool LineParser::match_process_exit(tokenstream* stream) { if (stream->match(tokens::exit)) { + stream->next(); cmd* c = new cmd; c->opcode = codes::EXIT; if (stream->match(tokens::number) || stream->match(tokens::name)) { @@ -583,11 +584,26 @@ namespace dms { bool LineParser::match_process_IFFF(tokenstream* stream) { return false; // TODO finish this } - void reset(value*& l,codes::op& op, value*& r) { + + bool LineParser::match_process_wait(tokenstream* stream) { + if (stream->match(tokens::name, tokens::number)) { + if (stream->peek().name == "wait") { + stream->next(); + buildWait(std::stod(stream->next().name)); + } + else { + return false; + } + } + return false; + } + + void reset(value*& l, codes::op& op, value*& r) { l = nullptr; op = codes::NOOP; r = nullptr; } + bool LineParser::match_process_expression(tokenstream* stream, value* v) { // I will have to consume for this to work so we need to keep track of what was incase we return false! stream->store(current_chunk); diff --git a/DMS/LineParserParse.cpp b/DMS/LineParserParse.cpp index 2d91e1f..9dda2e5 100644 --- a/DMS/LineParserParse.cpp +++ b/DMS/LineParserParse.cpp @@ -321,27 +321,7 @@ namespace dms { // Tokens build let's parse tokenizer(state, t_vec); if (isFirst) { - cmd* c = new cmd; - for (const auto& [key, val] : state->chunks) { - if (val->type == blocktype::bt_character) { - value* v = buildVariable(); - v->set(buildString(key)); - v->type = datatypes::block; - c->opcode = codes::ASGN; - c->args.push(buildVariable(key)); - c->args.push(v); - state->chunks["$INIT"]->addCmd(c); - c = new cmd; - } - } - - - c->opcode = codes::JUMP; - if (state->entry != "$undefined") - c->args.push(buildValue(state->entry)); - else - c->args.push(buildValue(state->chunks.begin()->first)); - state->chunks["$INIT"]->addCmd(c); + state->init(); } return state; } @@ -374,7 +354,6 @@ namespace dms { current_chunk->addCmd(c); } while (stream->peek().type != tokens::eof) { - //print(stream->peek()); debugInvoker(stream); if (current.type == tokens::flag) { temp = stream->next(tokens::newline); @@ -518,7 +497,9 @@ namespace dms { match_process_assignment(stream); match_process_debug(stream); match_process_goto(stream); - + + match_process_exit(stream); + match_process_wait(stream); match_process_jump(stream); current = stream->next(); } diff --git a/DMS/character.cpp b/DMS/character.cpp index 6230760..a2d6427 100644 --- a/DMS/character.cpp +++ b/DMS/character.cpp @@ -2,17 +2,17 @@ #include "utils.h" namespace dms { std::string character::getName() { - if (nickname != "") { - return nickname; + if (values.count("nickname")) { + return values["nickname"]->getPrintable(); } - if (seen && lname !="") { - return utils::concat(fname," ", lname); + if (seen && values.count("lname")) { + return utils::concat(values["fname"]->getPrintable()," ", values["lname"]->getPrintable()); } else if (seen) { - return utils::concat(fname); + return utils::concat(values["fname"]->getPrintable()); } else { - return unknown; + return values["unknown"]->getPrintable(); } } } \ No newline at end of file diff --git a/DMS/dms_state.cpp b/DMS/dms_state.cpp index b08edb6..539a5f2 100644 --- a/DMS/dms_state.cpp +++ b/DMS/dms_state.cpp @@ -1,6 +1,34 @@ #include "dms_state.h" #include "Handlers.h" namespace dms { + void dms_state::init() { + if (init_init) + return; + init_init = true; + cmd* c = new cmd; + for (const auto& [key, val] : chunks) { + if (val->type == blocktype::bt_character) { + value* v = buildVariable(); + v->set(buildString(key)); + v->type = datatypes::block; + c->opcode = codes::ASGN; + c->args.push(buildVariable(key)); + c->args.push(v); + chunks["$INIT"]->addCmd(c); + c = new cmd; + } + } + + + c->opcode = codes::JUMP; + if (entry != "$undefined") + c->args.push(buildValue(entry)); + else + c->args.push(buildValue(chunks.begin()->first)); + chunks["$INIT"]->addCmd(c); + if (!handler->OnStateInit(this)) + stop = true; + } dms_state::dms_state() { // We should define the defaults for the enables enables.insert_or_assign("leaking",false); @@ -56,6 +84,14 @@ namespace dms { } outputFile.close(); } + bool dms_state::hasError() { + return stop; + } + + bool dms_state::Inject(std::string var, value* val) { + return false; + } + bool dms_state::assign(value* var, value* val) { if (memory.count(var->s->getValue()) == 0) { memory.insert_or_assign(var->s->getValue(), val); diff --git a/DMS/dms_state.h b/DMS/dms_state.h index 605661c..a21f733 100644 --- a/DMS/dms_state.h +++ b/DMS/dms_state.h @@ -12,23 +12,26 @@ #include #include #include "Character.h" +#include "enviroment.h" namespace dms { + struct Handler; struct dms_state { - void* handler = nullptr; + Handler* handler = nullptr; bool hasFirst = false; std::unordered_map memory; std::vector garbage; std::map chunks; std::map characters; + std::map enviroments; std::map labels; std::string entry = "$undefined"; std::map enables; std::size_t cur_line=0; + int exitcode = 0; const double Iversion = 1.0; double Sversion; // The version of errors::error err; - bool stop = false; dms_state(); void dump(errors::error err); @@ -37,14 +40,18 @@ namespace dms { void push_warning(errors::error err); void push_chunk(std::string s, chunk* c); bool run(std::string instance); - double version=1.0; + double version = 1.0; void enable(std::string flag); void disable(std::string flag); bool isEnabled(std::string flag); - void setHandler(void* hand); + + void setHandler(Handler* hand); + + bool Inject(std::string var, value* val); // Gets or creates a character character* getCharacter(std::string c); + enviroment* getEnviroment(std::string c); bool assign(value* var, value* val); size_t seek(std::string label,std::vector cmds ,codes::op code, size_t pos); @@ -52,9 +59,15 @@ namespace dms { bool blockExists(std::string bk_name); bool typeAssert(value* val, datatypes type); bool run(); + // This is called once and once only. Dynamically loading code is not a thing! + void init(); + + bool hasError(); private: // From what I gathered //std::mutex memory_mutex; + bool stop = false; + bool init_init = false; void init(chunk* chunk, size_t &pos,size_t &max, std::vector& cmds); }; } diff --git a/DMS/dms_state_interpret.cpp b/DMS/dms_state_interpret.cpp index 5ecc702..ce02cd7 100644 --- a/DMS/dms_state_interpret.cpp +++ b/DMS/dms_state_interpret.cpp @@ -8,9 +8,12 @@ using namespace dms::exceptions; using namespace dms::codes; namespace dms { // This is a pointer to a choicehandler! dms_state and utils have codepedencies, so I have to do this. - void dms_state::setHandler(void* hand) { + void dms_state::setHandler(Handler* hand) { this->handler = hand; } + enviroment* dms_state::getEnviroment(std::string c) { + return nullptr; + } character* dms_state::getCharacter(std::string cha) { if (characters.count(cha)) { return characters[cha]; @@ -18,7 +21,8 @@ namespace dms { else { if (blockExists(cha)) { character* cc = new character; - cc->fname = cha; + cc->values.insert_or_assign("fname", buildValue(cha)); + cc->values.insert_or_assign("lname", buildValue("")); codes::op code; cmd* c = nullptr; bool halt = false; @@ -49,19 +53,19 @@ namespace dms { if (c->args.args[0]->s->getValue() == "fname") { if(!typeAssert(c->args.args[1],datatypes::string)) return nullptr; - cc->fname = c->args.args[1]->s->getValue(); + cc->values.insert_or_assign("fname", c->args.args[1]); } - else if (c->args.args[0]->s->getValue() == "lname" && c->args.args[1]->type == datatypes::string) { + else if (c->args.args[0]->s->getValue() == "lname") { if (!typeAssert(c->args.args[1], datatypes::string)) return nullptr; - cc->lname = c->args.args[1]->s->getValue(); + cc->values.insert_or_assign("lname", c->args.args[1]); } - else if (c->args.args[0]->s->getValue() == "unknown" && c->args.args[1]->type == datatypes::string) { + else if (c->args.args[0]->s->getValue() == "unknown") { if (!typeAssert(c->args.args[1], datatypes::string)) return nullptr; - cc->unknown = c->args.args[1]->s->getValue(); + cc->values.insert_or_assign("unknown", c->args.args[1]); } - else if (c->args.args[0]->s->getValue() == "known" && c->args.args[1]->type == datatypes::boolean) { + else if (c->args.args[0]->s->getValue() == "known") { if (!typeAssert(c->args.args[1], datatypes::boolean)) return nullptr; cc->seen = c->args.args[1]->b->getValue(); @@ -81,7 +85,7 @@ namespace dms { } characters.insert_or_assign(cha, cc); // Call Character event! - (*(Handler*)handler).OnSpeakerCreated(this,cc); + handler->OnSpeakerCreated(this,cc); return cc; } else { @@ -165,6 +169,12 @@ namespace dms { // How we add modules into the code. This is the code that actually loads that data! break; // Flags handled + case EXIT: + if (c->args.args.size()) { + exitcode = c->args.args[0]->n->getValue(); + } + return true; + break; case LIST: //We need to create an enviroment value then set that { @@ -186,6 +196,9 @@ namespace dms { std::this_thread::sleep_for(std::chrono::milliseconds(700)); std::cout << std::endl; break; + case WAIT: + std::this_thread::sleep_for(std::chrono::milliseconds((int)(c->args.args[0]->n->getValue()*1000))); + break; case DSPD: if (speaker == nullptr) { push_error(errors::error{ errors::unknown ,utils::concat("A call to set speaker speed, but a speaker has not been defined!") }); @@ -199,7 +212,7 @@ namespace dms { //Because we are using void* we must cast our pointers if (characterExists(c->args.args[0]->s->getValue())){ speaker = getCharacter(c->args.args[0]->s->getValue()); - if (!(*(Handler*)handler).handleSpeaker(this, speaker)) + if (!handler->handleSpeaker(this, speaker)) return false; } else { @@ -208,10 +221,12 @@ namespace dms { } break; case APND: - utils::write(c->args.args[0]->s->getValue(this)); + if (!handler->handleMessageAppend(this, c->args.args[0]->s->getValue(this))) + return false; break; case DISP: - utils::write(c->args.args[0]->s->getValue(this)); + if (!handler->handleMessageDisplay(this, c->args.args[0]->s->getValue(this))) + return false; break; case ASGN: assign(c->args.args[0], c->args.args[1]); @@ -229,7 +244,7 @@ namespace dms { std::string fn = c->args.args[1]->s->getValue(); for (size_t i = 2; i < c->args.args.size(); i++) args.push_back(c->args.args[i]->resolve(memory)->s->getValue()); - size_t npos = (*(Handler*)handler).handleChoice(this, prompt, args); + size_t npos = handler->handleChoice(this, prompt, args); size_t nnpos = seek(concat("CHOI_", fn, "_", npos),cmds,LABL,npos); if (!nnpos) { push_error(errors::error{ errors::choice_unknown ,utils::concat("Unknown choice!") }); diff --git a/DMS/dump.bin b/DMS/dump.bin index 45a5e46..5cf501d 100644 Binary files a/DMS/dump.bin and b/DMS/dump.bin differ diff --git a/DMS/dump.txt b/DMS/dump.txt index 667625e..dca5448 100644 --- a/DMS/dump.txt +++ b/DMS/dump.txt @@ -52,104 +52,233 @@ Line <15> newline Line <15> newline Line <16> name excited Line <16> colon : -Line <16> string Hello `Ryan:fname`! +Line <16> string Hello Mr. `Ryan:lname`, Line <16> newline Line <16> newline -Line <17> name wait -Line <17> number 200 +Line <17> string how are you doing? Line <17> newline Line <17> newline -Line <18> string How are you doing? I hear you have $`Ryan:money` in your account, nice! +Line <18> cbracketc } Line <18> newline Line <18> newline -Line <19> cbracketc } Line <19> newline Line <19> newline Line <20> newline -Line <20> newline -Line <21> name Ryan -Line <21> colon : -Line <21> cbracketo { Line <21> newline Line <21> newline -Line <22> string Hey Bob I'm good how are you? +Line <22> name Ryan +Line <22> colon : +Line <22> cbracketo { Line <22> newline Line <22> newline -Line <23> cbracketc } +Line <23> string Hey `Bob`, I'm good how are you? Line <23> newline Line <23> newline +Line <24> cbracketc } Line <24> newline -Line <24> newline -Line <25> name Bob -Line <25> colon : -Line <25> string I am great thanks! Line <25> newline Line <25> newline +Line <26> string Waiting ... Line <26> newline Line <26> newline -Line <27> control -Line <27> string What do you want to do? -Line <27> cbracketo { Line <27> newline Line <27> newline -Line <28> string option 1 -Line <28> name test2 -Line <28> parao ( -Line <28> string testing -Line <28> seperator , -Line <28> cbracketo { +Line <28> exit Line <28> number 1 -Line <28> seperator , -Line <28> number 2 -Line <28> seperator , -Line <28> number 3 -Line <28> cbracketc } -Line <28> parac ) Line <28> newline Line <28> newline -Line <29> string option 2 -Line <29> jump -Line <29> string test Line <29> newline Line <29> newline -Line <30> string option 3 -Line <30> jump -Line <30> name there +Line <30> name Bob +Line <30> colon : +Line <30> cbracketo { Line <30> newline Line <30> newline -Line <31> string option 4 -Line <31> gotoo -Line <31> string o3 +Line <31> string I am great thanks! I want to show you that I can count! + Line <31> newline Line <31> newline -Line <32> string option 5 -Line <32> gotoo -Line <32> name here +Line <32> name wait +Line <32> number 1 Line <32> newline Line <32> newline -Line <33> string option 6 -Line <33> name test -Line <33> parao ( -Line <33> string here -Line <33> parac ) +Line <33> string 1 + Line <33> newline Line <33> newline -Line <34> cbracketc } +Line <34> name wait +Line <34> number 1 Line <34> newline Line <34> newline +Line <35> string 2 + Line <35> newline Line <35> newline -Line <36> bracketo [ -Line <36> name test -Line <36> bracketc ] +Line <36> name wait +Line <36> number 1 Line <36> newline Line <36> newline -Line <37> name Ryan -Line <37> colon : -Line <37> string We are here now! +Line <37> string 3 + Line <37> newline Line <37> newline -Line <38> Line <1> newline +Line <38> name wait +Line <38> number 1 +Line <38> newline +Line <38> newline +Line <39> string 4 + +Line <39> newline +Line <39> newline +Line <40> name wait +Line <40> number 1 +Line <40> newline +Line <40> newline +Line <41> string 5 + +Line <41> newline +Line <41> newline +Line <42> cbracketc } +Line <42> newline +Line <42> newline +Line <43> newline +Line <43> newline +Line <44> control +Line <44> string What do you want to do? +Line <44> cbracketo { +Line <44> newline +Line <44> newline +Line <45> string option 1 +Line <45> name test2 +Line <45> parao ( +Line <45> string testing +Line <45> seperator , +Line <45> cbracketo { +Line <45> number 1 +Line <45> seperator , +Line <45> number 2 +Line <45> seperator , +Line <45> number 3 +Line <45> cbracketc } +Line <45> parac ) +Line <45> newline +Line <45> newline +Line <46> string option 2 +Line <46> jump +Line <46> string test +Line <46> newline +Line <46> newline +Line <47> string option 3 +Line <47> jump +Line <47> name there +Line <47> newline +Line <47> newline +Line <48> string option 4 +Line <48> gotoo +Line <48> string o3 +Line <48> newline +Line <48> newline +Line <49> string option 5 +Line <49> gotoo +Line <49> name here +Line <49> newline +Line <49> newline +Line <50> string option 6 +Line <50> name test +Line <50> parao ( +Line <50> string here +Line <50> parac ) +Line <50> newline +Line <50> newline +Line <51> cbracketc } +Line <51> newline +Line <51> newline +Line <52> newline +Line <52> newline +Line <53> bracketo [ +Line <53> name test +Line <53> bracketc ] +Line <53> newline +Line <53> newline +Line <54> name Ryan +Line <54> colon : +Line <54> string We are here now! +Line <54> newline +Line <54> newline +Line <55> pipe | +Line <55> string This continues from the last message! +Line <55> newline +Line <55> newline +Line <56> pipe | +Line <56> string Keeps code readable. This does not cause a new line! +Line <56> newline +Line <56> newline +Line <57> name Ryan +Line <57> colon : +Line <57> string This does trigger a new line tho! +Line <57> newline +Line <57> newline +Line <58> string This also will cause a new line! +Line <58> newline +Line <58> newline +Line <59> newline +Line <59> newline +Line <60> bracketo [ +Line <60> name Bob +Line <60> colon : +Line <60> name char +Line <60> bracketc ] +Line <60> newline +Line <60> newline +Line <61> name fname +Line <61> equal = +Line <61> string Bob +Line <61> newline +Line <61> newline +Line <62> newline +Line <63> newline +Line <64> name unknown +Line <64> equal = +Line <64> string Some Rando +Line <64> newline +Line <64> newline +Line <65> name age +Line <65> equal = +Line <65> number 0.24 +Line <65> newline +Line <65> newline +Line <66> name money +Line <66> equal = +Line <66> number 100 +Line <66> newline +Line <66> newline +Line <67> name excited +Line <67> colon : +Line <67> string path/to/file +Line <67> newline +Line <67> newline +Line <68> newline +Line <68> newline +Line <69> bracketo [ +Line <69> name newblock +Line <69> colon : +Line <69> name function +Line <69> parao ( +Line <69> parac ) +Line <69> bracketc ] +Line <69> newline +Line <69> newline +Line <70> string Test #2 +Line <70> newline +Line <70> newline +Line <71> string Does it parse this part properly? +Line <71> newline +Line <71> newline +Line <72> string huh +Line <72> newline +Line <72> newline +Line <72> eof +Line <1> newline Line <1> newline Line <1> flag Line <1> name tests @@ -276,42 +405,42 @@ Line <25> newline Line <25> newline Line <26> name slot1 Line <26> equal = -Line <26> string +Line <26> string S1 Line <26> newline Line <26> newline Line <27> name slot2 Line <27> equal = -Line <27> string +Line <27> string S2 Line <27> newline Line <27> newline Line <28> name slot3 Line <28> equal = -Line <28> string +Line <28> string S3 Line <28> newline Line <28> newline Line <29> name slot4 Line <29> equal = -Line <29> string +Line <29> string S4 Line <29> newline Line <29> newline Line <30> name slot5 Line <30> equal = -Line <30> string +Line <30> string S5 Line <30> newline Line <30> newline Line <31> name slot6 Line <31> equal = -Line <31> string +Line <31> string S6 Line <31> newline Line <31> newline Line <32> name slot7 Line <32> equal = -Line <32> string +Line <32> string S7 Line <32> newline Line <32> newline Line <33> name slot8 Line <33> equal = -Line <33> string +Line <33> string S8 Line <33> newline Line <33> newline Line <33> eof diff --git a/DMS/enviroment.h b/DMS/enviroment.h index c1949d2..f063fb0 100644 --- a/DMS/enviroment.h +++ b/DMS/enviroment.h @@ -3,9 +3,15 @@ #include #include "value.h" namespace dms { + enum class env_type { + env, + character, + function + }; struct enviroment { std::string name=""; std::unordered_map values; + env_type type = env_type::env; bool has(std::string index); void set(std::string index, value* val); value* get(std::string index); diff --git a/DMS/test.dms b/DMS/test.dms index ffdff6d..0fcfce9 100644 --- a/DMS/test.dms +++ b/DMS/test.dms @@ -13,16 +13,33 @@ using extendedDefine "why" Bob: { speed 50 - excited: "Hello `Ryan:fname`! " - wait 200 - "How are you doing? I hear you have $`Ryan:money` in your account, nice!" + excited: "Hello Mr. `Ryan:lname`, " + "how are you doing?" } + //Ryan:setNickname(Bob,"Bobby") // Not yet implemeted! + Ryan: { - "Hey Bob I'm good how are you?" - } + "Hey `Bob`, I'm good how are you?" + } // Should display Hey Bobby, I'm good how are you? - Bob: "I am great thanks!" + "Waiting ..." + + exit 1 + + Bob: { + "I am great thanks! I want to show you that I can count!\n" + wait 1 + "1\n" + wait 1 + "2\n" + wait 1 + "3\n" + wait 1 + "4\n" + wait 1 + "5\n" + } choice "What do you want to do?" { "option 1" test2("testing",{1,2,3}) @@ -43,7 +60,7 @@ using extendedDefine [Bob:char] fname = "Bob" //known = true // defaults to false - lname = "" + //lname = "Johnson" // defaults to "" unknown = "Some Rando" age = .24 money = 100 diff --git a/DMS/token.h b/DMS/token.h index 754cafa..e774924 100644 --- a/DMS/token.h +++ b/DMS/token.h @@ -120,7 +120,8 @@ namespace dms::tokens { "pound", "dollar", "ampersand", - "nil" + "nil", + "pipe" }; out << "Line <" << c.line_num << "> " << tokenlist[c.type] << " \t\t " << c.name; return out; diff --git a/DMS/value.cpp b/DMS/value.cpp index d8d1452..363ac9f 100644 --- a/DMS/value.cpp +++ b/DMS/value.cpp @@ -41,16 +41,7 @@ namespace dms { if (v->type == datatypes::block) { if (state->getCharacter(v->s->getValue())!=nullptr) { character* cha = state->getCharacter(v->s->getValue()); - if (index == "fname") { - temp << cha->fname; - } - else if (index == "lname") { - temp << cha->lname; - } - else if (index == "nickname") { - temp << cha->nickname; - } - else if (cha->values.count(index)) { + if (cha->values.count(index)) { temp << cha->values[index]->getPrintable(); } else { @@ -285,7 +276,7 @@ namespace dms { } value* dms_env::getValue(value* ind) { if (ind->type == number) { - return ipart.at(ind->n->getValue()); + return ipart.at((int)ind->n->getValue()); } else if (ind->type == number) { return new value{}; // Return a nil value diff --git a/DMS/value.h b/DMS/value.h index c834a4a..0ba69ba 100644 --- a/DMS/value.h +++ b/DMS/value.h @@ -10,7 +10,7 @@ namespace dms { struct value; struct dms_args; extern const std::string datatype[]; - enum datatypes { nil, number, boolean, env, string, custom, variable, block }; + enum datatypes { escape, nil, number, boolean, env, string, custom, variable, block }; struct dms_number { double val; double getValue() { return val; }