fixed load file

This commit is contained in:
Ryan Ward 2020-08-30 23:53:05 -04:00
parent eb2b53569c
commit c504f41dcb
19 changed files with 121 additions and 53 deletions

View File

@ -1,9 +1,5 @@
 DMS.cpp  LineParserBuilds.cpp
LineParserBuilds.cpp
LineParserMatchProcess.cpp
LineParserParse.cpp LineParserParse.cpp
LineParserUtils.cpp
chunk.cpp chunk.cpp
dms_state.cpp
Generating Code... 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.

View File

@ -54,6 +54,7 @@ namespace dms {
std::stack<scope> scopes; std::stack<scope> scopes;
size_t line = 1; size_t line = 1;
std::vector<tokens::token> temp; std::vector<tokens::token> temp;
std::vector<tokens::token> tdump;
size_t tabs = 0; size_t tabs = 0;
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);
@ -74,6 +75,7 @@ namespace dms {
void buildLabel(std::string l); void buildLabel(std::string l);
// Utils // Utils
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);
bool isBlock(); bool isBlock();

View File

@ -9,7 +9,7 @@ namespace dms {
Compound DISP Compound DISP
*/ */
if (isBlock(bt_block) && stream->match(tokens::newline, tokens::string, tokens::newline)) { if ((isBlock(bt_block) || isBlock(bt_method)) && stream->match(tokens::newline, tokens::string, tokens::newline)) {
stream->next(); // Standard consumption stream->next(); // Standard consumption
std::string msg = stream->next().name; std::string msg = stream->next().name;
print("DISP := ", msg); print("DISP := ", msg);

View File

@ -289,17 +289,20 @@ namespace dms {
data = stream.next(); data = stream.next();
} }
t_vec.push_back(token{ tokens::eof,codes::NOOP,"",line - 1 }); t_vec.push_back(token{ tokens::eof,codes::NOOP,"",line - 1 });
std::ofstream outputFile("dump.txt"); tokenDump(&t_vec);
outputFile << "Token Dump:" << std::endl;
for (size_t i = 0; i < t_vec.size(); i++) {
outputFile << t_vec[i] << std::endl;
}
outputFile.close();
print("Running tokenizer"); print("Running tokenizer");
// Tokens build let's parse // Tokens build let's parse
tokenizer(state, t_vec); tokenizer(state, t_vec);
return state; return state;
} }
void LineParser::tokenDump(std::vector<token>* v) {
std::ofstream outputFile("dump.txt");
outputFile << "Token Dump:" << std::endl;
for (size_t i = 0; i < v->size(); i++) {
outputFile << (*v)[i] << std::endl;
}
outputFile.close();
}
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) {
@ -330,7 +333,6 @@ namespace dms {
// TODO add usings, kinda useless atm since everything will be packed in. Perhaps extensions? // TODO add usings, kinda useless atm since everything will be packed in. Perhaps extensions?
} }
else if (code == codes::LOAD && tok == tokens::string) { else if (code == codes::LOAD && tok == tokens::string) {
print("Loading File: ", temp[0].name);
LineParser parser = LineParser(); LineParser parser = LineParser();
parser.Parse(state, temp[0].name);// Load another file parser.Parse(state, temp[0].name);// Load another file
} }

View File

