diff --git a/DMS/DMS.cpp b/DMS/DMS.cpp index 4542ee8..e171cd9 100644 --- a/DMS/DMS.cpp +++ b/DMS/DMS.cpp @@ -20,6 +20,7 @@ using namespace dms; using namespace dms::utils; int main() { - LineParser parser = LineParser("test.dms"); - parser.Parse(); + /*LineParser parser = LineParser("test.dms"); + dms_state* state = parser.Parse(); + state->dump();*/ } \ No newline at end of file diff --git a/DMS/DMS.vcxproj b/DMS/DMS.vcxproj index 81d8d24..feca9af 100644 --- a/DMS/DMS.vcxproj +++ b/DMS/DMS.vcxproj @@ -172,7 +172,34 @@ + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/DMS/DMS.vcxproj.filters b/DMS/DMS.vcxproj.filters index 1dcf68d..ddf43fc 100644 --- a/DMS/DMS.vcxproj.filters +++ b/DMS/DMS.vcxproj.filters @@ -105,4 +105,18 @@ Header Files\DMS + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DMS/Debug/DMS.log b/DMS/Debug/DMS.log index 03034fa..ff714f1 100644 --- a/DMS/Debug/DMS.log +++ b/DMS/Debug/DMS.log @@ -1,2 +1,2 @@ - LineParser.cpp - DMS.vcxproj -> C:\Users\Ryan\source\repos\DMS\Debug\DMS.exe + DMS.cpp + DMS.vcxproj -> F:\VSCWorkspace\DMS\Debug\DMS.exe diff --git a/DMS/Debug/DMS.obj b/DMS/Debug/DMS.obj index b19481c..c122251 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 2191231..7c61d14 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 acb33bb..8cabb47 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 2d93c87..d81a7ef 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/DMS.lastbuildstate b/DMS/Debug/DMS.tlog/DMS.lastbuildstate index 584141c..12e9dd0 100644 --- a/DMS/Debug/DMS.tlog/DMS.lastbuildstate +++ b/DMS/Debug/DMS.tlog/DMS.lastbuildstate @@ -1,2 +1,2 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.26.28801:TargetPlatformVersion=10.0.18362.0: -Debug|Win32|C:\Users\Ryan\source\repos\DMS\| +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|F:\VSCWorkspace\DMS\| diff --git a/DMS/Debug/DMS.tlog/link.command.1.tlog b/DMS/Debug/DMS.tlog/link.command.1.tlog index 0b26357..dc150d8 100644 Binary files a/DMS/Debug/DMS.tlog/link.command.1.tlog and b/DMS/Debug/DMS.tlog/link.command.1.tlog differ diff --git a/DMS/Debug/DMS.tlog/link.read.1.tlog b/DMS/Debug/DMS.tlog/link.read.1.tlog index 8867a7d..b04f053 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/DMS.tlog/link.write.1.tlog b/DMS/Debug/DMS.tlog/link.write.1.tlog index 4067293..46a805f 100644 Binary files a/DMS/Debug/DMS.tlog/link.write.1.tlog and b/DMS/Debug/DMS.tlog/link.write.1.tlog differ diff --git a/DMS/Debug/cmd.obj b/DMS/Debug/cmd.obj index ed2f999..1bf02e1 100644 Binary files a/DMS/Debug/cmd.obj and b/DMS/Debug/cmd.obj differ diff --git a/DMS/Debug/codes.obj b/DMS/Debug/codes.obj index fe8f3c7..9dead1c 100644 Binary files a/DMS/Debug/codes.obj and b/DMS/Debug/codes.obj differ diff --git a/DMS/Debug/dms_exceptions.obj b/DMS/Debug/dms_exceptions.obj index f984f34..9d56015 100644 Binary files a/DMS/Debug/dms_exceptions.obj and b/DMS/Debug/dms_exceptions.obj differ diff --git a/DMS/Debug/number_utils.obj b/DMS/Debug/number_utils.obj index 9c49584..4b63b57 100644 Binary files a/DMS/Debug/number_utils.obj and b/DMS/Debug/number_utils.obj differ diff --git a/DMS/Debug/utils.obj b/DMS/Debug/utils.obj index 243e939..2656fd0 100644 Binary files a/DMS/Debug/utils.obj and b/DMS/Debug/utils.obj differ diff --git a/DMS/Debug/value.obj b/DMS/Debug/value.obj index 99280ec..4f9877c 100644 Binary files a/DMS/Debug/value.obj and b/DMS/Debug/value.obj differ diff --git a/DMS/Debug/vc142.idb b/DMS/Debug/vc142.idb index 3a7d26c..b4435c7 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 f8ccedd..674f70f 100644 Binary files a/DMS/Debug/vc142.pdb and b/DMS/Debug/vc142.pdb differ diff --git a/DMS/LineParser.h b/DMS/LineParser.h index a443cad..b766461 100644 --- a/DMS/LineParser.h +++ b/DMS/LineParser.h @@ -75,8 +75,6 @@ namespace dms { bool isBlock(); bool isBlock(blocktype bk_type); void tolower(std::string &str); - tokens::tokentype* expr(); - tokens::tokentype* variable(); void tokenizer(dms_state* state, std::vector &tok); public: //Refer to streams.cpp for the match_process_CMD code. diff --git a/DMS/LineParserMatchProcess.cpp b/DMS/LineParserMatchProcess.cpp index 330d965..02b4892 100644 --- a/DMS/LineParserMatchProcess.cpp +++ b/DMS/LineParserMatchProcess.cpp @@ -113,7 +113,7 @@ namespace dms { stream->next(); } else if (stream->match(tokens::cbracketo) && start) { - state->push_error(errors::error{ errors::choice_unknown,concat("Unexpected symbol ",stream->next()),true,stream->peek().line_num }); + state->push_error(errors::error{ errors::choice_unknown,concat("Unexpected symbol ",stream->next()),true,stream->peek().line_num,current_chunk }); } else if (stream->match(tokens::string)) { std::string name = stream->next().name; @@ -139,7 +139,7 @@ namespace dms { stream->next(); // Consume } else if (!stream->match(tokens::cbracketc)) { - state->push_error(errors::error{ errors::choice_unknown,concat("Unexpected symbol ",stream->next()),true,stream->peek().line_num }); + state->push_error(errors::error{ errors::choice_unknown,concat("Unexpected symbol ",stream->next()),true,stream->peek().line_num,current_chunk }); } } return true; @@ -151,12 +151,6 @@ namespace dms { v->nuke(); // Make sure we clean up the data delete[] v; // We didn't need it, lets clean it up! } - /// - /// Recursively parse through function related tokens - /// - /// - /// - /// bool LineParser::match_process_function(tokenstream* stream, value* v, bool nested) { /* Functions should be able to handle function calls as arguments, @@ -204,7 +198,7 @@ namespace dms { c->opcode = codes::FUNC; std::string n = stream->next().name; print("FUNC ",n); - c->args.push(buildValue(n)); // Set the func identifier as the first variable + c->args.push(buildVariable(n)); // Set the func identifier as the first variable // Let's set the target if (v != nullptr) { c->args.push(v); // Push the supplied variable @@ -257,10 +251,10 @@ namespace dms { } // Final match this could be a function it might also be an expression else if (match_process_function(&tempstream, tempval)) { - if (!nested) { + /*if (!nested) { print("No nested!"); state->push_error(errors::error{ errors::nested_function,"Nested functions are not allowed in this context!",true, tempstream.peek().line_num }); - } + }*/ print("Nested ok!"); c->args.push(tempval); } @@ -280,26 +274,78 @@ namespace dms { } else { cleanup(tempval); // Cleanup - state->push_error(errors::error{ errors::badtoken,concat("Invalid symbol: ",tempstream.peek()),true, tempstream.peek().line_num}); + state->push_error(errors::error{ errors::badtoken,concat("Invalid symbol: ",tempstream.peek()),true, tempstream.peek().line_num,current_chunk }); } } } return false; } bool LineParser::match_process_goto(tokenstream* stream) { + if (stream->match(tokens::gotoo,tokens::name) || tokens::gotoo,tokens::string) { + cmd* c = new cmd; + c->opcode = codes::GOTO; + stream->next(); // consume gotoo + if (stream->match(tokens::name)) { + c->args.push(buildVariable(stream->next().name)); + } + else { + c->args.push(buildValue(stream->next().name)); + } + current_chunk->addCmd(c); + return true; + } return false; } bool LineParser::match_process_jump(tokenstream* stream) { + if (stream->match(tokens::jump, tokens::name) || tokens::jump, tokens::string) { + cmd* c = new cmd; + c->opcode = codes::JUMP; + stream->next(); // consume jump + if (stream->match(tokens::name)) { + c->args.push(buildVariable(stream->next().name)); + } + else { + c->args.push(buildValue(stream->next().name)); + } + current_chunk->addCmd(c); + return true; + } return false; } bool LineParser::match_process_exit(tokenstream* stream) { + if (stream->match(tokens::exit)) { + cmd* c = new cmd; + c->opcode = codes::EXIT; + if (stream->match(tokens::number) || stream->match(tokens::name)) { + if(stream->match(tokens::number)){ + c->args.push(buildValue(std::stod(stream->next().name))); + } + else { + c->args.push(buildVariable(stream->next().name)); + } + } + current_chunk->addCmd(c); + return true; + } return false; } bool LineParser::match_process_label(tokenstream* stream) { + if (stream->match(tokens::colon, tokens::colon, tokens::name, tokens::colon, tokens::colon)) { + cmd* c = new cmd; + c->opcode = codes::LABL; + stream->next(); + stream->next(); + std::string str = stream->next().name; + c->args.push(buildValue(str)); + current_chunk->addCmd(c); + current_chunk->addLabel(str); + stream->next(); + stream->next(); + } return false; } bool LineParser::match_process_IFFF(tokenstream* stream) { - return false; + return false; // TODO finish this } bool LineParser::match_process_expression(tokenstream* stream, value* v) { return false; // Method isn't done yet, we will get an error without this! diff --git a/DMS/LineParserParse.cpp b/DMS/LineParserParse.cpp index 9a7b01a..736cc47 100644 --- a/DMS/LineParserParse.cpp +++ b/DMS/LineParserParse.cpp @@ -152,11 +152,11 @@ namespace dms { } else if (data == '^') { doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); - t_vec.push_back(token{ tokens::pow,codes::NOOP,"",line - 2 }); + t_vec.push_back(token{ tokens::caret,codes::NOOP,"",line - 2 }); } else if (data == '%') { doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); - t_vec.push_back(token{ tokens::mod,codes::NOOP,"",line - 2 }); + t_vec.push_back(token{ tokens::percent,codes::NOOP,"",line - 2 }); } else if (data == '=') { doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); @@ -172,7 +172,31 @@ namespace dms { } else if (data == '!') { doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); - t_vec.push_back(token{ tokens::Not,codes::NOOP,"",line - 2 }); + t_vec.push_back(token{ tokens::exclamation,codes::NOOP,"",line - 2 }); + } + else if (data == '~') { + doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); + t_vec.push_back(token{ tokens::tilde,codes::NOOP,"",line - 2 }); + } + else if (data == '`') { + doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); + t_vec.push_back(token{ tokens::backtick,codes::NOOP,"",line - 2 }); + } + else if (data == '@') { + doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); + t_vec.push_back(token{ tokens::at,codes::NOOP,"",line - 2 }); + } + else if (data == '#') { + doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); + t_vec.push_back(token{ tokens::pound,codes::NOOP,"",line - 2 }); + } + else if (data == '$') { + doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); + t_vec.push_back(token{ tokens::dollar,codes::NOOP,"",line - 2 }); + } + else if (data == '&') { + doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); + t_vec.push_back(token{ tokens::ampersand,codes::NOOP,"",line - 2 }); } else if (data == '\t') { doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); @@ -311,7 +335,7 @@ namespace dms { else { std::stringstream str; str << "Expected " << " got: " << current << temp[0]; - state->push_error(errors::error{ errors::badtoken,str.str(),true,line }); + state->push_error(errors::error{ errors::badtoken,str.str(),true,line,current_chunk }); } } // Default block @@ -369,7 +393,7 @@ namespace dms { else { std::stringstream str; str << "Unexpected symbol: " << tokens[i]; - state->push_error(errors::error{ errors::badtoken,str.str(),true,line }); + state->push_error(errors::error{ errors::badtoken,str.str(),true,line,current_chunk }); } } // If all went well the 'args' now has all of tha params for the method we will be working with @@ -378,7 +402,7 @@ namespace dms { } else { str << "'function' keyword expected got " << b; - state->push_error(errors::error{ errors::badtoken, str.str(),true,line }); + state->push_error(errors::error{ errors::badtoken, str.str(),true,line,current_chunk }); } } // Control Handle all controls here @@ -391,13 +415,15 @@ namespace dms { // This will probably be the toughest one of them all } } - // Displays both with a target and without - match_process_disp(&stream); - if (current.type != tokens::tab) - tabs = 0; - current = stream.next(); + // Displays both with a target and without + match_process_disp(&stream); // Match and process displays + match_process_label(&stream); // Match and process labels + + //if (current.type != tokens::tab) // Old code for an old system... + // tabs = 0; + //current = stream.next(); } - state->chunks.insert_or_assign(current_chunk->name, current_chunk); + state->push_chunk(current_chunk->name, current_chunk); } } \ No newline at end of file diff --git a/DMS/LineParserUtils.cpp b/DMS/LineParserUtils.cpp index a302b0e..6d1e346 100644 --- a/DMS/LineParserUtils.cpp +++ b/DMS/LineParserUtils.cpp @@ -97,14 +97,6 @@ namespace dms { } return true; } - tokentype* LineParser::expr() { - return new tokentype[9]{ tokens::name,tokens::number,tokens::divide,tokens::minus,tokens::mod,tokens::multiply,tokens::plus,tokens::pow ,tokens::none }; - // tokens::none tells us we are at the end of the array. - } - tokentype* LineParser::variable() { - return new tokentype[7]{tokens::name,tokens::number,tokens::True,tokens::False,tokens::nil,tokens::string,tokens::none}; - // tokens::none tells us we are at the end of the array. - } bool inList(tokens::tokentype t,tokens::tokentype* list) { size_t c = 0; while (list[c] != tokens::none) { @@ -166,12 +158,12 @@ namespace dms { bool LineParser::createBlock(std::string bk_name, blocktype bk_type) { if (current_chunk != nullptr) { if (!state->chunks.count(current_chunk->name)) - state->chunks.insert_or_assign(current_chunk->name, current_chunk); + state->push_chunk(current_chunk->name, current_chunk); else { std::stringstream str; str << "Block <" << current_chunk->name << "> already defined!"; - state->push_error(errors::error{ errors::block_already_defined,str.str(),true,line }); + state->push_error(errors::error{ errors::block_already_defined,str.str(),true,line,current_chunk }); return false; } } diff --git a/DMS/Nadia.ogg b/DMS/Nadia.ogg new file mode 100644 index 0000000..92dcbeb Binary files /dev/null and b/DMS/Nadia.ogg differ diff --git a/DMS/chunk.cpp b/DMS/chunk.cpp index 9a9dab3..aa066e4 100644 --- a/DMS/chunk.cpp +++ b/DMS/chunk.cpp @@ -3,4 +3,8 @@ namespace dms { void chunk::addCmd(cmd* c) { cmds.push_back(c); } + void chunk::addLabel(std::string name) { + size_t size = cmds.size(); // Get the command position for the label. This should be the command we created for the label + labels.insert_or_assign(name,size); // Here we set the name of the label so we can find it as well as the position to jump to + } } \ No newline at end of file diff --git a/DMS/chunk.h b/DMS/chunk.h index cfc2c94..15897b7 100644 --- a/DMS/chunk.h +++ b/DMS/chunk.h @@ -1,6 +1,7 @@ #pragma once #include "cmd.h" #include +#include namespace dms { enum blocktype { bt_block, @@ -18,7 +19,15 @@ namespace dms { size_t pos = 0; size_t line = 0; void addCmd(cmd* c); + std::map labels; // Each chunk contains its own label data chunk(){} + void addLabel(std::string name); + friend std::ostream& operator << (std::ostream& out, const chunk& c) { + for (size_t i = 0; i < c.cmds.size(); i++) { + out << *(c.cmds[i]) << std::endl; + } + return out; + } }; } diff --git a/DMS/cmd.h b/DMS/cmd.h index 159dc34..9784d51 100644 --- a/DMS/cmd.h +++ b/DMS/cmd.h @@ -1,11 +1,25 @@ #pragma once #include "value.h" #include "codes.h" +#include #include namespace dms { struct cmd { dms::codes::op opcode; dms_args args; + friend std::ostream& operator << (std::ostream& out, const cmd& c) { + out << codes::list[c.opcode] << " "; + for (size_t i = 0; i < c.args.args.size(); i++) { + out << *c.args.args[i] << " "; + } + return out; + } + // For writing to a file + std::string toString() { + std::stringstream str; + str << opcode << args.toString() << (char)0; + return str.str(); + } }; } diff --git a/DMS/codes.cpp b/DMS/codes.cpp index 2deedc1..d2ee854 100644 --- a/DMS/codes.cpp +++ b/DMS/codes.cpp @@ -1,3 +1,3 @@ #pragma once #include "Codes.h" -const std::string dms::codes::list[] = { "NOOP","ENTR","ENAB","DISA","LOAD","VERN","USIN","STAT","DISP","ASGN","LABL","CHOI","OPTN","FORE","????","WHLE","FUNC","IFFF","ELIF","ELSE","DEFN","SKIP","COMP","INDX","JMPZ","INST","ERRO" ,"RETN" }; \ No newline at end of file +const std::string dms::codes::list[] = { "NOOP","ENTR","ENAB","DISA","LOAD","VERN","USIN","STAT","DISP","ASGN","LABL","CHOI","OPTN","FORE","????","WHLE","FUNC","IFFF","ELIF","ELSE","DEFN","SKIP","COMP","INDX","JMPZ","INST","ERRO" ,"GOTO","JUMP","RETN", "EXIT" }; \ No newline at end of file diff --git a/DMS/codes.h b/DMS/codes.h index 52dcf22..1a46e6b 100644 --- a/DMS/codes.h +++ b/DMS/codes.h @@ -30,7 +30,10 @@ namespace dms::codes { JMPZ, INST, ERRO, - RETN + GOTO, + JUMP, + RETN, + EXIT }; extern const std::string list[]; static bool isControl(const op code) { diff --git a/DMS/dms_state.cpp b/DMS/dms_state.cpp index fcac9e5..35a8a1c 100644 --- a/DMS/dms_state.cpp +++ b/DMS/dms_state.cpp @@ -1,9 +1,35 @@ #include "dms_state.h" namespace dms { + void dms_state::dump(errors::error err) { + std::cout << "Number of chunks: " << chunks.size(); + std::ofstream outputFile("dump.bin"); + for (const auto& [key, val] : chunks) { + std::cout << "Key: " << key << " Value: " << *val << '\n'; + } + //If the error has a chunk then we get the data from it + if (err.current_chunk != nullptr) { + outputFile << err.current_chunk->name << ":" << std::endl << *err.current_chunk << std::endl; + } + outputFile.close(); + } + void dms_state::dump() { + std::cout << "Number of chunks: " << chunks.size(); + std::ofstream outputFile("dump.bin"); + for (const auto& [key, val] : chunks) { + std::cout << "Key: " << key << " Value: " << *val << '\n'; + } + outputFile.close(); + } + void dms_state::push_chunk(std::string s, chunk* c) { + std::cout << "Pushing Chunk: " << s << std::endl; + chunks.insert_or_assign(s, c); + } void dms_state::push_error(errors::error err) { std::cout << err.err_msg << " On Line <" << err.linenum << ">" << std::endl; - if(err.crash) + if (err.crash) { + dump(err); std::exit(err.code); + } } void dms_state::push_warning(errors::error err) { err.crash = false; // Force code to not crash then push the error diff --git a/DMS/dms_state.h b/DMS/dms_state.h index 8020619..7c93634 100644 --- a/DMS/dms_state.h +++ b/DMS/dms_state.h @@ -1,18 +1,22 @@ #pragma once #include "errors.h" #include "chunk.h" +#include #include #include -#include +#include namespace dms { class dms_state { public: + void dump(errors::error err); + void dump(); void push_error(errors::error err); void push_warning(errors::error err); + void push_chunk(std::string s, chunk* c); double version=1.0; - std::unordered_map chunks; + std::map chunks; std::string entry = "start"; - std::unordered_map enables; + std::map enables; }; } diff --git a/DMS/dump.bin b/DMS/dump.bin new file mode 100644 index 0000000..e69de29 diff --git a/DMS/dump.txt b/DMS/dump.txt index a614711..f69c279 100644 --- a/DMS/dump.txt +++ b/DMS/dump.txt @@ -19,169 +19,155 @@ Line <7>USIN flag Line <7>NOOP name extendedDefine Line <7>NOOP newline Line <8>NOOP newline -Line <9>NOOP bracketo -Line <9>NOOP name main -Line <9>NOOP bracketc -Line <9>NOOP cbracketo Line <9>NOOP newline -Line <10>NOOP name Ryan -Line <10>NOOP colon -Line <10>NOOP string This works! +Line <10>NOOP bracketo +Line <10>NOOP name main +Line <10>NOOP bracketc +Line <10>NOOP cbracketo Line <10>NOOP newline -Line <11>NOOP name DEBUG -Line <11>NOOP string What's up +Line <11>NOOP name Ryan +Line <11>NOOP colon +Line <11>NOOP string This works! Line <11>NOOP newline -Line <12>NOOP name Ryan -Line <12>NOOP colon -Line <12>NOOP cbracketo +Line <12>NOOP name DEBUG +Line <12>NOOP string What's up Line <12>NOOP newline -Line <13>NOOP name speed -Line <13>NOOP number 100 -Line <13>NOOP mod +Line <13>NOOP name Ryan +Line <13>NOOP colon +Line <13>NOOP cbracketo Line <13>NOOP newline -Line <13>NOOP name calm -Line <13>NOOP string Hello Bob, -Line <13>NOOP newline -Line <14>NOOP name wait -Line <14>NOOP number 0.455 +Line <14>NOOP name speed +Line <14>NOOP number 100 +Line <14>NOOP mod Line <14>NOOP newline -Line <15>NOOP name excited -Line <15>NOOP string how are you doing? +Line <14>NOOP name calm +Line <14>NOOP string Hello Bob, +Line <14>NOOP newline +Line <15>NOOP name wait +Line <15>NOOP number 0.455 Line <15>NOOP newline +Line <16>NOOP name excited +Line <16>NOOP string how are you doing? Line <16>NOOP newline -Line <17>NOOP cbracketc Line <17>NOOP newline +Line <18>NOOP cbracketc Line <18>NOOP newline -Line <19>NOOP name tester -Line <19>NOOP equal -Line <19>NOOP string Hello Line <19>NOOP newline -Line <20>NOOP name food +Line <20>NOOP name tester Line <20>NOOP equal -Line <20>NOOP number 3 +Line <20>NOOP string Hello Line <20>NOOP newline -Line <21>NOOP name a +Line <21>NOOP name food Line <21>NOOP equal -Line <21>NOOP name list -Line <21>NOOP bracketo -Line <21>NOOP number 1 -Line <21>NOOP bracketc +Line <21>NOOP number 3 Line <21>NOOP newline +Line <22>NOOP name a +Line <22>NOOP equal +Line <22>NOOP name list +Line <22>NOOP bracketo +Line <22>NOOP number 1 +Line <22>NOOP bracketc Line <22>NOOP newline -Line <23>IFFF control -Line <23>NOOP name statment -Line <23>NOOP cbracketo Line <23>NOOP newline -Line <24>NOOP string test +Line <24>IFFF control +Line <24>NOOP name statment +Line <24>NOOP cbracketo Line <24>NOOP newline -Line <25>NOOP cbracketc -Line <25>ELIF control -Line <25>NOOP name statement -Line <25>NOOP cbracketo +Line <25>NOOP string test Line <25>NOOP newline -Line <26>NOOP string test +Line <26>NOOP cbracketc +Line <26>ELIF control +Line <26>NOOP name statement +Line <26>NOOP cbracketo Line <26>NOOP newline -Line <27>NOOP cbracketc -Line <27>IFFF control -Line <27>NOOP name statement -Line <27>NOOP cbracketo +Line <27>NOOP string test Line <27>NOOP newline -Line <28>NOOP string test +Line <28>NOOP cbracketc +Line <28>IFFF control +Line <28>NOOP name statement +Line <28>NOOP cbracketo Line <28>NOOP newline Line <29>NOOP string test Line <29>NOOP newline -Line <30>IFFF control -Line <30>NOOP name statement -Line <30>NOOP cbracketo +Line <30>NOOP string test Line <30>NOOP newline -Line <31>NOOP string test +Line <31>IFFF control +Line <31>NOOP name statement +Line <31>NOOP cbracketo Line <31>NOOP newline -Line <32>NOOP cbracketc -Line <32>ELSE control -Line <32>NOOP cbracketo +Line <32>NOOP string test Line <32>NOOP newline -Line <33>NOOP string test +Line <33>NOOP cbracketc +Line <33>ELSE control +Line <33>NOOP cbracketo Line <33>NOOP newline -Line <34>NOOP cbracketc +Line <34>NOOP string test Line <34>NOOP newline Line <35>NOOP cbracketc -Line <35>ELIF control -Line <35>NOOP name statement -Line <35>NOOP cbracketo Line <35>NOOP newline -Line <36>NOOP string test +Line <36>NOOP cbracketc +Line <36>ELIF control +Line <36>NOOP name statement +Line <36>NOOP cbracketo Line <36>NOOP newline -Line <37>NOOP cbracketc -Line <37>ELSE control -Line <37>NOOP cbracketo +Line <37>NOOP string test Line <37>NOOP newline -Line <38>NOOP string test +Line <38>NOOP cbracketc +Line <38>ELSE control +Line <38>NOOP cbracketo Line <38>NOOP newline -Line <39>NOOP cbracketc +Line <39>NOOP string test Line <39>NOOP newline +Line <40>NOOP cbracketc Line <40>NOOP newline -Line <41>NOOP gotoo -Line <41>NOOP string somewhere Line <41>NOOP newline -Line <42>NOOP jump -Line <42>NOOP string overhere +Line <42>NOOP gotoo +Line <42>NOOP string somewhere Line <42>NOOP newline +Line <43>NOOP jump +Line <43>NOOP string overhere Line <43>NOOP newline -Line <44>NOOP name hungry -Line <44>NOOP equal -Line <44>NOOP parao -Line <44>NOOP minus -Line <44>NOOP number 2 -Line <44>NOOP plus -Line <44>NOOP number 4 -Line <44>NOOP minus -Line <44>NOOP parao -Line <44>NOOP parao -Line <44>NOOP number 5 -Line <44>NOOP multiply -Line <44>NOOP number 5 -Line <44>NOOP parac -Line <44>NOOP divide -Line <44>NOOP name sqrt -Line <44>NOOP parao -Line <44>NOOP number 144 -Line <44>NOOP plus -Line <44>NOOP number 5 -Line <44>NOOP parac -Line <44>NOOP parac -Line <44>NOOP parac -Line <44>NOOP pow -Line <44>NOOP number 2 -Line <44>NOOP multiply -Line <44>NOOP number 2 -Line <44>NOOP plus -Line <44>NOOP number 2 Line <44>NOOP newline -Line <45>NOOP name list -Line <45>NOOP bracketo -Line <45>NOOP number 1 -Line <45>NOOP bracketc +Line <45>NOOP name hungry Line <45>NOOP equal -Line <45>NOOP string Hello +Line <45>NOOP parao +Line <45>NOOP minus +Line <45>NOOP number 2 +Line <45>NOOP plus +Line <45>NOOP number 4 +Line <45>NOOP minus +Line <45>NOOP parao +Line <45>NOOP parao +Line <45>NOOP number 5 +Line <45>NOOP multiply +Line <45>NOOP number 5 +Line <45>NOOP parac +Line <45>NOOP divide +Line <45>NOOP name sqrt +Line <45>NOOP parao +Line <45>NOOP number 144 +Line <45>NOOP plus +Line <45>NOOP number 5 +Line <45>NOOP parac +Line <45>NOOP parac +Line <45>NOOP parac +Line <45>NOOP pow +Line <45>NOOP number 2 +Line <45>NOOP multiply +Line <45>NOOP number 2 +Line <45>NOOP plus +Line <45>NOOP number 2 Line <45>NOOP newline -Line <46>NOOP name var1 -Line <46>NOOP number -Line <46>NOOP equal -Line <46>NOOP name func -Line <46>NOOP parao +Line <46>NOOP name list +Line <46>NOOP bracketo Line <46>NOOP number 1 -Line <46>NOOP seperator -Line <46>NOOP string string -Line <46>NOOP seperator -Line <46>NOOP number 2 -Line <46>NOOP plus -Line <46>NOOP number 5 -Line <46>NOOP parac +Line <46>NOOP bracketc +Line <46>NOOP equal +Line <46>NOOP string Hello Line <46>NOOP newline -Line <47>NOOP name a +Line <47>NOOP name var1 +Line <47>NOOP number Line <47>NOOP equal -Line <47>NOOP number 100 -Line <47>NOOP plus Line <47>NOOP name func Line <47>NOOP parao Line <47>NOOP number 1 @@ -192,9 +178,11 @@ Line <47>NOOP number 2 Line <47>NOOP plus Line <47>NOOP number 5 Line <47>NOOP parac -Line <47>NOOP plus -Line <47>NOOP number 100 Line <47>NOOP newline +Line <48>NOOP name a +Line <48>NOOP equal +Line <48>NOOP number 100 +Line <48>NOOP plus Line <48>NOOP name func Line <48>NOOP parao Line <48>NOOP number 1 @@ -205,105 +193,122 @@ Line <48>NOOP number 2 Line <48>NOOP plus Line <48>NOOP number 5 Line <48>NOOP parac +Line <48>NOOP plus +Line <48>NOOP number 100 Line <48>NOOP newline -Line <49>NOOP label label +Line <49>NOOP name func +Line <49>NOOP parao +Line <49>NOOP number 1 +Line <49>NOOP seperator +Line <49>NOOP string string +Line <49>NOOP seperator +Line <49>NOOP number 2 +Line <49>NOOP plus +Line <49>NOOP number 5 +Line <49>NOOP parac Line <49>NOOP newline +Line <50>NOOP label label Line <50>NOOP newline Line <51>NOOP newline -Line <52>CHOI control -Line <52>NOOP string Pick one: -Line <52>NOOP cbracketo Line <52>NOOP newline -Line <53>NOOP string first -Line <53>NOOP name func -Line <53>NOOP parao -Line <53>NOOP number 1 -Line <53>NOOP seperator -Line <53>NOOP number 2 -Line <53>NOOP seperator -Line <53>NOOP number 3 -Line <53>NOOP parac +Line <53>CHOI control +Line <53>NOOP string Pick one: +Line <53>NOOP cbracketo Line <53>NOOP newline -Line <54>NOOP string second +Line <54>NOOP string first Line <54>NOOP name func Line <54>NOOP parao -Line <54>NOOP true true +Line <54>NOOP number 1 Line <54>NOOP seperator -Line <54>NOOP false false +Line <54>NOOP number 2 Line <54>NOOP seperator -Line <54>NOOP name func -Line <54>NOOP parao -Line <54>NOOP string heehee -Line <54>NOOP parac +Line <54>NOOP number 3 Line <54>NOOP parac Line <54>NOOP newline -Line <55>NOOP string third +Line <55>NOOP string second Line <55>NOOP name func Line <55>NOOP parao -Line <55>NOOP string hehe +Line <55>NOOP true true +Line <55>NOOP seperator +Line <55>NOOP false false +Line <55>NOOP seperator +Line <55>NOOP name func +Line <55>NOOP parao +Line <55>NOOP string heehee +Line <55>NOOP parac Line <55>NOOP parac Line <55>NOOP newline -Line <56>NOOP string forth +Line <56>NOOP string third Line <56>NOOP name func Line <56>NOOP parao -Line <56>NOOP string 1 -Line <56>NOOP seperator -Line <56>NOOP number 2 -Line <56>NOOP seperator -Line <56>NOOP false false +Line <56>NOOP string hehe Line <56>NOOP parac Line <56>NOOP newline -Line <57>NOOP string fifth -Line <57>NOOP gotoo -Line <57>NOOP string here +Line <57>NOOP string forth +Line <57>NOOP name func +Line <57>NOOP parao +Line <57>NOOP string 1 +Line <57>NOOP seperator +Line <57>NOOP number 2 +Line <57>NOOP seperator +Line <57>NOOP false false +Line <57>NOOP parac Line <57>NOOP newline -Line <58>NOOP string sixth +Line <58>NOOP string fifth Line <58>NOOP gotoo -Line <58>NOOP name name +Line <58>NOOP string here Line <58>NOOP newline -Line <59>NOOP string sevinth -Line <59>NOOP jump -Line <59>NOOP string there +Line <59>NOOP string sixth +Line <59>NOOP gotoo +Line <59>NOOP name name Line <59>NOOP newline -Line <60>NOOP string eight +Line <60>NOOP string sevinth Line <60>NOOP jump -Line <60>NOOP name name +Line <60>NOOP string there Line <60>NOOP newline -Line <61>NOOP string nine -Line <61>NOOP name exit +Line <61>NOOP string eight +Line <61>NOOP jump +Line <61>NOOP name name Line <61>NOOP newline -Line <62>NOOP cbracketc +Line <62>NOOP string nine +Line <62>NOOP name exit Line <62>NOOP newline -Line <63>NOOP cbracketc +Line <63>NOOP string ten +Line <63>NOOP exit +Line <63>NOOP number 0 Line <63>NOOP newline +Line <64>NOOP cbracketc Line <64>NOOP newline +Line <65>NOOP cbracketc Line <65>NOOP newline Line <66>NOOP newline -Line <67>NOOP bracketo -Line <67>NOOP name Bob -Line <67>NOOP colon -Line <67>NOOP name char -Line <67>NOOP bracketc Line <67>NOOP newline -Line <68>NOOP name age -Line <68>NOOP equal -Line <68>NOOP number 24 Line <68>NOOP newline -Line <69>NOOP name money -Line <69>NOOP equal -Line <69>NOOP number 100 +Line <69>NOOP bracketo +Line <69>NOOP name Bob +Line <69>NOOP colon +Line <69>NOOP name char +Line <69>NOOP bracketc Line <69>NOOP newline +Line <70>NOOP name age +Line <70>NOOP equal +Line <70>NOOP number 24 Line <70>NOOP newline -Line <71>NOOP bracketo -Line <71>NOOP name newblock -Line <71>NOOP colon -Line <71>NOOP name function -Line <71>NOOP parao -Line <71>NOOP parac -Line <71>NOOP bracketc +Line <71>NOOP name money +Line <71>NOOP equal +Line <71>NOOP number 100 Line <71>NOOP newline -Line <72>NOOP string Test #2 Line <72>NOOP newline -Line <73>NOOP string Does it parse this part properly? +Line <73>NOOP bracketo +Line <73>NOOP name newblock +Line <73>NOOP colon +Line <73>NOOP name function +Line <73>NOOP parao +Line <73>NOOP parac +Line <73>NOOP bracketc Line <73>NOOP newline -Line <75>NOOP eof +Line <74>NOOP string Test #2 +Line <74>NOOP newline +Line <75>NOOP string Does it parse this part properly? +Line <75>NOOP newline +Line <77>NOOP eof diff --git a/DMS/errors.h b/DMS/errors.h index d179a10..e27eeda 100644 --- a/DMS/errors.h +++ b/DMS/errors.h @@ -1,5 +1,6 @@ #pragma once #include +#include "chunk.h" namespace dms::errors { enum errortype { unknown, @@ -17,5 +18,6 @@ namespace dms::errors { std::string err_msg; bool crash = true; // Set if you would like the state to exit size_t linenum = 0; + chunk* current_chunk = nullptr; }; } \ No newline at end of file diff --git a/DMS/packages.config b/DMS/packages.config new file mode 100644 index 0000000..5997977 --- /dev/null +++ b/DMS/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/DMS/test.dms b/DMS/test.dms index 9783cfe..c3cde32 100644 --- a/DMS/test.dms +++ b/DMS/test.dms @@ -5,7 +5,8 @@ disable omniscient //loadfile "loadtest.dms" version 1.2 using extendedDefine - + + [main] { Ryan: "This works!" DEBUG "What's up" // Debug lines are removed when debug mode is disabled @@ -59,6 +60,7 @@ using extendedDefine "sevinth" jump "there" "eight" jump name "nine" exit + "ten" exit 0 } } diff --git a/DMS/token.h b/DMS/token.h index 42a168e..fe1af1e 100644 --- a/DMS/token.h +++ b/DMS/token.h @@ -21,8 +21,8 @@ namespace dms::tokens { minus, multiply, divide, - pow, - mod, + caret, + percent, equal, colon, control, @@ -30,7 +30,7 @@ namespace dms::tokens { False, Or, And, - Not, + exclamation, For, label, newline, @@ -40,6 +40,14 @@ namespace dms::tokens { gotoo, jump, exit, + // Other token types + tilde, + backtick, + at, + pound, + dollar, + ampersand, + nil };//stream, t_vec, line, isNum, buffer struct token { diff --git a/DMS/value.h b/DMS/value.h index f0aeb0b..9abc779 100644 --- a/DMS/value.h +++ b/DMS/value.h @@ -60,25 +60,26 @@ namespace dms { std::string toString() const; friend std::ostream& operator << (std::ostream& out, const value& c) { if (c.type == string) { - out << c.s->getValue(); + out << (char)c.type << c.s->getValue() << (char)0; } else if (c.type == number) { - out << c.n->getValue(); + out << (char)c.type << c.n->getValue(); } else if (c.type == nil) { - out << "nil"; + out << (char)c.type << "nil"; } else if (c.type == boolean) { - out << c.b->getValue(); + out << (char)c.type << c.b->getValue(); } else if (c.type == env) { - out << "Env: " << c; + out << (char)c.type << "Env: " << c; } else if (c.type == custom) { - out << "Custom Data: " << c; + out << (char)c.type << "Custom Data: " << c; } + // Internal kinda else if (c.type == datatypes::variable) { - out << c.s->getValue(); // Do the lookup + out << (char)c.type << c.s->getValue(); // Do the lookup } return out; }; @@ -103,6 +104,13 @@ namespace dms { } return out; } + std::string toString() { + std::stringstream str; + for (size_t i = 0; i < args.size(); i++) { + str << *args[i]; + } + return str.str(); + } }; struct dms_env { diff --git a/Debug/DMS.exe b/Debug/DMS.exe index 17fa50a..0d82ea0 100644 Binary files a/Debug/DMS.exe and b/Debug/DMS.exe differ diff --git a/Debug/DMS.ilk b/Debug/DMS.ilk index 735e6e3..7c53a38 100644 Binary files a/Debug/DMS.ilk and b/Debug/DMS.ilk differ diff --git a/Debug/DMS.pdb b/Debug/DMS.pdb index fc21b2e..0f6bd4f 100644 Binary files a/Debug/DMS.pdb and b/Debug/DMS.pdb differ