Fixed error line number bug, started working on compound disp cmd

This commit is contained in:
Ryan Ward 2020-08-31 23:04:36 -04:00
parent c504f41dcb
commit 120ad85461
32 changed files with 321 additions and 132 deletions

View File

@ -25,8 +25,8 @@
<Keywords name="Folders in comment, middle"></Keywords> <Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords> <Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1">ENABLE DISABLE LOADFILE ENTRY USING VERSION as AS enable disable loadfile entry using version</Keywords> <Keywords name="Keywords1">ENABLE DISABLE LOADFILE ENTRY USING VERSION as AS enable disable loadfile entry using version</Keywords>
<Keywords name="Keywords2">if then return and or true false for while choice end else elseif goto jump exit</Keywords> <Keywords name="Keywords2">if then return and or true false for while choice end else elseif goto jump exit debug nil</Keywords>
<Keywords name="Keywords3">leaking debugging warnings statesave hostmsg</Keywords> <Keywords name="Keywords3">leaking debugging warnings statesave omniscient</Keywords>
<Keywords name="Keywords4">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</Keywords> <Keywords name="Keywords4">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</Keywords>
<Keywords name="Keywords5">_VERSION</Keywords> <Keywords name="Keywords5">_VERSION</Keywords>
<Keywords name="Keywords6">filesystem extendedDefine</Keywords> <Keywords name="Keywords6">filesystem extendedDefine</Keywords>
@ -36,19 +36,19 @@
</KeywordLists> </KeywordLists>
<Styles> <Styles>
<WordsStyle name="DEFAULT" fgColor="C3C3C3" bgColor="293135" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x632E;&#x6D6F;&#x656D;&#x746E;s&#x6F77;&#x6472;&#x3873;&#xD900;&#x0005;" fontStyle="0" fontSize="12" nesting="0" /> <WordsStyle name="DEFAULT" fgColor="C3C3C3" bgColor="293135" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x632E;&#x6D6F;&#x656D;&#x746E;s&#x6F77;&#x6472;&#x3873;&#xD900;&#x0005;" fontStyle="0" fontSize="12" nesting="0" />
<WordsStyle name="COMMENTS" fgColor="808080" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x662E;&#x6C6F;&#x6564;&#x7372;&#x6E49;&#x6F43;&#x6564;&#x4D31;&#x6469;&#x6C64;e&#x4CD8;&#x1400;&#x10A8;&#x8E00;&#x6966;&#x656C;&#x7973;&#x7473;&#x6D65;&#x6500;&#x7478;&#x6E65;&#x6564;&#x4464;&#x6665;&#x6E69;e" fontStyle="0" fontSize="12" nesting="0" /> <WordsStyle name="COMMENTS" fgColor="808080" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x662E;&#x6C6F;&#x6564;&#x7372;&#x6E49;&#x6F43;&#x6564;&#x4D31;&#x6469;&#x6C64;e&#x4CD8;&#x1400;&#x10A8;&#x8000;&#x6966;&#x656C;&#x7973;&#x7473;&#x6D65;&#x6500;&#x7478;&#x6E65;&#x6564;&#x4464;&#x6665;&#x6E69;e" fontStyle="0" fontSize="12" nesting="0" />
<WordsStyle name="LINE COMMENTS" fgColor="808080" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x662E;&#x6C6F;&#x6564;&#x7372;&#x6E49;&#x6F43;&#x6564;&#x4331;&#x6F6C;&#x6573;" fontStyle="0" fontSize="12" nesting="0" /> <WordsStyle name="LINE COMMENTS" fgColor="808080" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x662E;&#x6C6F;&#x6564;&#x7372;&#x6E49;&#x6F43;&#x6564;&#x4331;&#x6F6C;&#x6573;" fontStyle="0" fontSize="12" nesting="0" />
<WordsStyle name="NUMBERS" fgColor="FF8080" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x642E;&#x6365;&#x6D69;&#x6C61;&#x6553;&#x6170;&#x6172;&#x6F74;r" fontStyle="0" fontSize="12" nesting="0" /> <WordsStyle name="NUMBERS" fgColor="FF8080" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x642E;&#x6365;&#x6D69;&#x6C61;&#x6553;&#x6170;&#x6172;&#x6F74;r" fontStyle="0" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS1" fgColor="FF8000" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x702E;&#x6572;&#x6966;&#x4B78;&#x7965;&#x6F77;&#x6472;&#x3373;" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS1" fgColor="FF8000" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x702E;&#x6572;&#x6966;&#x4B78;&#x7965;&#x6F77;&#x6472;&#x3373;" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS2" fgColor="0080C0" bgColor="293134" fontName="&#xCF78;&#x0307;&#x9E90;&#x0295;&#x080B;" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS2" fgColor="0080C0" bgColor="293134" fontName="&#xCF00;&#x0307;&#x9E90;&#x0295;&#x080B;" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS3" fgColor="408080" bgColor="293134" fontName="0o&#x237B;&#x78FE;&#xCD98;&#x0307; " fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS3" fgColor="408080" bgColor="293134" fontName="" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS4" fgColor="5959AC" bgColor="293134" fontName="&#x0001;" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS4" fgColor="5959AC" bgColor="293134" fontName="" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS5" fgColor="FF0080" bgColor="293134" fontName="&#xA308;&#x0308;&#x0001;&#x78FE;&#xCFF0;&#x0307;&#xA200;&#x0295;&#x080B;" fontStyle="0" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS5" fgColor="FF0080" bgColor="293134" fontName="&#xA308;&#x0308;&#x0001;&#x78FE;&#xCF00;&#x0307;&#xA200;&#x0295;&#x080B;" fontStyle="0" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS6" fgColor="149311" bgColor="293134" fontName="&#x95A8;&#x0295;MMENT" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS6" fgColor="149311" bgColor="293134" fontName="&#x95A8;&#x0295;MMENT" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS7" fgColor="0080C0" bgColor="293134" fontName="293134" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="KEYWORDS7" fgColor="0080C0" bgColor="293134" fontName="293134" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="&#xE1E8;&#x0308;STRUC" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="&#xE1E8;&#x0308;STRUC" fontStyle="0" nesting="0" />
<WordsStyle name="OPERATORS" fgColor="EAC195" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x6E2E;&#x7365;&#x6974;&#x676E;&#x322E;0&#x030F;&#x271F;&#x1478;&#x0234;&#x8000;&#x271E;&#x1479;&#x0318;&#x8800;&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x6E2E;&#x7365;&#x6974;&#x676E;&#x322E;3" fontStyle="1" nesting="0" /> <WordsStyle name="OPERATORS" fgColor="EAC195" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x6E2E;&#x7365;&#x6974;&#x676E;&#x322E;0&#x030F;&#x271F;&#x1478;&#x0234;&#x8000;&#x271E;&#x1479;&#x0318;&#x8000;&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x6E2E;&#x7365;&#x6974;&#x676E;&#x322E;3" fontStyle="1" nesting="0" />
<WordsStyle name="FOLDER IN CODE1" fgColor="EAC195" bgColor="293134" fontName="&#x0015;" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="FOLDER IN CODE1" fgColor="EAC195" bgColor="293134" fontName="" fontStyle="1" fontSize="12" nesting="0" />
<WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="FFCD22" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="FFCD22" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS1" fgColor="8080C0" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x6E2E;&#x7365;&#x6974;&#x676E;&#x312E;9(&#x008E;" fontStyle="1" fontSize="12" nesting="0" /> <WordsStyle name="DELIMITERS1" fgColor="8080C0" bgColor="293134" fontName="&#x7375;&#x7265;&#x6544;&#x6966;&#x656E;&#x6E2E;&#x7365;&#x6974;&#x676E;&#x312E;9(&#x008E;" fontStyle="1" fontSize="12" nesting="0" />