@ -171,7 +171,6 @@ namespace dms {
current_chunk->name = bk_name; current_chunk->name = bk_name;
chunk_type = bk_type; chunk_type = bk_type;
current_chunk->type = bk_type; current_chunk->type = bk_type;
print("Created Block: ",bk_name," <",bk_type,">");
return true; return true;
} }
void LineParser::tokenizer(dms_state* state,std::vector<token> &toks) { void LineParser::tokenizer(dms_state* state,std::vector<token> &toks) {

View File

@ -35,7 +35,6 @@ namespace dms {
outputFile.close(); outputFile.close();
} }
void dms_state::push_chunk(std::string s, chunk* c) { void dms_state::push_chunk(std::string s, chunk* c) {
std::cout << "Pushing Chunk: " << s << std::endl;
chunks.insert_or_assign(s, c); chunks.insert_or_assign(s, c);
} }
void dms_state::push_error(errors::error err) { void dms_state::push_error(errors::error err) {

View File

@ -12,59 +12,120 @@ 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 <4>NOOP name test
Line <4>NOOP equal
Line <4>NOOP nil nil
Line <4>NOOP newline Line <4>NOOP newline
Line <5>NOOP bracketo
Line <5>NOOP name Ryan
Line <5>NOOP colon
Line <5>NOOP name char
Line <5>NOOP bracketc
Line <5>NOOP newline Line <5>NOOP newline
Line <6>NOOP name age Line <6>NOOP bracketo
Line <6>NOOP equal Line <6>NOOP name Ryan
Line <6>NOOP number 21 Line <6>NOOP colon
Line <6>NOOP name char
Line <6>NOOP bracketc
Line <6>NOOP newline Line <6>NOOP newline
Line <7>NOOP name money Line <7>NOOP name age
Line <7>NOOP equal Line <7>NOOP equal
Line <7>NOOP number 1000 Line <7>NOOP number 21
Line <7>NOOP newline Line <7>NOOP newline
Line <8>NOOP name money
Line <8>NOOP equal
Line <8>NOOP number 1000
Line <8>NOOP newline Line <8>NOOP newline
Line <9>NOOP name calm
Line <9>NOOP colon
Line <9>NOOP string ./path/to/file
Line <9>NOOP newline Line <9>NOOP newline
Line <10>NOOP name excited 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 <11>NOOP name excited
Line <11>NOOP colon
Line <11>NOOP string ./path/to/file
Line <11>NOOP newline Line <11>NOOP newline
Line <12>NOOP bracketo
Line <12>NOOP name step
Line <12>NOOP colon
Line <12>NOOP name function
Line <12>NOOP parao
Line <12>NOOP name a
Line <12>NOOP seperator
Line <12>NOOP name b
Line <12>NOOP seperator
Line <12>NOOP name c
Line <12>NOOP parac
Line <12>NOOP bracketc
Line <12>NOOP newline Line <12>NOOP newline
Line <13>NOOP string Testing... Line <13>NOOP bracketo
Line <13>NOOP name step
Line <13>NOOP colon
Line <13>NOOP name function
Line <13>NOOP parao
Line <13>NOOP name a
Line <13>NOOP seperator
Line <13>NOOP name b
Line <13>NOOP seperator
Line <13>NOOP name c
Line <13>NOOP parac
Line <13>NOOP bracketc
Line <13>NOOP newline Line <13>NOOP newline
Line <14>NOOP name d Line <14>NOOP string Testing...
Line <14>NOOP equal
Line <14>NOOP parao
Line <14>NOOP number 100
Line <14>NOOP plus
Line <14>NOOP name b
Line <14>NOOP parac
Line <14>NOOP divide
Line <14>NOOP name c
Line <14>NOOP newline Line <14>NOOP newline
Line <15>NOOP name e Line <15>NOOP name d
Line <15>NOOP equal Line <15>NOOP equal
Line <15>NOOP string somestring Line <15>NOOP parao
Line <15>NOOP number 100
Line <15>NOOP plus
Line <15>NOOP name b
Line <15>NOOP parac
Line <15>NOOP divide
Line <15>NOOP name c
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 newline
Line <17>NOOP name e
Line <17>NOOP equal
Line <17>NOOP nil nil
Line <17>NOOP newline
Line <18>NOOP name g
Line <18>NOOP equal
Line <18>NOOP false false
Line <18>NOOP newline
Line <19>RETN ret
Line <19>NOOP name d
Line <19>NOOP newline
Line <20>NOOP newline
Line <21>NOOP bracketo
Line <21>NOOP name inventory
Line <21>NOOP colon
Line <21>NOOP name env
Line <21>NOOP bracketc
Line <21>NOOP newline
Line <22>NOOP name slot1
Line <22>NOOP number
Line <22>NOOP equal
Line <22>NOOP string
Line <22>NOOP newline
Line <23>NOOP name slot2
Line <23>NOOP number
Line <23>NOOP equal
Line <23>NOOP string
Line <23>NOOP newline
Line <24>NOOP name slot3
Line <24>NOOP number
Line <24>NOOP equal
Line <24>NOOP string
Line <24>NOOP newline
Line <25>NOOP name slot4
Line <25>NOOP number
Line <25>NOOP equal
Line <25>NOOP string
Line <25>NOOP newline
Line <26>NOOP name slot5
Line <26>NOOP number
Line <26>NOOP equal
Line <26>NOOP string
Line <26>NOOP newline
Line <27>NOOP name slot6
Line <27>NOOP number
Line <27>NOOP equal
Line <27>NOOP string
Line <27>NOOP newline
Line <28>NOOP name slot7
Line <28>NOOP number
Line <28>NOOP equal
Line <28>NOOP string
Line <28>NOOP newline
Line <29>NOOP name slot8
Line <29>NOOP number
Line <29>NOOP equal
Line <29>NOOP string
Line <29>NOOP newline
Line <31>NOOP eof

View File

@ -1,6 +1,7 @@
[default:char] [default:char]
// The default stats for all characters. // The default stats for all characters.
money = 0 money = 0
test = nil
[Ryan:char] [Ryan:char]
age = 21 age = 21

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include "codes.h" #include "codes.h"
#include "utils.h"
namespace dms::tokens { namespace dms::tokens {
enum tokentype { enum tokentype {
none, none,
@ -106,6 +107,13 @@ namespace dms::tokens {
"gotoo", "gotoo",
"jump", "jump",
"exit", "exit",
"debug",
"tilde",
"backtick",
"at",
"pound",
"dollar",
"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] << " " << temp1[c.type] << " \t\t " << c.name;

Binary file not shown.

Binary file not shown.

Binary file not shown.