diff --git a/DMS syntax npp.xml b/DMS syntax npp.xml
index 67e0893..0682c15 100644
--- a/DMS syntax npp.xml
+++ b/DMS syntax npp.xml
@@ -25,8 +25,8 @@
ENABLE DISABLE LOADFILE ENTRY USING VERSION as AS enable disable loadfile entry using version
- if then return and or true false for while choice end else elseif goto jump exit
- leaking debugging warnings statesave hostmsg
+ if then return and or true false for while choice end else elseif goto jump exit debug nil
+ leaking debugging warnings statesave omniscient
ceil tan CSIM log10 sinh GOTOE lshift deg MUL QUIT cosh exp rad GOTO SUB log ADD error POW randomseed floor tanh max atan SKIP acos DIV abs rshif COMPARE print atan2 asin cos sin mod sqrt function getInput sleep getVar setVar newThread setGlobalVar getGlobalVar SAVE LOAD WATCH env char
_VERSION
filesystem extendedDefine
@@ -36,19 +36,19 @@
-
+
-
-
-
-
+
+
+
+
-
-
+
+
diff --git a/DMS/Debug/DMS.log b/DMS/Debug/DMS.log
index 1c01c78..ae767a8 100644
--- a/DMS/Debug/DMS.log
+++ b/DMS/Debug/DMS.log
@@ -1,5 +1,2 @@
- LineParserBuilds.cpp
- LineParserParse.cpp
- chunk.cpp
- Generating Code...
+ LineParserParse.cpp
DMS.vcxproj -> F:\VSCWorkspace\DMS\Debug\DMS.exe
diff --git a/DMS/Debug/DMS.obj b/DMS/Debug/DMS.obj
index a11430e..74719e2 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 4c1ae59..1315fd4 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 7d7da95..dcef754 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 cf39db3..ce40db9 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/cmd.obj b/DMS/Debug/cmd.obj
index 07e9027..3302c22 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 b867956..95e9400 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 1b963f0..dabdfc1 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 a26bef9..5ec87c4 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 d3a086a..e86b352 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 002a4ef..cf1a83e 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 76d1dbc..f87c0ba 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 e68168e..a93d702 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 c13cd38..808701c 100644
--- a/DMS/LineParser.h
+++ b/DMS/LineParser.h
@@ -56,6 +56,7 @@ namespace dms {
std::vector temp;
std::vector tdump;
size_t tabs = 0;
+ tokenstream* _stream;
dms_state* state;
void doCheck(passer* stream, std::vector* t_vec, size_t line, bool& isNum, bool& hasDec, std::vector* buffer);
void _Parse(tokenstream stream);
@@ -73,8 +74,14 @@ namespace dms {
void buildGoto(std::string g, bool v = false);
void buildNoop();
void buildLabel(std::string l);
+ void buildSpeed(double s);
+ void buildWait(double w);
// Utils
+ void badSymbol(errors::errortype err, tokenstream* stream);
+ void badSymbol(tokenstream* stream);
+ void badSymbol();
+
void tokenDump(std::vector* v);
bool createBlock(std::string bk_name, blocktype bk_type);
diff --git a/DMS/LineParserMatchProcess.cpp b/DMS/LineParserMatchProcess.cpp
index 489bfd5..8c26ea3 100644
--- a/DMS/LineParserMatchProcess.cpp
+++ b/DMS/LineParserMatchProcess.cpp
@@ -15,11 +15,12 @@ namespace dms {
print("DISP := ", msg);
cmd* c = new cmd;
c->opcode = codes::DISP;
+ c->args.push(buildValue());
c->args.push(buildValue(msg));
current_chunk->addCmd(c); // Add the cmd to the current chunk
return true;
}
- else if (isBlock(bt_block) && stream->match(tokens::newline, tokens::name, tokens::colon, tokens::string, tokens::newline)) {
+ else if ((isBlock(bt_block) || isBlock(bt_method)) && stream->match(tokens::newline, tokens::name, tokens::colon, tokens::string, tokens::newline)) {
// We might have to handle scope here
// Here we match 'Ryan: "This guy said this!"' Note the colon is needed!
stream->next(); // Standard consumption
@@ -29,12 +30,66 @@ namespace dms {
print("DISP := ", name, " says '", msg, "'");
cmd* c = new cmd;
c->opcode = codes::DISP;
- c->args.push(buildValue(msg));
c->args.push(buildValue(name));
+ c->args.push(buildValue(msg));
current_chunk->addCmd(c); // Add the cmd to the current chunk
// We might have to consume a newline... Depends on what's next
return true;
}
+ else if ((isBlock(bt_block) || isBlock(bt_method)) && stream->match(tokens::name,tokens::colon,tokens::cbracketo)) {
+ std::string name = stream->next().name;
+ cmd* c = new cmd;
+ c->opcode = codes::SSPK;
+ c->args.push(buildVariable(name));
+ current_chunk->addCmd(c);
+ // Command to set the speaker
+ stream->next();
+ stream->next();
+ print("Doing disp!!!");
+ while (stream->peek().type != tokens::cbracketc) {
+ print(stream->peek());
+ if (stream->match(tokens::name)) {
+ std::string mode = stream->next().name;
+ if (mode == "speed") {
+ if (stream->match(tokens::number)) {
+ buildSpeed(std::stod(stream->next().name));
+ }
+ else {
+ badSymbol(stream);
+ }
+ }
+ else if (mode == "wait") {
+ if (stream->match(tokens::number)) {
+ buildWait(std::stod(stream->next().name));
+ }
+ else {
+ badSymbol(errors::disp_unknown, stream);
+ }
+ }
+ else {
+ // Assume we have a dact
+ if (stream->match(tokens::string)) {
+ cmd* c = new cmd;
+ c->opcode = codes::DACT;
+ c->args.push(buildVariable(mode));
+ current_chunk->addCmd(c);
+ }
+ else {
+ badSymbol(stream);
+ }
+ }
+ }
+ else if (stream->match(tokens::string)) {
+
+ }
+ else if (stream->match(tokens::newline)) {
+ stream->next();
+ }
+ else {
+ badSymbol(stream);
+ }
+ }
+ }
// emotion: "path"
// looks like a simple disp command
else if (isBlock(bt_character) && stream->match(tokens::tab, tokens::name, tokens::colon, tokens::string, tokens::newline)) {
@@ -122,7 +177,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,current_chunk });
+ badSymbol(stream);
}
else if (stream->match(tokens::string)) {
std::string name = stream->next().name;
@@ -148,7 +203,7 @@ namespace dms {
stream->next(); // Consume
}
else {
- state->push_error(errors::error{ errors::choice_unknown,concat("Unexpected symbol ",stream->next()),true,stream->peek().line_num,current_chunk });
+ badSymbol(stream);
}
}
buildLabel(str);
@@ -282,7 +337,7 @@ namespace dms {
}
else {
cleanup(tempval); // Cleanup
- state->push_error(errors::error{ errors::badtoken,concat("Invalid symbol: ",tempstream.peek()),true, tempstream.peek().line_num,current_chunk });
+ badSymbol(stream);
}
}
}
diff --git a/DMS/LineParserParse.cpp b/DMS/LineParserParse.cpp
index 4c95ca2..9b166c4 100644
--- a/DMS/LineParserParse.cpp
+++ b/DMS/LineParserParse.cpp
@@ -23,11 +23,11 @@ namespace dms {
if (myfile.is_open())
{
std::string line;
- rawdata << "\n\n"; // For things to work I added 2 newlines. The issue is with how I decided to parse things.
+ rawdata << ";;"; // For things to work I added 2 newlines. The issue is with how I decided to parse things.
// This way you are allowed to start a block at the top of the screen!
while (std::getline(myfile, line)) {
trim(line);
- rawdata << line << "\n";
+ rawdata << line << ";\n";
}
myfile.close();
//std::cout << rawdata.str() << std::endl;
@@ -53,9 +53,9 @@ namespace dms {
}
else if (data == '\n') {
doCheck(&stream, &t_vec, line-2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::newline,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::newline,codes::NOOP,"",line });
if (isNum) {
- t_vec.push_back(token{ tokens::number,codes::NOOP,stream.processBuffer(buffer),line - 2 });
+ t_vec.push_back(token{ tokens::number,codes::NOOP,stream.processBuffer(buffer),line });
buffer.clear();
isNum = false;
}
@@ -70,7 +70,7 @@ namespace dms {
stream.next();
}
else if (data == ':' && stream.peek() == ':' && labelStart) {
- t_vec.push_back(token{ tokens::label,codes::NOOP,stream.processBuffer(buffer),line - 2 });
+ t_vec.push_back(token{ tokens::label,codes::NOOP,stream.processBuffer(buffer),line });
buffer.clear();
stream.next();
labelStart = false;
@@ -81,7 +81,7 @@ namespace dms {
}
else if (data == '"' && isStr) {
isStr = false;
- t_vec.push_back(token{ tokens::string,codes::NOOP,stream.processBuffer(buffer),line - 2 });
+ t_vec.push_back(token{ tokens::string,codes::NOOP,stream.processBuffer(buffer),line });
buffer.clear();
}
else if (isStr) {
@@ -99,190 +99,184 @@ namespace dms {
buffer.push_back(data);
}
else if (data == '.' && isNum && hasDec) {
- t_vec.push_back(token{ tokens::number,codes::ERRO,"Malformed number!",line - 2 });
+ t_vec.push_back(token{ tokens::number,codes::ERRO,"Malformed number!",line });
}
else if (data == '[') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::bracketo,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::bracketo,codes::NOOP,"",line });
}
else if (data == ']') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::bracketc,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::bracketc,codes::NOOP,"",line });
}
else if (data == '(') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::parao,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::parao,codes::NOOP,"",line });
}
else if (data == ')') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::parac,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::parac,codes::NOOP,"",line });
}
else if (data == ',') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::seperator,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::seperator,codes::NOOP,"",line });
}
else if (data == '.') {
//doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::dot,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::dot,codes::NOOP,"",line });
}
else if (data == '{') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::cbracketo,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::cbracketo,codes::NOOP,"",line });
}
else if (data == '}') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::cbracketc,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::cbracketc,codes::NOOP,"",line });
}
else if (data == '+') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::plus,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::plus,codes::NOOP,"",line });
}
else if (data == '-') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::minus,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::minus,codes::NOOP,"",line });
}
else if (data == '*') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::multiply,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::multiply,codes::NOOP,"",line });
}
else if (data == '/') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::divide,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::divide,codes::NOOP,"",line });
}
else if (data == '^') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::caret,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::caret,codes::NOOP,"",line });
}
else if (data == '%') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::percent,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::percent,codes::NOOP,"",line });
}
else if (data == '=') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::equal,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::equal,codes::NOOP,"",line });
}
else if (data == ':') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::colon,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::colon,codes::NOOP,"",line });
}
else if (data == ';') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::newline,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::newline,codes::NOOP,"",line });
}
else if (data == '!') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::exclamation,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::exclamation,codes::NOOP,"",line });
}
else if (data == '~') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::tilde,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::tilde,codes::NOOP,"",line });
}
else if (data == '`') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::backtick,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::backtick,codes::NOOP,"",line });
}
else if (data == '@') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::at,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::at,codes::NOOP,"",line });
}
else if (data == '#') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::pound,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::pound,codes::NOOP,"",line });
}
else if (data == '$') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::dollar,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::dollar,codes::NOOP,"",line });
}
else if (data == '&') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::ampersand,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::ampersand,codes::NOOP,"",line });
}
else if (data == '\t') {
- doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer);
- t_vec.push_back(token{ tokens::tab,codes::NOOP,"",line - 2 });
+ doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
+ t_vec.push_back(token{ tokens::tab,codes::NOOP,"",line });
}
if (data == ' ' && !isStr) { // tokens end with a space
std::string str = stream.processBuffer(buffer);
tolower(str);
if (str == "enable") {
- t_vec.push_back(token{ tokens::flag,codes::ENAB,"",line - 2 });
+ t_vec.push_back(token{ tokens::flag,codes::ENAB,"",line });
}
else if (str == "entry") {
- t_vec.push_back(token{ tokens::flag,codes::ENTR,"",line - 2 });
+ t_vec.push_back(token{ tokens::flag,codes::ENTR,"",line });
}
else if (str == "loadfile") {
- t_vec.push_back(token{ tokens::flag,codes::LOAD,"",line - 2 });
+ t_vec.push_back(token{ tokens::flag,codes::LOAD,"",line });
}
else if (str == "version") {
- t_vec.push_back(token{ tokens::flag,codes::VERN,"",line - 2 });
+ t_vec.push_back(token{ tokens::flag,codes::VERN,"",line });
}
else if (str == "using") {
- t_vec.push_back(token{ tokens::flag,codes::USIN,"",line - 2 });
+ t_vec.push_back(token{ tokens::flag,codes::USIN,"",line });
}
else if (str == "disable") {
- t_vec.push_back(token{ tokens::flag,codes::DISA,"",line - 2 });
+ t_vec.push_back(token{ tokens::flag,codes::DISA,"",line });
}
else if (str == "if") {
- t_vec.push_back(token{ tokens::control,codes::IFFF,"",line - 2 });
+ t_vec.push_back(token{ tokens::control,codes::IFFF,"",line });
}
else if (str == "elseif") {
- t_vec.push_back(token{ tokens::control,codes::ELIF,"",line - 2 });
+ t_vec.push_back(token{ tokens::control,codes::ELIF,"",line });
}
else if (str == "while") {
- t_vec.push_back(token{ tokens::control,codes::WHLE,"",line - 2 });
+ t_vec.push_back(token{ tokens::control,codes::WHLE,"",line });
}
else if (str == "true") {
- t_vec.push_back(token{ tokens::True,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::True,codes::NOOP,"",line });
}
else if (str == "false") {
- t_vec.push_back(token{ tokens::False,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::False,codes::NOOP,"",line });
}
else if (str == "else") {
- t_vec.push_back(token{ tokens::control,codes::ELSE,"",line - 2 });
+ t_vec.push_back(token{ tokens::control,codes::ELSE,"",line });
}
else if (str == "and") {
- t_vec.push_back(token{ tokens::And,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::And,codes::NOOP,"",line });
}
else if (str == "or") {
- t_vec.push_back(token{ tokens::Or,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::Or,codes::NOOP,"",line });
}
else if (str == "for") {
- t_vec.push_back(token{ tokens::For,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::For,codes::NOOP,"",line });
}
else if (str == "choice") {
- t_vec.push_back(token{ tokens::control,codes::CHOI,"",line - 2 });
+ t_vec.push_back(token{ tokens::control,codes::CHOI,"",line });
}
else if (str == "return") {
- t_vec.push_back(token{ tokens::ret,codes::RETN,"",line - 2 });
+ t_vec.push_back(token{ tokens::ret,codes::RETN,"",line });
}
else if (str == "nil") {
- t_vec.push_back(token{ tokens::nil,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::nil,codes::NOOP,"",line });
}
else if (str == "goto") {
- t_vec.push_back(token{ tokens::gotoo,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::gotoo,codes::NOOP,"",line });
}
else if (str == "jump") {
- t_vec.push_back(token{ tokens::jump,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::jump,codes::NOOP,"",line });
}
else if (str == "exit") {
- t_vec.push_back(token{ tokens::exit,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::exit,codes::NOOP,"",line });
}
else if (str == "debug") {
- t_vec.push_back(token{ tokens::debug,codes::NOOP,"",line - 2 });
+ t_vec.push_back(token{ tokens::debug,codes::NOOP,"",line });
}
else if (utils::isNum(str) && str.size()!=0) {
- t_vec.push_back(token{ tokens::number,codes::NOOP,stream.processBuffer(buffer),line - 2 });
+ t_vec.push_back(token{ tokens::number,codes::NOOP,stream.processBuffer(buffer),line });
isNum = false;
}
else if (utils::isalphanum(str) && str.size() > 0) {
- t_vec.push_back(token{ tokens::name,codes::NOOP,stream.processBuffer(buffer),line - 2 });
- }
- else {
- // Unknown command!
- /*tok.build(tokens::noop, codes::UNWN);
- tok.name = str;
- tok.line_num = line;*/
+ t_vec.push_back(token{ tokens::name,codes::NOOP,stream.processBuffer(buffer),line });
}
buffer.clear();
}
@@ -306,7 +300,7 @@ namespace dms {
void LineParser::_Parse(tokenstream stream) {
token current = stream.next();
while (stream.peek().type != tokens::eof) {
- //print(current);
+ print(current);
if (current.type == tokens::flag) {
temp = stream.next(tokens::newline);
stream.prev(); // Unconsume the newline piece
@@ -343,7 +337,8 @@ namespace dms {
}
}
// Default block
- if (stream.match(tokens::newline, tokens::bracketo, tokens::name, tokens::bracketc)) {
+ if (stream.match(tokens::newline,tokens::bracketo, tokens::name, tokens::bracketc)) {
+ stream.next();
stream.next();
std::string name = stream.next().name;
createBlock(name, bt_block);
@@ -432,6 +427,6 @@ namespace dms {
// tabs = 0;
current = stream.next();
}
- state->push_chunk(current_chunk->name, current_chunk);
+ createBlock("$END$", bt_block);
}
}
\ No newline at end of file
diff --git a/DMS/LineParserUtils.cpp b/DMS/LineParserUtils.cpp
index 46c5cc2..f137164 100644
--- a/DMS/LineParserUtils.cpp
+++ b/DMS/LineParserUtils.cpp
@@ -82,6 +82,7 @@ namespace dms {
return isBlock(bt_block); // Default block type
}
bool LineParser::isBlock(blocktype bk_type) {
+ //print();
if (current_chunk == nullptr) {
return false; // If a chunk wasn't defined then code was probably defined outside of a block
}
@@ -155,6 +156,27 @@ namespace dms {
}
}
}
+ void LineParser::badSymbol(errors::errortype err,tokenstream* stream) {
+ state->push_error(errors::error{ err,concat("Unexpected symbol '",stream->next().toString(),"'"),true,stream->peek().line_num,current_chunk });
+ }
+ void LineParser::badSymbol(tokenstream* stream) {
+ state->push_error(errors::error{ errors::unknown,concat("Unexpected symbol '",stream->next().toString(),"'"),true,stream->peek().line_num,current_chunk });
+ }
+ void LineParser::badSymbol() {
+ state->push_error(errors::error{ errors::unknown,concat("Unexpected symbol '",_stream->next().toString(),"'"),true,_stream->peek().line_num,current_chunk });
+ }
+ void LineParser::buildSpeed(double s) {
+ cmd* c = new cmd;
+ c->opcode = codes::DSPD;
+ c->args.push(buildValue(s));
+ current_chunk->addCmd(c);
+ }
+ void LineParser::buildWait(double w) {
+ cmd* c = new cmd;
+ c->opcode = codes::WAIT;
+ c->args.push(buildValue(w));
+ current_chunk->addCmd(c);
+ }
bool LineParser::createBlock(std::string bk_name, blocktype bk_type) {
if (current_chunk != nullptr) {
if (!state->chunks.count(current_chunk->name))
@@ -176,6 +198,7 @@ namespace dms {
void LineParser::tokenizer(dms_state* state,std::vector &toks) {
tokenstream stream;
stream.init(&toks);
+ _stream = &stream;
this->state = state; // Grab the pointer to the state and store it within the parser object
_Parse(stream);
}
diff --git a/DMS/chunk.cpp b/DMS/chunk.cpp
index aa066e4..1fd8eaa 100644
--- a/DMS/chunk.cpp
+++ b/DMS/chunk.cpp
@@ -1,5 +1,17 @@
#include "chunk.h"
namespace dms {
+ std::string getBlockType(const blocktype b) {
+ if (b == bt_block)
+ return "block";
+ if (b == bt_method)
+ return "method";
+ if (b == bt_env)
+ return "env";
+ if (b == bt_character)
+ return "character";
+ if (b == bt_menu)
+ return "menu";
+ }
void chunk::addCmd(cmd* c) {
cmds.push_back(c);
}
diff --git a/DMS/chunk.h b/DMS/chunk.h
index 15897b7..6b067be 100644
--- a/DMS/chunk.h
+++ b/DMS/chunk.h
@@ -1,5 +1,6 @@
#pragma once
#include "cmd.h"
+#include
#include
#include