Got cmds for a bunch of match processes

This commit is contained in:
Ryan Ward 2020-08-30 00:59:19 -04:00
parent e6e5311a04
commit 6110fad14c
42 changed files with 439 additions and 243 deletions

View File

@ -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();*/
}

View File

@ -172,7 +172,34 @@
<ClInclude Include="utils.h" />
<ClInclude Include="value.h" />
</ItemGroup>
<ItemGroup>
<None Include="C:\Users\rayam\Desktop\sfml\openal32.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-audio-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-audio-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-graphics-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-graphics-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-network-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-network-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-system-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-system-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-window-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-window-d-2.dll" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\sfml-audio.redist.2.4.2.0\build\native\sfml-audio.redist.targets" Condition="Exists('..\packages\sfml-audio.redist.2.4.2.0\build\native\sfml-audio.redist.targets')" />
<Import Project="..\packages\sfml-system.redist.2.4.2.0\build\native\sfml-system.redist.targets" Condition="Exists('..\packages\sfml-system.redist.2.4.2.0\build\native\sfml-system.redist.targets')" />
<Import Project="..\packages\sfml-system.2.4.2.0\build\native\sfml-system.targets" Condition="Exists('..\packages\sfml-system.2.4.2.0\build\native\sfml-system.targets')" />
<Import Project="..\packages\sfml-audio.2.4.2.0\build\native\sfml-audio.targets" Condition="Exists('..\packages\sfml-audio.2.4.2.0\build\native\sfml-audio.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\sfml-audio.redist.2.4.2.0\build\native\sfml-audio.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\sfml-audio.redist.2.4.2.0\build\native\sfml-audio.redist.targets'))" />
<Error Condition="!Exists('..\packages\sfml-system.redist.2.4.2.0\build\native\sfml-system.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\sfml-system.redist.2.4.2.0\build\native\sfml-system.redist.targets'))" />
<Error Condition="!Exists('..\packages\sfml-system.2.4.2.0\build\native\sfml-system.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\sfml-system.2.4.2.0\build\native\sfml-system.targets'))" />
<Error Condition="!Exists('..\packages\sfml-audio.2.4.2.0\build\native\sfml-audio.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\sfml-audio.2.4.2.0\build\native\sfml-audio.targets'))" />
</Target>
</Project>

View File

@ -105,4 +105,18 @@
<Filter>Header Files\DMS</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="C:\Users\rayam\Desktop\sfml\openal32.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-audio-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-audio-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-graphics-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-graphics-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-network-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-network-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-system-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-system-d-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-window-2.dll" />
<None Include="C:\Users\rayam\Desktop\sfml\sfml-window-d-2.dll" />
</ItemGroup>
</Project>

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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\|

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

@ -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<tokens::token> &tok);
public:
//Refer to streams.cpp for the match_process_CMD code.

View File

@ -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!
}
/// <summary>
/// Recursively parse through function related tokens
/// </summary>
/// <param name="stream"></param>
/// <param name="v"></param>
/// <returns></returns>
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!

View File

@ -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 <FLAG IDENTIFIER> " << " 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);
}
}

View File

@ -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;
}
}

BIN
DMS/Nadia.ogg Normal file

Binary file not shown.

View File

@ -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
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "cmd.h"
#include <vector>
#include <map>
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<std::string, size_t> 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;
}
};
}

View File

@ -1,11 +1,25 @@
#pragma once
#include "value.h"
#include "codes.h"
#include <ostream>
#include <vector>
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();
}
};
}

View File

@ -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" };
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" };

View File

@ -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) {

View File

@ -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

View File

@ -1,18 +1,22 @@
#pragma once
#include "errors.h"
#include "chunk.h"
#include <fstream>
#include <string>
#include <iostream>
#include <unordered_map>
#include <map>
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<std::string, chunk*> chunks;
std::map<std::string, chunk*> chunks;
std::string entry = "start";
std::unordered_map<std::string, bool> enables;
std::map<std::string, bool> enables;
};
}

0
DMS/dump.bin Normal file
View File

View File

@ -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

View File

@ -1,5 +1,6 @@
#pragma once
#include <string>
#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;
};
}

7
DMS/packages.config Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="sfml-audio" version="2.4.2.0" targetFramework="native" />
<package id="sfml-audio.redist" version="2.4.2.0" targetFramework="native" />
<package id="sfml-system" version="2.4.2.0" targetFramework="native" />
<package id="sfml-system.redist" version="2.4.2.0" targetFramework="native" />
</packages>

View File

@ -6,6 +6,7 @@ disable omniscient
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
}
}

View File

@ -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 {

View File

@ -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
{

Binary file not shown.

Binary file not shown.

Binary file not shown.