View File

@ -1,5 +1,2 @@
 LineParserBuilds.cpp  LineParserParse.cpp
LineParserParse.cpp
chunk.cpp
Generating Code...
DMS.vcxproj -> F:\VSCWorkspace\DMS\Debug\DMS.exe DMS.vcxproj -> F:\VSCWorkspace\DMS\Debug\DMS.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -56,6 +56,7 @@ namespace dms {
std::vector<tokens::token> temp; std::vector<tokens::token> temp;
std::vector<tokens::token> tdump; std::vector<tokens::token> tdump;
size_t tabs = 0; size_t tabs = 0;
tokenstream* _stream;
dms_state* state; dms_state* state;
void doCheck(passer* stream, std::vector<tokens::token>* t_vec, size_t line, bool& isNum, bool& hasDec, std::vector<uint8_t>* buffer); void doCheck(passer* stream, std::vector<tokens::token>* t_vec, size_t line, bool& isNum, bool& hasDec, std::vector<uint8_t>* buffer);
void _Parse(tokenstream stream); void _Parse(tokenstream stream);
@ -73,8 +74,14 @@ namespace dms {
void buildGoto(std::string g, bool v = false); void buildGoto(std::string g, bool v = false);
void buildNoop(); void buildNoop();
void buildLabel(std::string l); void buildLabel(std::string l);
void buildSpeed(double s);
void buildWait(double w);
// Utils // Utils
void badSymbol(errors::errortype err, tokenstream* stream);
void badSymbol(tokenstream* stream);
void badSymbol();
void tokenDump(std::vector<tokens::token>* v); void tokenDump(std::vector<tokens::token>* v);
bool createBlock(std::string bk_name, blocktype bk_type); bool createBlock(std::string bk_name, blocktype bk_type);

View File

@ -15,11 +15,12 @@ namespace dms {
print("DISP := ", msg); print("DISP := ", msg);
cmd* c = new cmd; cmd* c = new cmd;
c->opcode = codes::DISP; c->opcode = codes::DISP;
c->args.push(buildValue());
c->args.push(buildValue(msg)); c->args.push(buildValue(msg));
current_chunk->addCmd(c); // Add the cmd to the current chunk current_chunk->addCmd(c); // Add the cmd to the current chunk
return true; 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 // We might have to handle scope here
// Here we match 'Ryan: "This guy said this!"' Note the colon is needed! // Here we match 'Ryan: "This guy said this!"' Note the colon is needed!
stream->next(); // Standard consumption stream->next(); // Standard consumption
@ -29,12 +30,66 @@ namespace dms {
print("DISP := ", name, " says '", msg, "'"); print("DISP := ", name, " says '", msg, "'");
cmd* c = new cmd; cmd* c = new cmd;
c->opcode = codes::DISP; c->opcode = codes::DISP;
c->args.push(buildValue(msg));
c->args.push(buildValue(name)); c->args.push(buildValue(name));
c->args.push(buildValue(msg));
current_chunk->addCmd(c); // Add the cmd to the current chunk current_chunk->addCmd(c); // Add the cmd to the current chunk
// We might have to consume a newline... Depends on what's next // We might have to consume a newline... Depends on what's next
return true; 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" // emotion: "path"
// looks like a simple disp command // looks like a simple disp command
else if (isBlock(bt_character) && stream->match(tokens::tab, tokens::name, tokens::colon, tokens::string, tokens::newline)) { 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(); stream->next();
} }
else if (stream->match(tokens::cbracketo) && start) { 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)) { else if (stream->match(tokens::string)) {
std::string name = stream->next().name; std::string name = stream->next().name;
@ -148,7 +203,7 @@ namespace dms {
stream->next(); // Consume stream->next(); // Consume
} }
else { 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); buildLabel(str);
@ -282,7 +337,7 @@ namespace dms {
} }
else { else {
cleanup(tempval); // Cleanup cleanup(tempval); // Cleanup
state->push_error(errors::error{ errors::badtoken,concat("Invalid symbol: ",tempstream.peek()),true, tempstream.peek().line_num,current_chunk }); badSymbol(stream);
} }
} }
} }

