From 993b9e9b4dc3a76157dc9b5d728f25bfc903bf9a Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Fri, 11 Dec 2020 00:18:56 -0500 Subject: [PATCH] Reworked a lot of stuff, need to fix what I broke --- DMS/DMS.cpp | 5 +- DMS/DMS.vcxproj | 2 +- DMS/DMS.vcxproj.filters | 2 +- DMS/dms_custom.cpp | 14 ++-- DMS/dms_state.cpp | 2 + DMS/dms_state_interpret.cpp | 9 ++- DMS/dump.bin | Bin 1192 -> 303 bytes DMS/dump.txt | 149 ++++++++++++++++-------------------- DMS/sterilizer.h | 21 ----- DMS/test.dms | 30 ++++---- DMS/value.cpp | 7 ++ DMS/value.h | 2 + DMS/wrapper.h | 23 ++++++ README.md | 1 + 14 files changed, 135 insertions(+), 132 deletions(-) delete mode 100644 DMS/sterilizer.h create mode 100644 DMS/wrapper.h diff --git a/DMS/DMS.cpp b/DMS/DMS.cpp index fdbdd0f..df5b934 100644 --- a/DMS/DMS.cpp +++ b/DMS/DMS.cpp @@ -5,7 +5,7 @@ #include #include "value.h" #include "enviroment.h" -#include "sterilizer.h" +#include "wrapper.h" //#include using namespace dms; //typedef void(*FNPTR)(); @@ -36,6 +36,9 @@ value type(void* self, dms_state* state, dms_args* args) { //} int main() { + // TODO fix disp cmd to handle the standard + + /*milliseconds ms = duration_cast( system_clock::now().time_since_epoch() ); diff --git a/DMS/DMS.vcxproj b/DMS/DMS.vcxproj index 7290bb1..69bf1f6 100644 --- a/DMS/DMS.vcxproj +++ b/DMS/DMS.vcxproj @@ -189,10 +189,10 @@ - + diff --git a/DMS/DMS.vcxproj.filters b/DMS/DMS.vcxproj.filters index f215b57..542dac8 100644 --- a/DMS/DMS.vcxproj.filters +++ b/DMS/DMS.vcxproj.filters @@ -149,7 +149,7 @@ Header Files\DMS - + Header Files\DMS\C-API diff --git a/DMS/dms_custom.cpp b/DMS/dms_custom.cpp index 0261106..649e2c4 100644 --- a/DMS/dms_custom.cpp +++ b/DMS/dms_custom.cpp @@ -17,7 +17,7 @@ namespace dms { } value dms_custom::Index(value data) { state->push_error(errors::error{ errors::unknown,"Attempting to index a non enviroment!" }); - return nullptr; + return value(); } bool dms_custom::NewIndex(value var, value val) { state->push_error(errors::error{ errors::unknown,"Attempting to create a new index on a non enviroment!" }); @@ -25,30 +25,30 @@ namespace dms { } value dms_custom::Call(dms_args* args) { state->push_error(errors::error{ errors::unknown,"Attempting to call a non function value!" }); - return nullptr; + return value(); } value dms_custom::ToString() { return value(utils::concat("Custom: ", this)); } value dms_custom::ADD(value left, value right) { state->push_error(errors::error{ errors::unknown,"Attempting to add a non number value!" }); - return nullptr; + return value(); } value dms_custom::SUB(value left, value right) { state->push_error(errors::error{ errors::unknown,"Attempting to subtract a non number value!" }); - return nullptr; + return value(); } value dms_custom::MUL(value left, value right) { state->push_error(errors::error{ errors::unknown,"Attempting to multiply a non number value!" }); - return nullptr; + return value(); } value dms_custom::DIV(value left, value right) { state->push_error(errors::error{ errors::unknown,"Attempting to divide a non number value!" }); - return nullptr; + return value(); } value dms_custom::POW(value left, value right) { state->push_error(errors::error{ errors::unknown,"Attempting to raise a non number value!" }); - return nullptr; + return value(); } value dms_custom::EQUAL(value left, value right) { return value(left.getPrintable() == right.getPrintable()); diff --git a/DMS/dms_state.cpp b/DMS/dms_state.cpp index 51405cf..7164d13 100644 --- a/DMS/dms_state.cpp +++ b/DMS/dms_state.cpp @@ -160,6 +160,8 @@ namespace dms { push_error(errors::error{ errors::unknown ,val.s }); return false; } + if(val.state==nullptr) + val.state = this; (*getMem())[var.getPrintable()] = val; return true; } diff --git a/DMS/dms_state_interpret.cpp b/DMS/dms_state_interpret.cpp index ca6b182..f5c7dfe 100644 --- a/DMS/dms_state_interpret.cpp +++ b/DMS/dms_state_interpret.cpp @@ -545,9 +545,12 @@ namespace dms { return false; break; case DISP: - //FIX STRING STER - if (!handler->handleMessageDisplay(this, c->args.args[0].s)) - return false; + { + //FIX STRING STER + value disp = c->args.args[0].resolve(this).getPrintable(); + if (!handler->handleMessageDisplay(this, c->args.args[0].s)) + return false; + } break; case ASGN: if(!assign(c->args.args[0], c->args.args[1])) { diff --git a/DMS/dump.bin b/DMS/dump.bin index 247ff62ac51bbf046ce2ddf2d0180b86b390df6f..1c3a6e8de8657095e3a04c0a6ed008997b1589f0 100644 GIT binary patch delta 69 zcmZ3%xt?i)vVL%IfVToiP-SAC0xy?~XK;W5o2Nozu0nc#ehLFn$ivYm1W5UK`nf7F V8=6e~c!`^r%g^6G04T`I1ps_?5gY&j literal 1192 zcmah|-*4JL3}&qqWk~!Fp2Twt3H|Z1hlB*0Exl9_rfDzL0Rf^VmkKUx``^#LOGt*s z_5v5%pY89n?S|v8VB|a%9k?7ouR94s9}Jls2)Ja17=!)`La)igbyOk&}X-+QHoyIRjm6y^D5T<_aN5%kIsMvaqVUCtQM))^@6zr zMv;s3uu2mlsZpOfE*P6K%LLDpmZjLg^8GsF%Oq1`>c9j4g#vTgid-kla=T5%wj~Wo z{LP;+xENd!!AkC7^CYVtid!te182^c74JIn+s9MCg+T5z8R+DPYEmBl*QQOlji`=C+ zz<AQ^Df0tQM?K;=0%>sjEi-V!?b*F>e$W2 z@@=Aah$PhV+UjQ20p*2A-jUfrO(S+AT1C3pOP adu7qp=^Ou37(zA;H$ysV&!Xr_)%p$LBlsr( diff --git a/DMS/dump.txt b/DMS/dump.txt index a282287..111713f 100644 --- a/DMS/dump.txt +++ b/DMS/dump.txt @@ -39,131 +39,112 @@ Line <12> name main Line <12> bracketc ] Line <12> newline Line <12> newline -Line <13> name num -Line <13> equal = -Line <13> number 30.0 +Line <13> name Ryan +Line <13> colon : +Line <13> string I am good Line <13> newline Line <13> newline -Line <14> name io -Line <14> dot . -Line <14> name print -Line <14> parao ( -Line <14> string ! +Line <14> name John +Line <14> colon : +Line <14> string Hi Line <14> plus + -Line <14> name num +Line <14> name Ryan Line <14> plus + -Line <14> string = -Line <14> plus + -Line <14> name fact -Line <14> parao ( -Line <14> name num -Line <14> parac ) -Line <14> parac ) +Line <14> string how are you? Line <14> newline Line <14> newline Line <15> newline Line <15> newline -Line <16> bracketo [ -Line <16> name fact -Line <16> colon : -Line <16> name function -Line <16> parao ( -Line <16> name n -Line <16> parac ) -Line <16> bracketc ] Line <16> newline Line <16> newline -Line <17> name if -Line <17> parao ( -Line <17> name n -Line <17> equal = -Line <17> equal = -Line <17> number 1 -Line <17> parac ) Line <17> newline Line <17> newline -Line <18> ret -Line <18> number 1 +Line <18> bracketo [ +Line <18> name John +Line <18> colon : +Line <18> name char +Line <18> bracketc ] Line <18> newline Line <18> newline -Line <19> name else +Line <19> name lname +Line <19> equal = +Line <19> string Johnson Line <19> newline Line <19> newline -Line <20> ret -Line <20> name n -Line <20> multiply * -Line <20> name fact -Line <20> parao ( -Line <20> name n -Line <20> minus - -Line <20> number 1 -Line <20> parac ) +Line <20> name age +Line <20> equal = +Line <20> number 16 Line <20> newline Line <20> newline +Line <21> name money +Line <21> equal = +Line <21> number 100000 Line <21> newline Line <21> newline -Line <22> bracketo [ -Line <22> name this -Line <22> colon : -Line <22> name function -Line <22> parao ( -Line <22> parac ) -Line <22> bracketc ] +Line <22> name known +Line <22> equal = +Line <22> true true Line <22> newline Line <22> newline -Line <23> name print -Line <23> parao ( -Line <23> string This -Line <23> parac ) Line <23> newline Line <23> newline +Line <24> bracketo [ +Line <24> name Ryan +Line <24> colon : +Line <24> name char +Line <24> bracketc ] Line <24> newline Line <24> newline -Line <25> bracketo [ -Line <25> name that -Line <25> colon : -Line <25> name function -Line <25> parao ( -Line <25> parac ) -Line <25> bracketc ] +Line <25> name lname +Line <25> equal = +Line <25> string Ward Line <25> newline Line <25> newline -Line <26> name print -Line <26> parao ( -Line <26> string That -Line <26> parac ) +Line <26> name age +Line <26> equal = +Line <26> number 24 Line <26> newline Line <26> newline +Line <27> name known +Line <27> equal = +Line <27> true true Line <27> newline Line <27> newline -Line <28> bracketo [ -Line <28> name Bob -Line <28> colon : -Line <28> name char -Line <28> bracketc ] +Line <28> name money +Line <28> equal = +Line <28> number 0 Line <28> newline Line <28> newline Line <29> newline +Line <29> newline +Line <30> bracketo [ +Line <30> name Bob +Line <30> colon : +Line <30> name char +Line <30> bracketc ] +Line <30> newline Line <30> newline Line <31> newline -Line <32> name unknown -Line <32> equal = -Line <32> string Some Random Guy Line <32> newline -Line <32> newline -Line <33> name age -Line <33> equal = -Line <33> number 0.24 Line <33> newline -Line <33> newline -Line <34> name money +Line <34> name unknown Line <34> equal = -Line <34> number 100 +Line <34> string Some Random Guy Line <34> newline Line <34> newline -Line <35> name excited -Line <35> colon : -Line <35> string path/to/file +Line <35> name age +Line <35> equal = +Line <35> number 24 Line <35> newline Line <35> newline -Line <35> eof +Line <36> name money +Line <36> equal = +Line <36> number 100 +Line <36> newline +Line <36> newline +Line <37> name excited +Line <37> colon : +Line <37> string path/to/file +Line <37> newline +Line <37> newline +Line <37> eof diff --git a/DMS/sterilizer.h b/DMS/sterilizer.h deleted file mode 100644 index b615269..0000000 --- a/DMS/sterilizer.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "value.h" -// This file converts the c++ objects into a form that c is happy with -extern "C" { - using namespace dms; - // All structs types in this file will have an s_typename infront of it - // All methods will have an sf_methodname infron of it as well - struct s_value { - datatypes type = nil; // The type of the value - unsigned int slen; // Length of string - const char* s; // Contains the string part. - uint64_t i; // The int portion of the code - double n; - void setInt(int n); // Define value as an int - void setDouble(double n); // Define value as a double - void setString(const char* s); // Define value as a string - void setBlock(const char* s); // Define value as a block - void setVariable(const char* s); // Define value as a variable - void setNil(); // Define value as nil - }; -} \ No newline at end of file diff --git a/DMS/test.dms b/DMS/test.dms index 231f359..420f60a 100644 --- a/DMS/test.dms +++ b/DMS/test.dms @@ -10,26 +10,28 @@ enable debugging version 0.2 using extendedDefine [main] - num = 30.0 - io.print("!"+num+" = " + fact(num)) - -[fact:function(n)] - if(n==1) - return 1 - else - return n * fact(n-1) - -[this:function()] - print("This") + Ryan: "I am good" + John: "Hi " + Ryan + " how are you?" -[that:function()] - print("That") + + +[John:char] + lname = "Johnson" + age = 16 + money = 100000 + known = true + +[Ryan:char] + lname = "Ward" + age = 24 + known = true + money = 0 [Bob:char] //fname = "Bob" //known = true // defaults to false //lname = "Johnson" // defaults to "" unknown = "Some Random Guy" - age = .24 + age = 24 money = 100 excited: "path/to/file" diff --git a/DMS/value.cpp b/DMS/value.cpp index 11246a5..4bc3092 100644 --- a/DMS/value.cpp +++ b/DMS/value.cpp @@ -350,6 +350,9 @@ namespace dms { } return *this; } + value value::resolve() { + return resolve(state); + } void dms_args::push(value val) { args.push_back(val); } @@ -389,6 +392,10 @@ namespace dms { return "custom"; } else if (type == block) { + if (state->characterExists(s)) { + auto cha = state->getCharacter(s); + return cha->getName(); + } return s; } else if (type == datatypes::variable) { diff --git a/DMS/value.h b/DMS/value.h index 564cb8d..25c3172 100644 --- a/DMS/value.h +++ b/DMS/value.h @@ -42,6 +42,7 @@ namespace dms { std::string s; dms_list* e = nullptr; dms_custom* c = nullptr; + dms_state* state = nullptr; value(); value(datatypes); value(char const*,datatypes); @@ -71,6 +72,7 @@ namespace dms { friend value operator/(const value& lhs, const value& rhs); friend value operator*(const value& lhs, const value& rhs); value resolve(dms_state*); + value resolve(); void nuke(); void set(value); void set(std::string str); diff --git a/DMS/wrapper.h b/DMS/wrapper.h new file mode 100644 index 0000000..879b194 --- /dev/null +++ b/DMS/wrapper.h @@ -0,0 +1,23 @@ +#pragma once +#include "enviroment.h" +// This file converts the c++ objects into a form that c is happy with +extern "C" { + using namespace dms; + // All structs types in this file will have an s_typename infront of it + // All methods will have an sf_methodname infron of it as well + struct s_value { + datatypes type = nil; // The type of the value + const char* s; // Contains the string part. + uint64_t i; // The int portion of the code + double n; + }; + void s_value_setInt(s_value& sv, int n) { sv.type = int64; sv.i = n; } // Define value as an int + void s_value_setDouble(s_value& sv, double d) { sv.type = number; sv.n = d; } // Define value as a double + void s_value_setString(s_value& sv, const char* str) { sv.type = string; sv.s = str; } // Define value as a string + void s_value_setBlock(s_value& sv, const char* str) { sv.type = block; sv.s = str; } // Define value as a block + void s_value_setVariable(s_value& sv, const char* str) { sv.type = variable; sv.s = str; } // Define value as a variable + void s_value_setNil(s_value& sv) { sv.type = nil; } // Define value as nil + struct s_enviroment { + + }; +} \ No newline at end of file diff --git a/README.md b/README.md index 51cc5ed..d92431b 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,4 @@ The Dialogue Management Script's goal is to provide a nice and simple way to hav - [ ] Finish implementing custom datatype - [ ] Speed up interperter - [ ] Finish C API for code +- [ ] Extend beginning features \ No newline at end of file