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