core features updated

This commit is contained in:
Ryan Ward 2020-08-30 16:56:48 -04:00
parent 6110fad14c
commit 6f07a4d604
31 changed files with 52 additions and 61 deletions

View File

@ -20,7 +20,7 @@ using namespace dms;
using namespace dms::utils; using namespace dms::utils;
int main() int main()
{ {
/*LineParser parser = LineParser("test.dms"); LineParser parser = LineParser("test.dms");
dms_state* state = parser.Parse(); dms_state* state = parser.Parse();
state->dump();*/ state->dump();
} }

View File

@ -172,34 +172,6 @@
<ClInclude Include="utils.h" /> <ClInclude Include="utils.h" />
<ClInclude Include="value.h" /> <ClInclude Include="value.h" />
</ItemGroup> </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" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <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> </Project>

View File

@ -105,18 +105,4 @@
<Filter>Header Files\DMS</Filter> <Filter>Header Files\DMS</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </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> </Project>

View File

@ -1,2 +1,2 @@
 DMS.cpp  LineParserParse.cpp
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.

Binary file not shown.

Binary file not shown.

View File

@ -46,6 +46,26 @@ namespace dms {
return false; return false;
} }
bool LineParser::match_process_debug(tokenstream* stream) { bool LineParser::match_process_debug(tokenstream* stream) {
if (stream->match(tokens::newline, tokens::debug, tokens::string) || stream->match(tokens::newline, tokens::debug, tokens::name)){
stream->next();
stream->next();
if (state->isEnabled("debugging")) {
cmd* c = new cmd;
c->opcode = codes::DEBG;
if (stream->match(tokens::string)) {
c->args.push(buildValue(stream->next().name));
}
else {
c->args.push(buildVariable(stream->next().name));
}
current_chunk->addCmd(c);
return true;
}
else {
stream->next(); // Consume the third element anyway
return true; // This is a debugging match, but debugging is disabled. It's good!
}
}
return false; return false;
} }
bool LineParser::match_process_choice(tokenstream* stream) { bool LineParser::match_process_choice(tokenstream* stream) {
@ -122,7 +142,7 @@ namespace dms {
// We consumed the option now lets do some matching, note that all of these are one liners in the bytecode! // We consumed the option now lets do some matching, note that all of these are one liners in the bytecode!
if (match_process_function(stream,nullptr,false)) { // No returns and also no nesting of functions! if (match_process_function(stream,nullptr,false)) { // No returns and also no nesting of functions!
// We collect
} }
else if (match_process_goto(stream)) { else if (match_process_goto(stream)) {
current_chunk->addCmd(new cmd{codes::NOOP }); // Add noop to post-goto command current_chunk->addCmd(new cmd{codes::NOOP }); // Add noop to post-goto command

View File

@ -269,6 +269,9 @@ namespace dms {
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 - 2 });
} }
else if (str == "debug") {
t_vec.push_back(token{ tokens::debug,codes::NOOP,"",line - 2 });
}
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 - 2 });
isNum = false; isNum = false;
@ -419,10 +422,11 @@ namespace dms {
// Displays both with a target and without // Displays both with a target and without
match_process_disp(&stream); // Match and process displays match_process_disp(&stream); // Match and process displays
match_process_label(&stream); // Match and process labels match_process_label(&stream); // Match and process labels
match_process_debug(&stream);
//if (current.type != tokens::tab) // Old code for an old system... //if (current.type != tokens::tab) // Old code for an old system...
// tabs = 0; // tabs = 0;
//current = stream.next(); current = stream.next();
} }
state->push_chunk(current_chunk->name, current_chunk); state->push_chunk(current_chunk->name, current_chunk);
} }

View File

@ -1,3 +1,3 @@
#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" }; 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" };

View File

@ -33,7 +33,8 @@ namespace dms::codes {
GOTO, GOTO,
JUMP, JUMP,
RETN, RETN,
EXIT EXIT,
DEBG
}; };
extern const std::string list[]; extern const std::string list[];
static bool isControl(const op code) { static bool isControl(const op code) {

View File

@ -1,5 +1,19 @@
#include "dms_state.h" #include "dms_state.h"
namespace dms { namespace dms {
dms_state::dms_state() {
// We should define the defaults for the enables
//chunks.insert_or_assign("leaking",false);
//chunks.insert_or_assign("debugging",false);
//chunks.insert_or_assign("warnings",false); //
//chunks.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
}
bool dms_state::isEnabled(std::string flag) {
if (enables.count(flag)) {
return enables[flag];
}
return false;
}
void dms_state::dump(errors::error err) { void dms_state::dump(errors::error err) {
std::cout << "Number of chunks: " << chunks.size(); std::cout << "Number of chunks: " << chunks.size();
std::ofstream outputFile("dump.bin"); std::ofstream outputFile("dump.bin");

View File

@ -9,6 +9,7 @@ namespace dms {
class dms_state class dms_state
{ {
public: public:
dms_state();
void dump(errors::error err); void dump(errors::error err);
void dump(); void dump();
void push_error(errors::error err); void push_error(errors::error err);
@ -18,5 +19,6 @@ namespace dms {
std::map<std::string, chunk*> chunks; std::map<std::string, chunk*> chunks;
std::string entry = "start"; std::string entry = "start";
std::map<std::string, bool> enables; std::map<std::string, bool> enables;
bool isEnabled(std::string flag);
}; };
} }

View File

@ -1,5 +1,5 @@
Token Dump: Token Dump:
Line <18446744073709551615>NOOP newline Line <4294967295>NOOP newline
Line <0>NOOP newline Line <0>NOOP newline
Line <1>ENTR flag Line <1>ENTR flag
Line <1>NOOP name main Line <1>NOOP name main
@ -29,7 +29,7 @@ Line <11>NOOP name Ryan
Line <11>NOOP colon Line <11>NOOP colon
Line <11>NOOP string This works! Line <11>NOOP string This works!
Line <11>NOOP newline Line <11>NOOP newline
Line <12>NOOP name DEBUG Line <12>NOOP nil
Line <12>NOOP string What's up Line <12>NOOP string What's up
Line <12>NOOP newline Line <12>NOOP newline
Line <13>NOOP name Ryan Line <13>NOOP name Ryan

View File

@ -1,7 +0,0 @@
<?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

@ -40,14 +40,13 @@ namespace dms::tokens {
gotoo, gotoo,
jump, jump,
exit, exit,
// Other token types debug,
tilde, tilde,
backtick, backtick,
at, at,
pound, pound,
dollar, dollar,
ampersand, ampersand,
nil nil
};//stream, t_vec, line, isNum, buffer };//stream, t_vec, line, isNum, buffer
struct token { struct token {

Binary file not shown.

Binary file not shown.

Binary file not shown.