View File

@ -23,11 +23,11 @@ namespace dms {
if (myfile.is_open()) if (myfile.is_open())
{ {
std::string line; 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! // This way you are allowed to start a block at the top of the screen!
while (std::getline(myfile, line)) { while (std::getline(myfile, line)) {
trim(line); trim(line);
rawdata << line << "\n"; rawdata << line << ";\n";
} }
myfile.close(); myfile.close();
//std::cout << rawdata.str() << std::endl; //std::cout << rawdata.str() << std::endl;
@ -53,9 +53,9 @@ namespace dms {
} }
else if (data == '\n') { else if (data == '\n') {
doCheck(&stream, &t_vec, line-2, isNum, hasDec, &buffer); 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) { 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(); buffer.clear();
isNum = false; isNum = false;
} }
@ -70,7 +70,7 @@ namespace dms {
stream.next(); stream.next();
} }
else if (data == ':' && stream.peek() == ':' && labelStart) { 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(); buffer.clear();
stream.next(); stream.next();
labelStart = false; labelStart = false;
@ -81,7 +81,7 @@ namespace dms {
} }
else if (data == '"' && isStr) { else if (data == '"' && isStr) {
isStr = false; 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(); buffer.clear();
} }
else if (isStr) { else if (isStr) {
@ -99,190 +99,184 @@ namespace dms {
buffer.push_back(data); buffer.push_back(data);
} }
else if (data == '.' && isNum && hasDec) { 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 == '[') { else if (data == '[') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::bracketo,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::bracketo,codes::NOOP,"",line });
} }
else if (data == ']') { else if (data == ']') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::bracketc,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::bracketc,codes::NOOP,"",line });
} }
else if (data == '(') { else if (data == '(') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::parao,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::parao,codes::NOOP,"",line });
} }
else if (data == ')') { else if (data == ')') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::parac,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::parac,codes::NOOP,"",line });
} }
else if (data == ',') { else if (data == ',') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::seperator,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::seperator,codes::NOOP,"",line });
} }
else if (data == '.') { else if (data == '.') {
//doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer); //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 == '{') { else if (data == '{') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::cbracketo,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::cbracketo,codes::NOOP,"",line });
} }
else if (data == '}') { else if (data == '}') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::cbracketc,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::cbracketc,codes::NOOP,"",line });
} }
else if (data == '+') { else if (data == '+') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::plus,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::plus,codes::NOOP,"",line });
} }
else if (data == '-') { else if (data == '-') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::minus,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::minus,codes::NOOP,"",line });
} }
else if (data == '*') { else if (data == '*') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::multiply,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::multiply,codes::NOOP,"",line });
} }
else if (data == '/') { else if (data == '/') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::divide,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::divide,codes::NOOP,"",line });
} }
else if (data == '^') { else if (data == '^') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::caret,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::caret,codes::NOOP,"",line });
} }
else if (data == '%') { else if (data == '%') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::percent,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::percent,codes::NOOP,"",line });
} }
else if (data == '=') { else if (data == '=') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::equal,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::equal,codes::NOOP,"",line });
} }
else if (data == ':') { else if (data == ':') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::colon,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::colon,codes::NOOP,"",line });
} }
else if (data == ';') { else if (data == ';') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::newline,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::newline,codes::NOOP,"",line });
} }
else if (data == '!') { else if (data == '!') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::exclamation,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::exclamation,codes::NOOP,"",line });
} }
else if (data == '~') { else if (data == '~') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::tilde,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::tilde,codes::NOOP,"",line });
} }
else if (data == '`') { else if (data == '`') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::backtick,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::backtick,codes::NOOP,"",line });
} }
else if (data == '@') { else if (data == '@') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::at,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::at,codes::NOOP,"",line });
} }
else if (data == '#') { else if (data == '#') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::pound,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::pound,codes::NOOP,"",line });
} }
else if (data == '$') { else if (data == '$') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::dollar,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::dollar,codes::NOOP,"",line });
} }
else if (data == '&') { else if (data == '&') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::ampersand,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::ampersand,codes::NOOP,"",line });
} }
else if (data == '\t') { else if (data == '\t') {
doCheck(&stream, &t_vec, line - 2, isNum, hasDec, &buffer); doCheck(&stream, &t_vec, line, isNum, hasDec, &buffer);
t_vec.push_back(token{ tokens::tab,codes::NOOP,"",line - 2 }); t_vec.push_back(token{ tokens::tab,codes::NOOP,"",line });
} }
if (data == ' ' && !isStr) { // tokens end with a space if (data == ' ' && !isStr) { // tokens end with a space
std::string str = stream.processBuffer(buffer); std::string str = stream.processBuffer(buffer);
tolower(str); tolower(str);
if (str == "enable") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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") { 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) { 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; isNum = false;
} }
else if (utils::isalphanum(str) && str.size() > 0) { else if (utils::isalphanum(str) && str.size() > 0) {
t_vec.push_back(token{ tokens::name,codes::NOOP,stream.processBuffer(buffer),line - 2 }); t_vec.push_back(token{ tokens::name,codes::NOOP,stream.processBuffer(buffer),line });
}
else {
// Unknown command!
/*tok.build(tokens::noop, codes::UNWN);
tok.name = str;
tok.line_num = line;*/
} }
buffer.clear(); buffer.clear();
} }
@ -306,7 +300,7 @@ namespace dms {
void LineParser::_Parse(tokenstream stream) { void LineParser::_Parse(tokenstream stream) {
token current = stream.next(); token current = stream.next();
while (stream.peek().type != tokens::eof) { while (stream.peek().type != tokens::eof) {
//print(current); print(current);
if (current.type == tokens::flag) { if (current.type == tokens::flag) {
temp = stream.next(tokens::newline); temp = stream.next(tokens::newline);
stream.prev(); // Unconsume the newline piece stream.prev(); // Unconsume the newline piece
@ -343,7 +337,8 @@ namespace dms {
} }
} }
// Default block // 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(); stream.next();
std::string name = stream.next().name; std::string name = stream.next().name;
createBlock(name, bt_block); createBlock(name, bt_block);
@ -432,6 +427,6 @@ namespace dms {
// tabs = 0; // tabs = 0;
current = stream.next(); current = stream.next();
} }
state->push_chunk(current_chunk->name, current_chunk); createBlock("$END$", bt_block);
} }
} }

View File

@ -82,6 +82,7 @@ namespace dms {
return isBlock(bt_block); // Default block type return isBlock(bt_block); // Default block type
} }
bool LineParser::isBlock(blocktype bk_type) { bool LineParser::isBlock(blocktype bk_type) {
//print();
if (current_chunk == nullptr) { if (current_chunk == nullptr) {
return false; // If a chunk wasn't defined then code was probably defined outside of a block 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) { bool LineParser::createBlock(std::string bk_name, blocktype bk_type) {
if (current_chunk != nullptr) { if (current_chunk != nullptr) {
if (!state->chunks.count(current_chunk->name)) if (!state->chunks.count(current_chunk->name))
@ -176,6 +198,7 @@ namespace dms {
void LineParser::tokenizer(dms_state* state,std::vector<token> &toks) { void LineParser::tokenizer(dms_state* state,std::vector<token> &toks) {
tokenstream stream; tokenstream stream;
stream.init(&toks); stream.init(&toks);
_stream = &stream;
this->state = state; // Grab the pointer to the state and store it within the parser object this->state = state; // Grab the pointer to the state and store it within the parser object
_Parse(stream); _Parse(stream);
} }

View File

@ -1,5 +1,17 @@
#include "chunk.h" #include "chunk.h"
namespace dms { 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) { void chunk::addCmd(cmd* c) {
cmds.push_back(c); cmds.push_back(c);
} }

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "cmd.h" #include "cmd.h"
#include <string>
#include <vector> #include <vector>
#include <map> #include <map>
namespace dms { namespace dms {
@ -10,6 +11,7 @@ namespace dms {
bt_character, bt_character,
bt_menu bt_menu
}; };
std::string getBlockType(const blocktype b);
struct chunk struct chunk
{ {
blocktype type = bt_block; blocktype type = bt_block;

View File

@ -1,3 +1,40 @@
#pragma once #pragma once
#include "Codes.h" #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" ,"GOTO","JUMP","RETN", "EXIT", "DEBG" }; 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",
"DEBG",
"DSPD",
"DACT",
"WAIT",
"APND",
"SSPK"
};

View File

@ -17,7 +17,6 @@ namespace dms::codes {
CHOI, CHOI,
OPTN, OPTN,
FORE, FORE,
UNWN,
WHLE, WHLE,
FUNC, FUNC,
IFFF, IFFF,
@ -34,7 +33,12 @@ namespace dms::codes {
JUMP, JUMP,
RETN, RETN,
EXIT, EXIT,
DEBG DEBG,
DSPD,
DACT,
WAIT,
APND,
SSPK
}; };
extern const std::string list[]; extern const std::string list[];
static bool isControl(const op code) { static bool isControl(const op code) {

24
DMS/diaplsy cmd.txt Normal file
View File

@ -0,0 +1,24 @@
Chat Stuff
--------------------------------------------------------------------------
DISP spk "msg" display message from a speaker
DSPD # set display speed
DACT path
WAIT # delay until next cmd is processed
APND "msg" appends text to last message, keeping all applied stats
SSPK spk sets the speaker
Ryan: {
speed 100
calm "Hello Bob, "
wait 0.455
excited "how are you doing? "
"It's a nice day we are having!"
}
DISP ""
DSPD Ryan 100
DACT Ryan [path defined by: Ryan.calm]
APND Ryan "Hello Bob, "
WAIT 0.455
DACT Ryan [path defined by: Ryan.excited]
APND "how are you doing?"

View File

@ -2,11 +2,11 @@
namespace dms { namespace dms {
dms_state::dms_state() { dms_state::dms_state() {
// We should define the defaults for the enables // We should define the defaults for the enables
//chunks.insert_or_assign("leaking",false); enables.insert_or_assign("leaking",false);
//chunks.insert_or_assign("debugging",false); enables.insert_or_assign("debugging",false);
//chunks.insert_or_assign("warnings",false); // enables.insert_or_assign("warnings",false); //
//chunks.insert_or_assign("statesave",true); // Allows you to save state enables.insert_or_assign("statesave",true); // Allows you to save state
//chunks.insert_or_assign("omniscient",true); // Allows you to know who's who when you first meet them enables.insert_or_assign("omniscient",true); // Allows you to know who's who when you first meet them
} }
bool dms_state::isEnabled(std::string flag) { bool dms_state::isEnabled(std::string flag) {
if (enables.count(flag)) { if (enables.count(flag)) {
@ -18,7 +18,7 @@ namespace dms {
std::cout << std::endl << "STATE DUMP" << std::endl << "Number of chunks: " << chunks.size(); std::cout << std::endl << "STATE DUMP" << std::endl << "Number of chunks: " << chunks.size();
std::ofstream outputFile("dump.bin"); std::ofstream outputFile("dump.bin");
for (const auto& [key, val] : chunks) { for (const auto& [key, val] : chunks) {
std::cout << "Key: " << key << " Value: " << *val << '\n'; std::cout << "Key: " << key << "<" << getBlockType(val->type) << ">" << std::endl << *val << std::endl;
} }
//If the error has a chunk then we get the data from it //If the error has a chunk then we get the data from it
if (err.current_chunk != nullptr) { if (err.current_chunk != nullptr) {
@ -27,10 +27,10 @@ namespace dms {
outputFile.close(); outputFile.close();
} }
void dms_state::dump() { void dms_state::dump() {
std::cout << "Number of chunks: " << chunks.size(); std::cout << "Number of chunks: " << chunks.size() << std::endl;
std::ofstream outputFile("dump.bin"); std::ofstream outputFile("dump.bin");
for (const auto& [key, val] : chunks) { for (const auto& [key, val] : chunks) {
std::cout << "Key: " << key << " Value: " << *val << '\n'; std::cout << "Key: " << key << "<" << getBlockType(val->type) << ">" << std::endl << *val << std::endl;
} }
outputFile.close(); outputFile.close();
} }
@ -39,11 +39,9 @@ namespace dms {
} }
void dms_state::push_error(errors::error err) { void dms_state::push_error(errors::error err) {
std::cout << err.err_msg << " On Line <" << err.linenum << ">" << std::endl; std::cout << err.err_msg << " On Line <" << err.linenum << ">" << std::endl;
if (err.crash) { if (err.crash)
dump(err);
std::exit(err.code); std::exit(err.code);
} }
}
void dms_state::push_warning(errors::error err) { void dms_state::push_warning(errors::error err) {
err.crash = false; // Force code to not crash then push the error err.crash = false; // Force code to not crash then push the error
if(enables.count("warnings")) if(enables.count("warnings"))

View File

@ -1,21 +1,25 @@
Token Dump: Token Dump:
Line <4294967295>NOOP newline Line <1>NOOP newline
Line <0>NOOP newline Line <1>NOOP newline
Line <1>NOOP bracketo Line <1>NOOP bracketo
Line <1>NOOP name default Line <1>NOOP name default
Line <1>NOOP colon Line <1>NOOP colon
Line <1>NOOP name char Line <1>NOOP name char
Line <1>NOOP bracketc Line <1>NOOP bracketc
Line <1>NOOP newline Line <1>NOOP newline
Line <1>NOOP newline
Line <2>NOOP newline Line <2>NOOP newline
Line <3>NOOP name money Line <3>NOOP name money
Line <3>NOOP equal Line <3>NOOP equal
Line <3>NOOP number 0 Line <3>NOOP number 0
Line <3>NOOP newline Line <3>NOOP newline
Line <3>NOOP newline
Line <4>NOOP name test Line <4>NOOP name test
Line <4>NOOP equal Line <4>NOOP equal
Line <4>NOOP nil nil Line <4>NOOP nil nil
Line <4>NOOP newline Line <4>NOOP newline
Line <4>NOOP newline
Line <5>NOOP newline
Line <5>NOOP newline Line <5>NOOP newline
Line <6>NOOP bracketo Line <6>NOOP bracketo
Line <6>NOOP name Ryan Line <6>NOOP name Ryan
@ -23,23 +27,29 @@ Line <6>NOOP colon
Line <6>NOOP name char Line <6>NOOP name char
Line <6>NOOP bracketc Line <6>NOOP bracketc
Line <6>NOOP newline Line <6>NOOP newline
Line <6>NOOP newline
Line <7>NOOP name age Line <7>NOOP name age
Line <7>NOOP equal Line <7>NOOP equal
Line <7>NOOP number 21 Line <7>NOOP number 21
Line <7>NOOP newline Line <7>NOOP newline
Line <7>NOOP newline
Line <8>NOOP name money Line <8>NOOP name money
Line <8>NOOP equal Line <8>NOOP equal
Line <8>NOOP number 1000 Line <8>NOOP number 1000
Line <8>NOOP newline Line <8>NOOP newline
Line <8>NOOP newline
Line <9>NOOP newline Line <9>NOOP newline
Line <10>NOOP name calm Line <10>NOOP name calm
Line <10>NOOP colon Line <10>NOOP colon
Line <10>NOOP string ./path/to/file Line <10>NOOP string ./path/to/file
Line <10>NOOP newline Line <10>NOOP newline
Line <10>NOOP newline
Line <11>NOOP name excited Line <11>NOOP name excited
Line <11>NOOP colon Line <11>NOOP colon
Line <11>NOOP string ./path/to/file Line <11>NOOP string ./path/to/file
Line <11>NOOP newline Line <11>NOOP newline
Line <11>NOOP newline
Line <12>NOOP newline
Line <12>NOOP newline Line <12>NOOP newline
Line <13>NOOP bracketo Line <13>NOOP bracketo
Line <13>NOOP name step Line <13>NOOP name step
@ -54,6 +64,7 @@ Line <13>NOOP name c
Line <13>NOOP parac Line <13>NOOP parac
Line <13>NOOP bracketc Line <13>NOOP bracketc
Line <13>NOOP newline Line <13>NOOP newline
Line <13>NOOP newline
Line <14>NOOP string Testing... Line <14>NOOP string Testing...
Line <14>NOOP newline Line <14>NOOP newline
Line <15>NOOP name d Line <15>NOOP name d
@ -66,21 +77,27 @@ Line <15>NOOP parac
Line <15>NOOP divide Line <15>NOOP divide
Line <15>NOOP name c Line <15>NOOP name c
Line <15>NOOP newline Line <15>NOOP newline
Line <15>NOOP newline
Line <16>NOOP name e Line <16>NOOP name e
Line <16>NOOP equal Line <16>NOOP equal
Line <16>NOOP string somestring Line <16>NOOP string somestring
Line <16>NOOP newline Line <16>NOOP newline
Line <16>NOOP newline
Line <17>NOOP name e Line <17>NOOP name e
Line <17>NOOP equal Line <17>NOOP equal
Line <17>NOOP nil nil Line <17>NOOP nil nil
Line <17>NOOP newline Line <17>NOOP newline
Line <17>NOOP newline
Line <18>NOOP name g Line <18>NOOP name g
Line <18>NOOP equal Line <18>NOOP equal
Line <18>NOOP false false Line <18>NOOP false false
Line <18>NOOP newline Line <18>NOOP newline
Line <18>NOOP newline
Line <19>RETN ret Line <19>RETN ret
Line <19>NOOP name d Line <19>NOOP name d
Line <19>NOOP newline Line <19>NOOP newline
Line <19>NOOP newline
Line <20>NOOP newline
Line <20>NOOP newline Line <20>NOOP newline
Line <21>NOOP bracketo Line <21>NOOP bracketo
Line <21>NOOP name inventory Line <21>NOOP name inventory
@ -88,44 +105,53 @@ Line <21>NOOP colon
Line <21>NOOP name env Line <21>NOOP name env
Line <21>NOOP bracketc Line <21>NOOP bracketc
Line <21>NOOP newline Line <21>NOOP newline
Line <21>NOOP newline
Line <22>NOOP name slot1 Line <22>NOOP name slot1
Line <22>NOOP number Line <22>NOOP number
Line <22>NOOP equal Line <22>NOOP equal
Line <22>NOOP string Line <22>NOOP string
Line <22>NOOP newline Line <22>NOOP newline
Line <22>NOOP newline
Line <23>NOOP name slot2 Line <23>NOOP name slot2
Line <23>NOOP number Line <23>NOOP number
Line <23>NOOP equal Line <23>NOOP equal
Line <23>NOOP string Line <23>NOOP string
Line <23>NOOP newline Line <23>NOOP newline
Line <23>NOOP newline
Line <24>NOOP name slot3 Line <24>NOOP name slot3
Line <24>NOOP number Line <24>NOOP number
Line <24>NOOP equal Line <24>NOOP equal
Line <24>NOOP string Line <24>NOOP string
Line <24>NOOP newline Line <24>NOOP newline
Line <24>NOOP newline
Line <25>NOOP name slot4 Line <25>NOOP name slot4
Line <25>NOOP number Line <25>NOOP number
Line <25>NOOP equal Line <25>NOOP equal
Line <25>NOOP string Line <25>NOOP string
Line <25>NOOP newline Line <25>NOOP newline
Line <25>NOOP newline
Line <26>NOOP name slot5 Line <26>NOOP name slot5
Line <26>NOOP number Line <26>NOOP number
Line <26>NOOP equal Line <26>NOOP equal
Line <26>NOOP string Line <26>NOOP string
Line <26>NOOP newline Line <26>NOOP newline
Line <26>NOOP newline
Line <27>NOOP name slot6 Line <27>NOOP name slot6
Line <27>NOOP number Line <27>NOOP number
Line <27>NOOP equal Line <27>NOOP equal
Line <27>NOOP string Line <27>NOOP string
Line <27>NOOP newline Line <27>NOOP newline
Line <27>NOOP newline
Line <28>NOOP name slot7 Line <28>NOOP name slot7
Line <28>NOOP number Line <28>NOOP number
Line <28>NOOP equal Line <28>NOOP equal
Line <28>NOOP string Line <28>NOOP string
Line <28>NOOP newline Line <28>NOOP newline
Line <28>NOOP newline
Line <29>NOOP name slot8 Line <29>NOOP name slot8
Line <29>NOOP number Line <29>NOOP number
Line <29>NOOP equal Line <29>NOOP equal
Line <29>NOOP string Line <29>NOOP string
Line <29>NOOP newline Line <29>NOOP newline
Line <31>NOOP eof Line <29>NOOP newline
Line <29>NOOP eof

View File

@ -11,7 +11,8 @@ namespace dms::errors {
badtoken, badtoken,
block_already_defined, block_already_defined,
choice_unknown, choice_unknown,
nested_function nested_function,
disp_unknown
}; };
struct error { struct error {
errortype code=unknown; errortype code=unknown;

View File

@ -11,7 +11,7 @@
excited: "./path/to/file" excited: "./path/to/file"
[step:function(a,b,c)] [step:function(a,b,c)]
"Testing..." "Testing..." // testing
d = (100 + b) / c d = (100 + b) / c
e = "somestring" e = "somestring"
e = nil e = nil

View File

@ -1,17 +1,20 @@
entry main entry main
enable warnings enable warnings
disable omniscient disable omniscient
//enable debugging enable debugging
loadfile "loadtest.dms" loadfile "loadtest.dms"
version 1.2 version 1.2
using extendedDefine using extendedDefine
[testblockpro]
"hehe"
[main] { [main]
Ryan: "This works!" Ryan: "This works!"
DEBUG "What's up" // Debug lines are removed when debug mode is disabled DEBUG "What's up" // Debug lines are removed when debug mode is disabled
Ryan: { Ryan: {
speed 100%;calm "Hello Bob, " true
speed 100;calm "Hello Bob, "
wait 0.455 wait 0.455
excited "how are you doing?" excited "how are you doing?"
// Becomes: Hello Bob, how are you doing? // Becomes: Hello Bob, how are you doing?
@ -62,7 +65,6 @@ using extendedDefine
"nine" exit "nine" exit
"ten" exit 0 "ten" exit 0
} }
}
@ -73,3 +75,4 @@ using extendedDefine
[newblock:function()] [newblock:function()]
"Test #2" "Test #2"
"Does it parse this part properly?" "Does it parse this part properly?"
"huh"

View File

@ -68,8 +68,13 @@ namespace dms::tokens {
raw = o; raw = o;
name = s; name = s;
} }
std::string toString() {
std::stringstream str;
str << name;
return str.str();
}
friend std::ostream& operator << (std::ostream& out, const token& c) { friend std::ostream& operator << (std::ostream& out, const token& c) {
const std::string temp1[] = { const std::string tokenlist[] = {
"none", "none",
"noop", "noop",
"flag", "flag",
@ -116,7 +121,7 @@ namespace dms::tokens {
"ampersand", "ampersand",
"nil" "nil"
}; };
out << "Line <" << c.line_num << ">" << codes::list[c.raw] << " " << temp1[c.type] << " \t\t " << c.name; out << "Line <" << c.line_num << ">" << codes::list[c.raw] << " " << tokenlist[c.type] << " \t\t " << c.name;
return out; return out;
} }
}; };

Binary file not shown.

Binary file not shown.

Binary file not shown.