Working on commands
This commit is contained in:
parent
c1b97b83a3
commit
1c61488119
@ -1,5 +1,4 @@
|
||||
DMS.cpp
|
||||
LineParser.cpp
|
||||
chunk.cpp
|
||||
LineParser.cpp
|
||||
value.cpp
|
||||
Generating Code...
|
||||
DMS.vcxproj -> C:\Users\Ryan\source\repos\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.
@ -11,10 +11,26 @@ namespace dms {
|
||||
return token{ tokentype::noop,codes::NOOP,"EOF",0 };
|
||||
return this->tokens[pos++];
|
||||
}
|
||||
std::vector<token> tokenstream::next(tokentype to, tokentype tc) {
|
||||
std::vector<token> tok;
|
||||
size_t open = 0;
|
||||
if (peek().type == to) {
|
||||
open++;
|
||||
next(); // Consume
|
||||
while (open != 0) {
|
||||
if (peek().type == to)
|
||||
open++;
|
||||
else if (peek().type == tc)
|
||||
open--;
|
||||
tok.push_back(next());
|
||||
}
|
||||
}
|
||||
return tok;
|
||||
}
|
||||
token tokenstream::peek() {
|
||||
return this->tokens[pos];
|
||||
}
|
||||
std::vector<token> tokenstream::next(tokens::tokentype tk) {
|
||||
std::vector<token> tokenstream::next(tokentype tk) {
|
||||
std::vector<token> temp;
|
||||
while (peek().type!=tk) {
|
||||
temp.push_back(next());
|
||||
@ -52,15 +68,30 @@ namespace dms {
|
||||
return std::string(buf.begin(), buf.end());
|
||||
}
|
||||
void doCheck(passer* stream,std::vector<token>* t_vec, size_t line, bool &isNum, bool &hasDec, std::vector<uint8_t>* buffer) {
|
||||
if (isNum) {
|
||||
std::string str = stream->processBuffer(*buffer);
|
||||
if (utils::isNum(str) && isNum) {
|
||||
t_vec->push_back(token{ tokens::number,codes::NOOP,stream->processBuffer(*buffer),line });
|
||||
buffer->clear();
|
||||
isNum = false;
|
||||
hasDec = false;
|
||||
}
|
||||
else if (buffer->size() > 0) {
|
||||
std::string str = stream->processBuffer(*buffer);
|
||||
if (utils::isNum(str) && str.size() > 0) {
|
||||
if (str == "nil") {
|
||||
t_vec->push_back(token{ tokens::nil,codes::NOOP,stream->processBuffer(*buffer),line });
|
||||
buffer->clear();
|
||||
hasDec = false;
|
||||
}
|
||||
else if (str == "true") {
|
||||
t_vec->push_back(token{ tokens::True,codes::NOOP,stream->processBuffer(*buffer),line });
|
||||
buffer->clear();
|
||||
hasDec = false;
|
||||
}
|
||||
else if (str == "false") {
|
||||
t_vec->push_back(token{ tokens::False,codes::NOOP,stream->processBuffer(*buffer),line });
|
||||
buffer->clear();
|
||||
hasDec = false;
|
||||
}
|
||||
else if (utils::isNum(str) && str.size() > 0) {
|
||||
t_vec->push_back(token{ tokens::number,codes::NOOP,stream->processBuffer(*buffer),line });
|
||||
buffer->clear();
|
||||
isNum = false;
|
||||
@ -86,22 +117,58 @@ namespace dms {
|
||||
return true;
|
||||
if (stream.tokens[stream.pos+i].type != types[i])
|
||||
return false;
|
||||
//print(stream.tokens[stream.pos + i].type, " | ", types[i]);
|
||||
}
|
||||
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) {
|
||||
if (list[c] == t)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Todo create a match method that matches until a certain symbol... We need to finish the choice block stuff as well!
|
||||
|
||||
|
||||
|
||||
bool LineParser::match(tokenstream stream, tokens::tokentype* t1, tokens::tokentype* t2, tokens::tokentype* t3, tokens::tokentype* t4, tokens::tokentype* t5, tokens::tokentype* t6, tokens::tokentype* t7, tokens::tokentype* t8, tokens::tokentype* t9, tokens::tokentype* t10, tokens::tokentype* t11, tokens::tokentype* t12) {
|
||||
tokens::tokentype* types[12] = { t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12 };
|
||||
for (size_t i = 0; i < 12; i++) {
|
||||
if (types[i] == nullptr)
|
||||
return true;
|
||||
if (!inList(stream.tokens[stream.pos + i].type, types[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// This function is broken
|
||||
std::map<std::string, chunk*> LineParser::tokenizer(dms_state* state,std::vector<token> &toks) {
|
||||
std::map<std::string,chunk*> chunks;
|
||||
chunk* current_chunk = nullptr;
|
||||
std::string chunk_name;
|
||||
blocktype chunk_type;
|
||||
blocktype chunk_type = bt_block;
|
||||
size_t line=1;
|
||||
tokenstream stream;
|
||||
stream.init(&toks);
|
||||
token current = stream.next();
|
||||
std::vector<token> temp;
|
||||
size_t tabs = 0;
|
||||
while (stream.peek().type != tokens::eof) {
|
||||
print(current);
|
||||
if (current.type == tokens::tab)
|
||||
tabs++;
|
||||
if (current.type == tokens::flag) {
|
||||
temp = stream.next(tokens::newline);
|
||||
if (temp.size() != 2) {
|
||||
@ -110,12 +177,14 @@ namespace dms {
|
||||
codes::op code = current.raw;
|
||||
tokens::tokentype tok = temp[0].type;
|
||||
if (code == codes::ENAB && tok == tokens::name) {
|
||||
tolower(temp[0].name);
|
||||
state->enables.insert_or_assign(temp[0].name,true);
|
||||
}
|
||||
else if (code == codes::ENTR && tok == tokens::name) {
|
||||
state->entry = temp[0].name;
|
||||
}
|
||||
else if (code == codes::DISA && tok == tokens::name) {
|
||||
tolower(temp[0].name);
|
||||
state->enables.insert_or_assign(temp[0].name, false);
|
||||
}
|
||||
else if (code == codes::VERN && tok == tokens::number) {
|
||||
@ -133,8 +202,6 @@ namespace dms {
|
||||
state->push_error(errors::error{errors::badtoken,str.str(),true,line});
|
||||
}
|
||||
}
|
||||
|
||||
//Todo Finish the chunk data stuff
|
||||
if (match(stream,tokens::newline,tokens::bracketo,tokens::name,tokens::bracketc)) {
|
||||
stream.next();
|
||||
if (current_chunk != nullptr) {
|
||||
@ -217,9 +284,9 @@ namespace dms {
|
||||
for (size_t i = 0; i < tokens.size()-1; i++) {//The lase symbol is parac since that was the consume condition
|
||||
if (tokens[i].type == tokens::name) {
|
||||
// We got a name which is refering to a variable so lets build one
|
||||
value v;
|
||||
v.type = variable; // Special type, it writes data to the string portion, but is interperted as a lookup
|
||||
v.s = buildString(tokens[i].name);
|
||||
value* v = new value{};
|
||||
v->type = datatypes::variable; // Special type, it writes data to the string portion, but is interperted as a lookup
|
||||
v->s = buildString(tokens[i].name);
|
||||
args.push(v);
|
||||
}
|
||||
else if (tokens[i].type == tokens::seperator) {
|
||||
@ -240,6 +307,47 @@ namespace dms {
|
||||
state->push_error(errors::error{errors::badtoken, str.str(),true,line });
|
||||
}
|
||||
}
|
||||
// Control Handle all controls here
|
||||
if (match(stream,tokens::tab,tokens::control)) {
|
||||
stream.next(); // Standard consumption
|
||||
token control = stream.next();
|
||||
if (control.raw == codes::CHOI && stream.peek().type==tokens::string) {
|
||||
// Let's parse choice blocks.
|
||||
print("Choice block found!");
|
||||
bool good = true;
|
||||
while (good) {
|
||||
if (match(stream, new tokentype[2]{ tokens::string,tokens::none })) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Displays both with a target and without
|
||||
if (match(stream, tokens::tab, tokens::string, tokens::newline)) {
|
||||
// ToDo Implement the command for this
|
||||
stream.next(); // Standard consumption
|
||||
print("DISP := ", stream.next().name);
|
||||
}
|
||||
else if (match(stream, tokens::tab, tokens::name, tokens::string, tokens::newline)) {
|
||||
// Here we mathc Name "This guy said this!"
|
||||
stream.next(); // Standard consumption
|
||||
std::string name = stream.next().name;
|
||||
std::string msg = stream.next().name;
|
||||
print("DISP := ", name , " says '",msg,"'");
|
||||
// You notice that we dont consume the new line, some commands match new line as the front. It's best to not consume to allow those patterns to go through
|
||||
}
|
||||
// function stuff
|
||||
/*if (match(stream, tokens::name, tokens::parao)) {
|
||||
std::string n = stream.next().name;
|
||||
std::vector<token> t = stream.next(tokens::parao, tokens::parac);
|
||||
std::cout << "---Tokens---" << std::endl;
|
||||
for (size_t i = 0; i < t.size()-1; i++) {
|
||||
std::cout << t[i] << std::endl;
|
||||
}
|
||||
wait();
|
||||
}*/
|
||||
if (current.type != tokens::tab)
|
||||
tabs=0;
|
||||
current = stream.next();
|
||||
}
|
||||
chunks.insert_or_assign(current_chunk->name, current_chunk);
|
||||
@ -421,7 +529,7 @@ namespace dms {
|
||||
if (data == ' ' && !isStr) { // tokens end with a space
|
||||
std::string str = stream.processBuffer(buffer);
|
||||
tolower(str);
|
||||
buffer.clear();
|
||||
print("> ",str);
|
||||
if (str == "enable") {
|
||||
t_vec.push_back(token{ tokens::flag,codes::ENAB,"",line });
|
||||
} else if (str == "entry") {
|
||||
@ -451,7 +559,7 @@ namespace dms {
|
||||
else if (str == "true") {
|
||||
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 });
|
||||
}
|
||||
else if (str == "else") {
|
||||
@ -476,7 +584,7 @@ namespace dms {
|
||||
t_vec.push_back(token{ tokens::nil,codes::NOOP,"",line });
|
||||
}
|
||||
else if (utils::isalphanum(str) && str.size()>0) {
|
||||
t_vec.push_back(token{ tokens::name,codes::NOOP,str,line });
|
||||
t_vec.push_back(token{ tokens::name,codes::NOOP,stream.processBuffer(buffer),line });
|
||||
}
|
||||
else {
|
||||
// Unknown command!
|
||||
@ -484,6 +592,7 @@ namespace dms {
|
||||
tok.name = str;
|
||||
tok.line_num = line;*/
|
||||
}
|
||||
buffer.clear();
|
||||
}
|
||||
data = stream.next();
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ namespace dms {
|
||||
size_t pos = 0;
|
||||
void init(std::vector<tokens::token>* ptr);
|
||||
tokens::token next();
|
||||
std::vector<tokens::token> next(tokens::tokentype to,tokens::tokentype tc);
|
||||
tokens::token peek();
|
||||
std::vector<tokens::token> next(tokens::tokentype tk);
|
||||
};
|
||||
@ -44,7 +45,10 @@ namespace dms {
|
||||
LineParser();
|
||||
//Matches tokens from the stream, if the tokens match it will return true and YOU should call next on the stream. This method does not change the current position
|
||||
bool match(tokenstream stream, tokens::tokentype t1=tokens::none, tokens::tokentype t2 = tokens::none, tokens::tokentype t3 = tokens::none, tokens::tokentype t4 = tokens::none, tokens::tokentype t5 = tokens::none, tokens::tokentype t6 = tokens::none, tokens::tokentype t7 = tokens::none, tokens::tokentype t8 = tokens::none, tokens::tokentype t9 = tokens::none, tokens::tokentype t10 = tokens::none, tokens::tokentype t11 = tokens::none, tokens::tokentype t12 = tokens::none);
|
||||
bool match(tokenstream stream, tokens::tokentype* t1 = nullptr,tokens::tokentype* t2 = nullptr, tokens::tokentype* t3 = nullptr, tokens::tokentype* t4 = nullptr, tokens::tokentype* t5 = nullptr, tokens::tokentype* t6 = nullptr, tokens::tokentype* t7 = nullptr, tokens::tokentype* t8 = nullptr, tokens::tokentype* t9 = nullptr, tokens::tokentype* t10 = nullptr, tokens::tokentype* t11 = nullptr, tokens::tokentype* t12 = nullptr);
|
||||
void tolower(std::string &str);
|
||||
tokens::tokentype* expr();
|
||||
tokens::tokentype* variable();
|
||||
std::map<std::string, chunk*> tokenizer(dms_state* state, std::vector<tokens::token> &tok);
|
||||
};
|
||||
}
|
||||
@ -7,6 +7,7 @@ namespace dms {
|
||||
}
|
||||
void dms_state::push_warning(errors::error err) {
|
||||
err.crash = false; // Force code to not crash then push the error
|
||||
if(enables.count("warnings"))
|
||||
push_error(err);
|
||||
}
|
||||
}
|
||||
604
DMS/dump.txt
604
DMS/dump.txt
@ -21,14 +21,14 @@ Line <8>NOOP name char
|
||||
Line <8>NOOP bracketc
|
||||
Line <8>NOOP newline
|
||||
Line <9>NOOP tab
|
||||
Line <9>NOOP name name
|
||||
Line <9>NOOP name age
|
||||
Line <9>NOOP equal
|
||||
Line <9>NOOP string Ryan
|
||||
Line <9>NOOP number 21
|
||||
Line <9>NOOP newline
|
||||
Line <10>NOOP tab
|
||||
Line <10>NOOP name age
|
||||
Line <10>NOOP name money
|
||||
Line <10>NOOP equal
|
||||
Line <10>NOOP number 21
|
||||
Line <10>NOOP number 1000
|
||||
Line <10>NOOP newline
|
||||
Line <11>NOOP newline
|
||||
Line <12>NOOP bracketo
|
||||
@ -58,465 +58,475 @@ Line <14>NOOP name b
|
||||
Line <14>NOOP parac
|
||||
Line <14>NOOP divide
|
||||
Line <14>NOOP name c
|
||||
Line <14>NOOP name nil
|
||||
Line <14>NOOP newline
|
||||
Line <15>NOOP tab
|
||||
Line <15>RETN ret
|
||||
Line <15>NOOP name d
|
||||
Line <15>NOOP name e
|
||||
Line <15>NOOP equal
|
||||
Line <15>NOOP nil nil
|
||||
Line <15>NOOP newline
|
||||
Line <16>NOOP tab
|
||||
Line <16>NOOP name f
|
||||
Line <16>NOOP equal
|
||||
Line <16>NOOP true true
|
||||
Line <16>NOOP newline
|
||||
Line <17>NOOP bracketo
|
||||
Line <17>NOOP name main
|
||||
Line <17>NOOP bracketc
|
||||
Line <17>NOOP tab
|
||||
Line <17>NOOP name g
|
||||
Line <17>NOOP equal
|
||||
Line <17>NOOP false false
|
||||
Line <17>NOOP newline
|
||||
Line <18>NOOP tab
|
||||
Line <18>NOOP string This works!
|
||||
Line <18>RETN ret
|
||||
Line <18>NOOP name d
|
||||
Line <18>NOOP newline
|
||||
Line <19>NOOP tab
|
||||
Line <19>NOOP string What's up
|
||||
Line <19>NOOP newline
|
||||
Line <20>NOOP bracketo
|
||||
Line <20>NOOP name main
|
||||
Line <20>NOOP bracketc
|
||||
Line <20>NOOP newline
|
||||
Line <21>NOOP tab
|
||||
Line <21>NOOP name ryan
|
||||
Line <21>NOOP string Hello "how" are you doing?
|
||||
Line <21>NOOP string This works!
|
||||
Line <21>NOOP newline
|
||||
Line <22>NOOP tab
|
||||
Line <22>NOOP name bob
|
||||
Line <22>NOOP string I'm good you?
|
||||
Line <22>NOOP string What's up
|
||||
Line <22>NOOP newline
|
||||
Line <23>NOOP tab
|
||||
Line <23>NOOP newline
|
||||
Line <24>NOOP tab
|
||||
Line <24>NOOP name tester
|
||||
Line <24>NOOP equal
|
||||
Line <24>NOOP string Hello
|
||||
Line <24>NOOP name Ryan
|
||||
Line <24>NOOP string Hello "how" are you doing?
|
||||
Line <24>NOOP newline
|
||||
Line <25>NOOP tab
|
||||
Line <25>NOOP name Bob
|
||||
Line <25>NOOP string I'm good you?
|
||||
Line <25>NOOP newline
|
||||
Line <26>NOOP tab
|
||||
Line <26>NOOP name food
|
||||
Line <26>NOOP equal
|
||||
Line <26>NOOP number 3
|
||||
Line <26>NOOP newline
|
||||
Line <27>NOOP tab
|
||||
Line <27>NOOP name tester
|
||||
Line <27>NOOP equal
|
||||
Line <27>NOOP string Hello
|
||||
Line <27>NOOP newline
|
||||
Line <28>NOOP tab
|
||||
Line <28>NOOP name hi
|
||||
Line <28>NOOP equal
|
||||
Line <28>NOOP cbracketo
|
||||
Line <28>NOOP number 1
|
||||
Line <28>NOOP seperator
|
||||
Line <28>NOOP number 2
|
||||
Line <28>NOOP seperator
|
||||
Line <28>NOOP number 3
|
||||
Line <28>NOOP cbracketc
|
||||
Line <28>NOOP newline
|
||||
Line <29>NOOP tab
|
||||
Line <29>NOOP name food
|
||||
Line <29>NOOP equal
|
||||
Line <29>NOOP number 3
|
||||
Line <29>NOOP newline
|
||||
Line <30>NOOP tab
|
||||
Line <30>NOOP name list
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP name test
|
||||
Line <30>NOOP equal
|
||||
Line <30>NOOP cbracketo
|
||||
Line <30>NOOP cbracketo
|
||||
Line <30>NOOP number 1
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP number 2
|
||||
Line <30>NOOP plus
|
||||
Line <30>NOOP name food
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP name hi
|
||||
Line <30>NOOP bracketo
|
||||
Line <30>NOOP number 3
|
||||
Line <30>NOOP bracketc
|
||||
Line <30>NOOP cbracketc
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP name true
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP name tester
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP number 123
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP string This is a string!
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP name false
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP cbracketo
|
||||
Line <30>NOOP number 3
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP number 2
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP number 1
|
||||
Line <30>NOOP cbracketc
|
||||
Line <30>NOOP cbracketc
|
||||
Line <30>NOOP seperator
|
||||
Line <30>NOOP number 5
|
||||
Line <30>NOOP newline
|
||||
Line <31>NOOP tab
|
||||
Line <31>NOOP name a
|
||||
Line <31>NOOP name hi
|
||||
Line <31>NOOP equal
|
||||
Line <31>NOOP name list
|
||||
Line <31>NOOP bracketo
|
||||
Line <31>NOOP cbracketo
|
||||
Line <31>NOOP number 1
|
||||
Line <31>NOOP bracketc
|
||||
Line <31>NOOP seperator
|
||||
Line <31>NOOP number 2
|
||||
Line <31>NOOP seperator
|
||||
Line <31>NOOP number 3
|
||||
Line <31>NOOP cbracketc
|
||||
Line <31>NOOP newline
|
||||
Line <32>NOOP newline
|
||||
Line <33>NOOP tab
|
||||
Line <33>NOOP name hungry
|
||||
Line <33>NOOP name list
|
||||
Line <33>NOOP equal
|
||||
Line <33>NOOP parao
|
||||
Line <33>NOOP minus
|
||||
Line <33>NOOP number 2
|
||||
Line <33>NOOP plus
|
||||
Line <33>NOOP number 4
|
||||
Line <33>NOOP minus
|
||||
Line <33>NOOP parao
|
||||
Line <33>NOOP parao
|
||||
Line <33>NOOP number 5
|
||||
Line <33>NOOP multiply
|
||||
Line <33>NOOP number 5
|
||||
Line <33>NOOP parac
|
||||
Line <33>NOOP divide
|
||||
Line <33>NOOP name sqrt
|
||||
Line <33>NOOP parao
|
||||
Line <33>NOOP number 144
|
||||
Line <33>NOOP plus
|
||||
Line <33>NOOP number 5
|
||||
Line <33>NOOP parac
|
||||
Line <33>NOOP parac
|
||||
Line <33>NOOP parac
|
||||
Line <33>NOOP pow
|
||||
Line <33>NOOP number 2
|
||||
Line <33>NOOP multiply
|
||||
Line <33>NOOP cbracketo
|
||||
Line <33>NOOP cbracketo
|
||||
Line <33>NOOP number 1
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP number 2
|
||||
Line <33>NOOP plus
|
||||
Line <33>NOOP name food
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP name hi
|
||||
Line <33>NOOP bracketo
|
||||
Line <33>NOOP number 3
|
||||
Line <33>NOOP bracketc
|
||||
Line <33>NOOP cbracketc
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP true true
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP name tester
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP number 123
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP string This is a string!
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP false false
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP cbracketo
|
||||
Line <33>NOOP number 3
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP number 2
|
||||
Line <33>NOOP seperator
|
||||
Line <33>NOOP number 1
|
||||
Line <33>NOOP cbracketc
|
||||
Line <33>NOOP cbracketc
|
||||
Line <33>NOOP newline
|
||||
Line <34>NOOP tab
|
||||
Line <34>NOOP name a
|
||||
Line <34>NOOP equal
|
||||
Line <34>NOOP name list
|
||||
Line <34>NOOP bracketo
|
||||
Line <34>NOOP number 1
|
||||
Line <34>NOOP bracketc
|
||||
Line <34>NOOP equal
|
||||
Line <34>NOOP string Hello
|
||||
Line <34>NOOP newline
|
||||
Line <35>NOOP tab
|
||||
Line <35>NOOP number var1
|
||||
Line <35>NOOP seperator
|
||||
Line <35>NOOP name var2
|
||||
Line <35>NOOP number
|
||||
Line <35>NOOP equal
|
||||
Line <35>NOOP name func
|
||||
Line <35>NOOP parao
|
||||
Line <35>NOOP number 1
|
||||
Line <35>NOOP seperator
|
||||
Line <35>NOOP string string
|
||||
Line <35>NOOP seperator
|
||||
Line <35>NOOP number 2
|
||||
Line <35>NOOP plus
|
||||
Line <35>NOOP number 5
|
||||
Line <35>NOOP parac
|
||||
Line <35>NOOP newline
|
||||
Line <36>NOOP tab
|
||||
Line <36>NOOP name a
|
||||
Line <36>NOOP name hungry
|
||||
Line <36>NOOP equal
|
||||
Line <36>NOOP name 100
|
||||
Line <36>NOOP number
|
||||
Line <36>NOOP plus
|
||||
Line <36>NOOP name func
|
||||
Line <36>NOOP parao
|
||||
Line <36>NOOP number 1
|
||||
Line <36>NOOP seperator
|
||||
Line <36>NOOP string string
|
||||
Line <36>NOOP seperator
|
||||
Line <36>NOOP minus
|
||||
Line <36>NOOP number 2
|
||||
Line <36>NOOP plus
|
||||
Line <36>NOOP number 4
|
||||
Line <36>NOOP minus
|
||||
Line <36>NOOP parao
|
||||
Line <36>NOOP parao
|
||||
Line <36>NOOP number 5
|
||||
Line <36>NOOP multiply
|
||||
Line <36>NOOP number 5
|
||||
Line <36>NOOP parac
|
||||
Line <36>NOOP divide
|
||||
Line <36>NOOP name sqrt
|
||||
Line <36>NOOP parao
|
||||
Line <36>NOOP number 144
|
||||
Line <36>NOOP plus
|
||||
Line <36>NOOP number 5
|
||||
Line <36>NOOP parac
|
||||
Line <36>NOOP parac
|
||||
Line <36>NOOP parac
|
||||
Line <36>NOOP pow
|
||||
Line <36>NOOP number 2
|
||||
Line <36>NOOP multiply
|
||||
Line <36>NOOP number 2
|
||||
Line <36>NOOP plus
|
||||
Line <36>NOOP number 100
|
||||
Line <36>NOOP number 2
|
||||
Line <36>NOOP newline
|
||||
Line <37>NOOP tab
|
||||
Line <37>NOOP name func
|
||||
Line <37>NOOP parao
|
||||
Line <37>NOOP name list
|
||||
Line <37>NOOP bracketo
|
||||
Line <37>NOOP number 1
|
||||
Line <37>NOOP seperator
|
||||
Line <37>NOOP string string
|
||||
Line <37>NOOP seperator
|
||||
Line <37>NOOP number 2
|
||||
Line <37>NOOP plus
|
||||
Line <37>NOOP number 5
|
||||
Line <37>NOOP parac
|
||||
Line <37>NOOP bracketc
|
||||
Line <37>NOOP equal
|
||||
Line <37>NOOP string Hello
|
||||
Line <37>NOOP newline
|
||||
Line <38>NOOP tab
|
||||
Line <38>NOOP label label
|
||||
Line <38>NOOP name var1
|
||||
Line <38>NOOP seperator
|
||||
Line <38>NOOP name var2
|
||||
Line <38>NOOP number
|
||||
Line <38>NOOP equal
|
||||
Line <38>NOOP name func
|
||||
Line <38>NOOP parao
|
||||
Line <38>NOOP number 1
|
||||
Line <38>NOOP seperator
|
||||
Line <38>NOOP string string
|
||||
Line <38>NOOP seperator
|
||||
Line <38>NOOP number 2
|
||||
Line <38>NOOP plus
|
||||
Line <38>NOOP number 5
|
||||
Line <38>NOOP parac
|
||||
Line <38>NOOP newline
|
||||
Line <39>NOOP tab
|
||||
Line <39>NOOP name a
|
||||
Line <39>NOOP equal
|
||||
Line <39>NOOP name 100
|
||||
Line <39>NOOP number
|
||||
Line <39>NOOP plus
|
||||
Line <39>NOOP name func
|
||||
Line <39>NOOP parao
|
||||
Line <39>NOOP number 1
|
||||
Line <39>NOOP seperator
|
||||
Line <39>NOOP string string
|
||||
Line <39>NOOP seperator
|
||||
Line <39>NOOP number 2
|
||||
Line <39>NOOP plus
|
||||
Line <39>NOOP number 5
|
||||
Line <39>NOOP parac
|
||||
Line <39>NOOP plus
|
||||
Line <39>NOOP number 100
|
||||
Line <39>NOOP newline
|
||||
Line <40>NOOP tab
|
||||
Line <40>NOOP name func
|
||||
Line <40>NOOP parao
|
||||
Line <40>NOOP number 1
|
||||
Line <40>NOOP seperator
|
||||
Line <40>NOOP string string
|
||||
Line <40>NOOP seperator
|
||||
Line <40>NOOP number 2
|
||||
Line <40>NOOP plus
|
||||
Line <40>NOOP number 5
|
||||
Line <40>NOOP parac
|
||||
Line <40>NOOP newline
|
||||
Line <41>NOOP tab
|
||||
Line <41>CHOI control
|
||||
Line <41>NOOP string Pick one:
|
||||
Line <41>NOOP label label
|
||||
Line <41>NOOP newline
|
||||
Line <42>NOOP tab
|
||||
Line <42>NOOP tab
|
||||
Line <42>NOOP string first
|
||||
Line <42>NOOP name func
|
||||
Line <42>NOOP parao
|
||||
Line <42>NOOP parac
|
||||
Line <42>NOOP newline
|
||||
Line <43>NOOP tab
|
||||
Line <43>NOOP tab
|
||||
Line <43>NOOP string second
|
||||
Line <43>NOOP name func
|
||||
Line <43>NOOP parao
|
||||
Line <43>NOOP parac
|
||||
Line <43>NOOP newline
|
||||
Line <44>NOOP tab
|
||||
Line <44>NOOP tab
|
||||
Line <44>NOOP string third
|
||||
Line <44>NOOP name func
|
||||
Line <44>NOOP parao
|
||||
Line <44>NOOP parac
|
||||
Line <44>CHOI control
|
||||
Line <44>NOOP string Pick one:
|
||||
Line <44>NOOP newline
|
||||
Line <45>NOOP tab
|
||||
Line <45>NOOP tab
|
||||
Line <45>NOOP string forth
|
||||
Line <45>NOOP string first
|
||||
Line <45>NOOP name func
|
||||
Line <45>NOOP parao
|
||||
Line <45>NOOP parac
|
||||
Line <45>NOOP newline
|
||||
Line <46>NOOP tab
|
||||
Line <46>NOOP tab
|
||||
Line <46>NOOP string second
|
||||
Line <46>NOOP name func
|
||||
Line <46>NOOP parao
|
||||
Line <46>NOOP parac
|
||||
Line <46>NOOP newline
|
||||
Line <47>NOOP tab
|
||||
Line <47>NOOP for
|
||||
Line <47>NOOP name x
|
||||
Line <47>NOOP equal
|
||||
Line <47>NOOP number 1
|
||||
Line <47>NOOP seperator
|
||||
Line <47>NOOP number 10
|
||||
Line <47>NOOP tab
|
||||
Line <47>NOOP string third
|
||||
Line <47>NOOP name func
|
||||
Line <47>NOOP parao
|
||||
Line <47>NOOP parac
|
||||
Line <47>NOOP newline
|
||||
Line <48>NOOP tab
|
||||
Line <48>NOOP tab
|
||||
Line <48>NOOP for
|
||||
Line <48>NOOP name y
|
||||
Line <48>NOOP equal
|
||||
Line <48>NOOP number 1
|
||||
Line <48>NOOP seperator
|
||||
Line <48>NOOP number 10
|
||||
Line <48>NOOP seperator
|
||||
Line <48>NOOP number 1
|
||||
Line <48>NOOP string forth
|
||||
Line <48>NOOP name func
|
||||
Line <48>NOOP parao
|
||||
Line <48>NOOP parac
|
||||
Line <48>NOOP newline
|
||||
Line <49>NOOP tab
|
||||
Line <49>NOOP tab
|
||||
Line <49>NOOP tab
|
||||
Line <49>NOOP for
|
||||
Line <49>NOOP name z
|
||||
Line <49>NOOP equal
|
||||
Line <49>NOOP number 1
|
||||
Line <49>NOOP seperator
|
||||
Line <49>NOOP number 10
|
||||
Line <49>NOOP newline
|
||||
Line <50>NOOP tab
|
||||
Line <50>NOOP tab
|
||||
Line <50>NOOP tab
|
||||
Line <50>NOOP tab
|
||||
Line <50>NOOP string test
|
||||
Line <50>NOOP for
|
||||
Line <50>NOOP name x
|
||||
Line <50>NOOP equal
|
||||
Line <50>NOOP number 1
|
||||
Line <50>NOOP seperator
|
||||
Line <50>NOOP number 10
|
||||
Line <50>NOOP newline
|
||||
Line <51>NOOP tab
|
||||
Line <51>NOOP tab
|
||||
Line <51>NOOP tab
|
||||
Line <51>NOOP tab
|
||||
Line <51>NOOP string $x$ $y$ $z$
|
||||
Line <51>NOOP for
|
||||
Line <51>NOOP name y
|
||||
Line <51>NOOP equal
|
||||
Line <51>NOOP number 1
|
||||
Line <51>NOOP seperator
|
||||
Line <51>NOOP number 10
|
||||
Line <51>NOOP seperator
|
||||
Line <51>NOOP number 1
|
||||
Line <51>NOOP newline
|
||||
Line <52>NOOP tab
|
||||
Line <52>NOOP name test
|
||||
Line <52>NOOP tab
|
||||
Line <52>NOOP tab
|
||||
Line <52>NOOP for
|
||||
Line <52>NOOP name z
|
||||
Line <52>NOOP equal
|
||||
Line <52>NOOP name true
|
||||
Line <52>NOOP number 1
|
||||
Line <52>NOOP seperator
|
||||
Line <52>NOOP number 10
|
||||
Line <52>NOOP newline
|
||||
Line <53>NOOP tab
|
||||
Line <53>NOOP name test2
|
||||
Line <53>NOOP number
|
||||
Line <53>NOOP equal
|
||||
Line <53>NOOP name false
|
||||
Line <53>NOOP tab
|
||||
Line <53>NOOP tab
|
||||
Line <53>NOOP tab
|
||||
Line <53>NOOP string test
|
||||
Line <53>NOOP newline
|
||||
Line <54>NOOP tab
|
||||
Line <54>NOOP tab
|
||||
Line <54>NOOP tab
|
||||
Line <54>NOOP tab
|
||||
Line <54>NOOP string $x$ $y$ $z$
|
||||
Line <54>NOOP newline
|
||||
Line <55>NOOP tab
|
||||
Line <55>NOOP name count
|
||||
Line <55>NOOP name test
|
||||
Line <55>NOOP equal
|
||||
Line <55>NOOP number 0
|
||||
Line <55>NOOP true true
|
||||
Line <55>NOOP newline
|
||||
Line <56>NOOP tab
|
||||
Line <56>NOOP name test2
|
||||
Line <56>NOOP number
|
||||
Line <56>NOOP equal
|
||||
Line <56>NOOP false false
|
||||
Line <56>NOOP newline
|
||||
Line <57>NOOP tab
|
||||
Line <57>WHLE control
|
||||
Line <57>NOOP name count
|
||||
Line <57>NOOP not
|
||||
Line <57>NOOP equal
|
||||
Line <57>NOOP number 100
|
||||
Line <57>NOOP newline
|
||||
Line <58>NOOP tab
|
||||
Line <58>NOOP tab
|
||||
Line <58>NOOP name count
|
||||
Line <58>NOOP plus
|
||||
Line <58>NOOP plus
|
||||
Line <58>NOOP equal
|
||||
Line <58>NOOP number 0
|
||||
Line <58>NOOP newline
|
||||
Line <59>NOOP tab
|
||||
Line <59>NOOP tab
|
||||
Line <59>NOOP string Count = $count$
|
||||
Line <59>NOOP newline
|
||||
Line <60>NOOP tab
|
||||
Line <60>WHLE control
|
||||
Line <60>NOOP name count
|
||||
Line <60>NOOP not
|
||||
Line <60>NOOP equal
|
||||
Line <60>NOOP number 100
|
||||
Line <60>NOOP newline
|
||||
Line <61>NOOP tab
|
||||
Line <61>IFFF control
|
||||
Line <61>NOOP parao
|
||||
Line <61>NOOP name func
|
||||
Line <61>NOOP parao
|
||||
Line <61>NOOP number 123
|
||||
Line <61>NOOP parac
|
||||
Line <61>NOOP not
|
||||
Line <61>NOOP equal
|
||||
Line <61>NOOP name name
|
||||
Line <61>NOOP bracketo
|
||||
Line <61>NOOP number 1
|
||||
Line <61>NOOP bracketc
|
||||
Line <61>NOOP or
|
||||
Line <61>NOOP true
|
||||
Line <61>NOOP equal
|
||||
Line <61>NOOP equal
|
||||
Line <61>NOOP string Bob
|
||||
Line <61>NOOP parac
|
||||
Line <61>NOOP and
|
||||
Line <61>NOOP name foodcount
|
||||
Line <61>NOOP equal
|
||||
Line <61>NOOP number 10.34
|
||||
Line <61>NOOP tab
|
||||
Line <61>NOOP name count
|
||||
Line <61>NOOP plus
|
||||
Line <61>NOOP plus
|
||||
Line <61>NOOP newline
|
||||
Line <62>NOOP tab
|
||||
Line <62>NOOP tab
|
||||
Line <62>NOOP string test=true or test2=false!
|
||||
Line <62>NOOP number
|
||||
Line <62>NOOP string Count = $count$
|
||||
Line <62>NOOP newline
|
||||
Line <63>NOOP tab
|
||||
Line <63>NOOP tab
|
||||
Line <63>NOOP string help me
|
||||
Line <63>NOOP newline
|
||||
Line <64>NOOP tab
|
||||
Line <64>NOOP tab
|
||||
Line <64>IFFF control
|
||||
Line <64>NOOP name cool
|
||||
Line <64>NOOP parao
|
||||
Line <64>NOOP name func
|
||||
Line <64>NOOP parao
|
||||
Line <64>NOOP number 123
|
||||
Line <64>NOOP parac
|
||||
Line <64>NOOP not
|
||||
Line <64>NOOP equal
|
||||
Line <64>NOOP name name
|
||||
Line <64>NOOP bracketo
|
||||
Line <64>NOOP number 1
|
||||
Line <64>NOOP bracketc
|
||||
Line <64>NOOP or
|
||||
Line <64>NOOP true
|
||||
Line <64>NOOP equal
|
||||
Line <64>NOOP equal
|
||||
Line <64>NOOP name true
|
||||
Line <64>NOOP string Bob
|
||||
Line <64>NOOP parac
|
||||
Line <64>NOOP and
|
||||
Line <64>NOOP name foodCount
|
||||
Line <64>NOOP equal
|
||||
Line <64>NOOP number 10.34
|
||||
Line <64>NOOP newline
|
||||
Line <65>NOOP tab
|
||||
Line <65>NOOP tab
|
||||
Line <65>NOOP tab
|
||||
Line <65>NOOP string We are here
|
||||
Line <65>NOOP string test=true or test2=false!
|
||||
Line <65>NOOP number
|
||||
Line <65>NOOP newline
|
||||
Line <66>NOOP tab
|
||||
Line <66>NOOP tab
|
||||
Line <66>NOOP tab
|
||||
Line <66>NOOP string Nested if
|
||||
Line <66>NOOP string help me
|
||||
Line <66>NOOP newline
|
||||
Line <67>NOOP tab
|
||||
Line <67>NOOP tab
|
||||
Line <67>ELIF control
|
||||
Line <67>NOOP name food
|
||||
Line <67>IFFF control
|
||||
Line <67>NOOP name cool
|
||||
Line <67>NOOP equal
|
||||
Line <67>NOOP number 21
|
||||
Line <67>NOOP equal
|
||||
Line <67>NOOP true true
|
||||
Line <67>NOOP newline
|
||||
Line <68>NOOP tab
|
||||
Line <68>NOOP tab
|
||||
Line <68>NOOP tab
|
||||
Line <68>NOOP string This is getting weird
|
||||
Line <68>NOOP string We are here
|
||||
Line <68>NOOP newline
|
||||
Line <69>NOOP tab
|
||||
Line <69>NOOP tab
|
||||
Line <69>NOOP string Hi
|
||||
Line <69>NOOP tab
|
||||
Line <69>NOOP string Nested if
|
||||
Line <69>NOOP newline
|
||||
Line <70>NOOP tab
|
||||
Line <70>NOOP tab
|
||||
Line <70>ELIF control
|
||||
Line <70>NOOP parao
|
||||
Line <70>NOOP number func2
|
||||
Line <70>NOOP parao
|
||||
Line <70>NOOP number 321
|
||||
Line <70>NOOP parac
|
||||
Line <70>NOOP not
|
||||
Line <70>NOOP name food
|
||||
Line <70>NOOP equal
|
||||
Line <70>NOOP number name2
|
||||
Line <70>NOOP bracketo
|
||||
Line <70>NOOP number 1
|
||||
Line <70>NOOP bracketc
|
||||
Line <70>NOOP or
|
||||
Line <70>NOOP true
|
||||
Line <70>NOOP equal
|
||||
Line <70>NOOP equal
|
||||
Line <70>NOOP string Bob2
|
||||
Line <70>NOOP number
|
||||
Line <70>NOOP parac
|
||||
Line <70>NOOP and
|
||||
Line <70>NOOP name foodcount2
|
||||
Line <70>NOOP number
|
||||
Line <70>NOOP equal
|
||||
Line <70>NOOP number 1.78
|
||||
Line <70>NOOP number 21
|
||||
Line <70>NOOP newline
|
||||
Line <71>NOOP tab
|
||||
Line <71>NOOP tab
|
||||
Line <71>NOOP string This Block
|
||||
Line <71>NOOP tab
|
||||
Line <71>NOOP string This is getting weird
|
||||
Line <71>NOOP newline
|
||||
Line <72>NOOP tab
|
||||
Line <72>NOOP name else
|
||||
Line <72>NOOP tab
|
||||
Line <72>NOOP string Hi
|
||||
Line <72>NOOP newline
|
||||
Line <73>NOOP tab
|
||||
Line <73>NOOP tab
|
||||
Line <73>NOOP string That Block
|
||||
Line <73>ELIF control
|
||||
Line <73>NOOP parao
|
||||
Line <73>NOOP name func2
|
||||
Line <73>NOOP parao
|
||||
Line <73>NOOP number 321
|
||||
Line <73>NOOP parac
|
||||
Line <73>NOOP not
|
||||
Line <73>NOOP equal
|
||||
Line <73>NOOP name name2
|
||||
Line <73>NOOP bracketo
|
||||
Line <73>NOOP number 1
|
||||
Line <73>NOOP bracketc
|
||||
Line <73>NOOP or
|
||||
Line <73>NOOP true
|
||||
Line <73>NOOP equal
|
||||
Line <73>NOOP equal
|
||||
Line <73>NOOP string Bob2
|
||||
Line <73>NOOP number
|
||||
Line <73>NOOP parac
|
||||
Line <73>NOOP and
|
||||
Line <73>NOOP name foodCount2
|
||||
Line <73>NOOP number
|
||||
Line <73>NOOP equal
|
||||
Line <73>NOOP number 1.78
|
||||
Line <73>NOOP newline
|
||||
Line <74>NOOP tab
|
||||
Line <74>NOOP string ah this is why no pop
|
||||
Line <74>NOOP tab
|
||||
Line <74>NOOP string This Block
|
||||
Line <74>NOOP newline
|
||||
Line <75>NOOP tab
|
||||
Line <75>NOOP name else
|
||||
Line <75>NOOP newline
|
||||
Line <76>NOOP bracketo
|
||||
Line <76>NOOP name Ryan
|
||||
Line <76>NOOP colon
|
||||
Line <76>NOOP name char
|
||||
Line <76>NOOP bracketc
|
||||
Line <76>NOOP tab
|
||||
Line <76>NOOP tab
|
||||
Line <76>NOOP string That Block
|
||||
Line <76>NOOP newline
|
||||
Line <77>NOOP tab
|
||||
Line <77>NOOP name age
|
||||
Line <77>NOOP equal
|
||||
Line <77>NOOP number 24
|
||||
Line <77>NOOP string ah this is why no pop
|
||||
Line <77>NOOP newline
|
||||
Line <78>NOOP tab
|
||||
Line <78>NOOP name money
|
||||
Line <78>NOOP equal
|
||||
Line <78>NOOP number 100
|
||||
Line <78>NOOP newline
|
||||
Line <79>NOOP tab
|
||||
Line <79>NOOP bracketo
|
||||
Line <79>NOOP name Bob
|
||||
Line <79>NOOP colon
|
||||
Line <79>NOOP name char
|
||||
Line <79>NOOP bracketc
|
||||
Line <79>NOOP newline
|
||||
Line <80>NOOP bracketo
|
||||
Line <80>NOOP name test
|
||||
Line <80>NOOP colon
|
||||
Line <80>NOOP name env
|
||||
Line <80>NOOP bracketc
|
||||
Line <80>NOOP tab
|
||||
Line <80>NOOP name age
|
||||
Line <80>NOOP equal
|
||||
Line <80>NOOP number 24
|
||||
Line <80>NOOP newline
|
||||
Line <81>NOOP tab
|
||||
Line <81>NOOP string test
|
||||
Line <81>NOOP name money
|
||||
Line <81>NOOP equal
|
||||
Line <81>NOOP number 100
|
||||
Line <81>NOOP newline
|
||||
Line <82>NOOP tab
|
||||
Line <82>NOOP newline
|
||||
Line <83>NOOP bracketo
|
||||
Line <83>NOOP name newblock
|
||||
Line <83>NOOP name test
|
||||
Line <83>NOOP colon
|
||||
Line <83>NOOP name function
|
||||
Line <83>NOOP parao
|
||||
Line <83>NOOP parac
|
||||
Line <83>NOOP name env
|
||||
Line <83>NOOP bracketc
|
||||
Line <83>NOOP newline
|
||||
Line <84>NOOP tab
|
||||
Line <84>NOOP string Test #2
|
||||
Line <84>NOOP number
|
||||
Line <84>NOOP string test
|
||||
Line <84>NOOP newline
|
||||
Line <85>NOOP tab
|
||||
Line <85>NOOP string Does it parse this part properly?
|
||||
Line <85>NOOP newline
|
||||
Line <87>NOOP eof
|
||||
Line <86>NOOP bracketo
|
||||
Line <86>NOOP name newblock
|
||||
Line <86>NOOP colon
|
||||
Line <86>NOOP name function
|
||||
Line <86>NOOP parao
|
||||
Line <86>NOOP parac
|
||||
Line <86>NOOP bracketc
|
||||
Line <86>NOOP newline
|
||||
Line <87>NOOP tab
|
||||
Line <87>NOOP string Test #2
|
||||
Line <87>NOOP number
|
||||
Line <87>NOOP newline
|
||||
Line <88>NOOP tab
|
||||
Line <88>NOOP string Does it parse this part properly?
|
||||
Line <88>NOOP newline
|
||||
Line <90>NOOP eof
|
||||
|
||||
@ -10,7 +10,7 @@ namespace dms::number_utils {
|
||||
if (args.args.size() == 0)
|
||||
return buildNumber(-1); // ABS cannot be -1, this is an error
|
||||
if (utils::typeassert(args, number)) {
|
||||
double temp = args.args[0].n->val;
|
||||
double temp = args.args[0]->n->val;
|
||||
return buildNumber(temp*temp / 2);
|
||||
}
|
||||
return buildNumber(-1);
|
||||
@ -19,8 +19,8 @@ namespace dms::number_utils {
|
||||
size_t size = args.args.size();
|
||||
double max = std::numeric_limits<double>::min();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (args.args[i].n->val > max)
|
||||
max = args.args[i].n->val;
|
||||
if (args.args[i]->n->val > max)
|
||||
max = args.args[i]->n->val;
|
||||
}
|
||||
return buildNumber(max);
|
||||
}
|
||||
|
||||
@ -18,8 +18,8 @@ namespace dms::string_utils {
|
||||
return buildString("");
|
||||
}
|
||||
if (utils::typeassert(state, args, string)) {
|
||||
size_t size = args.args[0].s->length;
|
||||
uint8_t* newptr = copyStr(*args.args[0].s, 0, size);
|
||||
size_t size = args.args[0]->s->length;
|
||||
uint8_t* newptr = copyStr(*args.args[0]->s, 0, size);
|
||||
std::reverse(newptr, newptr + size);
|
||||
dms_string* newstr = new dms_string{ size, newptr };
|
||||
return newstr;
|
||||
@ -33,9 +33,9 @@ namespace dms::string_utils {
|
||||
return buildString("");
|
||||
}
|
||||
if (utils::typeassert(state, args, string, number, number)) {
|
||||
size_t start = args.args[1].n->val;
|
||||
size_t size = args.args[2].n->val;
|
||||
dms_string str = *args.args[0].s;
|
||||
size_t start = args.args[1]->n->val;
|
||||
size_t size = args.args[2]->n->val;
|
||||
dms_string str = *args.args[0]->s;
|
||||
if (start + size > str.length) {
|
||||
state->push_error(errors::error{ errors::invalid_arguments,"Expected a string object, got nil." });
|
||||
return buildString("");
|
||||
@ -56,7 +56,7 @@ namespace dms::string_utils {
|
||||
return buildString("");
|
||||
}
|
||||
if (utils::typeassert(state, args, string)) {
|
||||
dms_string str = *args.args[0].s;
|
||||
dms_string str = *args.args[0]->s;
|
||||
uint8_t* newptr = copyStr(str, 0, str.length);
|
||||
std::transform(newptr, newptr + str.length, newptr, toupper);
|
||||
dms_string* newstr = new dms_string{ str.length, newptr };
|
||||
@ -71,7 +71,7 @@ namespace dms::string_utils {
|
||||
return buildString("");
|
||||
}
|
||||
if (utils::typeassert(state, args, string)) {
|
||||
dms_string str = *args.args[0].s;
|
||||
dms_string str = *args.args[0]->s;
|
||||
uint8_t* newptr = copyStr(str, 0, str.length);
|
||||
std::transform(newptr, newptr + str.length, newptr, tolower);
|
||||
dms_string* newstr = new dms_string{ str.length, newptr };
|
||||
@ -86,8 +86,8 @@ namespace dms::string_utils {
|
||||
return buildBool(false);
|
||||
}
|
||||
if (utils::typeassert(state, args, string, string)) {
|
||||
dms_string str = *args.args[0].s;
|
||||
dms_string starts = *args.args[1].s;
|
||||
dms_string str = *args.args[0]->s;
|
||||
dms_string starts = *args.args[1]->s;
|
||||
if (starts.length > str.length)
|
||||
return buildBool(false);
|
||||
for (int i = 0; i < starts.length; i++) {
|
||||
@ -106,8 +106,8 @@ namespace dms::string_utils {
|
||||
return buildBool(false);
|
||||
}
|
||||
if (utils::typeassert(state, args, string, string)) {
|
||||
dms_string str = *args.args[0].s;
|
||||
dms_string ends = *args.args[1].s;
|
||||
dms_string str = *args.args[0]->s;
|
||||
dms_string ends = *args.args[1]->s;
|
||||
if (ends.length > str.length)
|
||||
return buildBool(false);
|
||||
for (int i = ends.length - 1; i >= 0; i--) {
|
||||
@ -129,8 +129,8 @@ namespace dms::string_utils {
|
||||
if (utils::typeassert(state, args, string, string)) {
|
||||
bool check = false;
|
||||
int ind;
|
||||
dms_string str = *args.args[0].s;
|
||||
dms_string find = *args.args[1].s;
|
||||
dms_string str = *args.args[0]->s;
|
||||
dms_string find = *args.args[1]->s;
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
for (int ii = 0; ii < find.length; ii++) {
|
||||
if (find.val[ii] == str.val[i + ii]) {
|
||||
@ -176,8 +176,8 @@ namespace dms::string_utils {
|
||||
return buildString("");
|
||||
}
|
||||
if (utils::typeassert(state, args, string, number)) {
|
||||
dms_string str = *args.args[0].s;
|
||||
dms_number num = *args.args[1].n;
|
||||
dms_string str = *args.args[0]->s;
|
||||
dms_number num = *args.args[1]->n;
|
||||
std::string newstr = str.getValue();
|
||||
std::stringstream temp;
|
||||
for (int i = 0; i < num.getValue(); i++)
|
||||
|
||||
11
DMS/test.dms
11
DMS/test.dms
@ -6,12 +6,15 @@ version 1.2
|
||||
using extendedDefine
|
||||
|
||||
[Ryan:char]
|
||||
name = "Ryan"
|
||||
age = 21
|
||||
money = 1000
|
||||
|
||||
[step:function(a,b,c)]
|
||||
"Testing..."
|
||||
d = (100 + b) / c nil
|
||||
d = (100 + b) / c
|
||||
e = nil
|
||||
f = true
|
||||
g = false
|
||||
return d
|
||||
|
||||
[main]
|
||||
@ -27,7 +30,7 @@ using extendedDefine
|
||||
|
||||
hi = {1,2,3}
|
||||
|
||||
list,test = {{1,2+food,hi[3]},true,tester,123,"This is a string!",false, {3,2,1}},5
|
||||
list = {{1,2+food,hi[3]},true,tester,123,"This is a string!",false, {3,2,1}}
|
||||
a = list[1]
|
||||
|
||||
hungry = (-2+4-((5*5)/sqrt(144+5)))^2*2+2
|
||||
@ -73,7 +76,7 @@ using extendedDefine
|
||||
"That Block"
|
||||
"ah this is why no pop"
|
||||
|
||||
[Ryan:char]
|
||||
[Bob:char]
|
||||
age = 24
|
||||
money = 100
|
||||
|
||||
|
||||
@ -41,12 +41,12 @@ namespace dms::utils {
|
||||
datatypes types[12] = { t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12 };
|
||||
if(size >= 4)
|
||||
for (size_t i = 0; i < 4;i++) {
|
||||
if (args.args[i].type != types[i])
|
||||
if (args.args[i]->type != types[i])
|
||||
return false;
|
||||
}
|
||||
else
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (args.args[i].type != types[i])
|
||||
if (args.args[i]->type != types[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -56,15 +56,15 @@ namespace dms::utils {
|
||||
datatypes types[12] = { t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12 };
|
||||
if (size >= 4)
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
if (args.args[i].type != types[i]) {
|
||||
state->push_error(dms::errors::error{ errors::invalid_arguments, "Invalid arguments! Expected (" + resolveTypes(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) + ") Got: " + resolveTypes(args.args[i].type)});
|
||||
if (args.args[i]->type != types[i]) {
|
||||
state->push_error(dms::errors::error{ errors::invalid_arguments, "Invalid arguments! Expected (" + resolveTypes(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) + ") Got: " + resolveTypes(args.args[i]->type)});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (args.args[i].type != types[i]) {
|
||||
state->push_error(dms::errors::error{ errors::invalid_arguments, "Invalid arguments! Expected (" + resolveTypes(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) + ") Got: " + resolveTypes(args.args[i].type)});
|
||||
if (args.args[i]->type != types[i]) {
|
||||
state->push_error(dms::errors::error{ errors::invalid_arguments, "Invalid arguments! Expected (" + resolveTypes(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) + ") Got: " + resolveTypes(args.args[i]->type)});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
namespace dms {
|
||||
void dms_args::push(value val) {
|
||||
void dms_args::push(value* val) {
|
||||
args.push_back(val);
|
||||
}
|
||||
dms_string* buildString(std::string str) {
|
||||
@ -62,68 +62,32 @@ namespace dms {
|
||||
e = nullptr;
|
||||
c = nullptr;
|
||||
}
|
||||
bool value::typeMatch(const value o) const {
|
||||
return type == o.type;
|
||||
// Fixed issue with memory not properly being cleaned up
|
||||
bool value::typeMatch(const value* o) const {
|
||||
return type == o->type;
|
||||
}
|
||||
void value::set(dms_string* str) {
|
||||
nuke();
|
||||
s = str;
|
||||
delete[] b;
|
||||
delete[] n;
|
||||
delete[] e;
|
||||
delete[] c;
|
||||
b = nullptr;
|
||||
n = nullptr;
|
||||
e = nullptr;
|
||||
c = nullptr;
|
||||
type = string;
|
||||
}
|
||||
void value::set(dms_boolean* bo) {
|
||||
nuke();
|
||||
b = bo;
|
||||
delete[] s;
|
||||
delete[] n;
|
||||
delete[] e;
|
||||
delete[] c;
|
||||
s = nullptr;
|
||||
n = nullptr;
|
||||
e = nullptr;
|
||||
c = nullptr;
|
||||
type = boolean;
|
||||
}
|
||||
void value::set(dms_number* num) {
|
||||
nuke();
|
||||
n = num;
|
||||
delete[] b;
|
||||
delete[] s;
|
||||
delete[] e;
|
||||
delete[] c;
|
||||
b = nullptr;
|
||||
s = nullptr;
|
||||
e = nullptr;
|
||||
c = nullptr;
|
||||
type = number;
|
||||
}
|
||||
void dms::value::set(dms_env* en) {
|
||||
nuke();
|
||||
e = en;
|
||||
delete[] b;
|
||||
delete[] s;
|
||||
delete[] n;
|
||||
delete[] c;
|
||||
b = nullptr;
|
||||
n = nullptr;
|
||||
s = nullptr;
|
||||
c = nullptr;
|
||||
type = env;
|
||||
}
|
||||
void value::set() {
|
||||
delete[] b;
|
||||
delete[] s;
|
||||
delete[] n;
|
||||
delete[] e;
|
||||
delete[] c;
|
||||
s = nullptr;
|
||||
n = nullptr;
|
||||
e = nullptr;
|
||||
c = nullptr;
|
||||
b = nullptr;
|
||||
nuke();
|
||||
type = nil;
|
||||
}
|
||||
std::string dms_string::getValue() {
|
||||
@ -133,42 +97,44 @@ namespace dms {
|
||||
}
|
||||
return temp.str();
|
||||
}
|
||||
void dms_env::pushValue(value val) {
|
||||
void dms_env::pushValue(value* val) {
|
||||
double count = 0;
|
||||
while (ipart[count++].type != nil) {}
|
||||
while (ipart[count++]->type != nil) {}
|
||||
ipart.insert_or_assign(count-1, val);
|
||||
}
|
||||
void dms_env::pushValue(value ind, value val) {
|
||||
if (ind.type == number) {
|
||||
void dms_env::pushValue(value* ind, value* val) {
|
||||
if (ind->type == number) {
|
||||
size_t size = ipart.size();
|
||||
if (val.type == nil) {
|
||||
ipart.erase(ind.n->val);
|
||||
if (val->type == nil) {
|
||||
ipart[ind->n->val]->nuke();
|
||||
ipart.erase(ind->n->val);
|
||||
count--;
|
||||
}
|
||||
else {
|
||||
ipart.insert_or_assign(ind.n->val, val);
|
||||
ipart.insert_or_assign(ind->n->val, val);
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
if (val.type == nil) {
|
||||
hpart.erase(ind.toString());
|
||||
if (val->type == nil) {
|
||||
hpart[ind->toString()]->nuke();
|
||||
hpart.erase(ind->toString());
|
||||
count--;
|
||||
}
|
||||
else {
|
||||
hpart.insert_or_assign(ind.toString(), val);
|
||||
hpart.insert_or_assign(ind->toString(), val);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
value dms_env::getValue(value ind) {
|
||||
if (ind.type == number) {
|
||||
return ipart.at(ind.n->getValue());
|
||||
value* dms_env::getValue(value* ind) {
|
||||
if (ind->type == number) {
|
||||
return ipart.at(ind->n->getValue());
|
||||
}
|
||||
else if (ind.type == number) {
|
||||
return *(new value{}); // Return a nil value
|
||||
else if (ind->type == number) {
|
||||
return new value{}; // Return a nil value
|
||||
}
|
||||
else {
|
||||
return hpart.at(ind.toString());
|
||||
return hpart.at(ind->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
32
DMS/value.h
32
DMS/value.h
@ -41,6 +41,9 @@ namespace dms {
|
||||
dms_boolean* buildBool(bool b);
|
||||
dms_number* buildNumber(double num);
|
||||
struct value {
|
||||
/*~value() {
|
||||
nuke();
|
||||
}*/
|
||||
datatypes type = nil;
|
||||
dms_boolean* b = nullptr;
|
||||
dms_number* n = nullptr;
|
||||
@ -53,19 +56,8 @@ namespace dms {
|
||||
void set(dms_number* num);
|
||||
void set(dms_env* en);
|
||||
void set();
|
||||
bool typeMatch(const value o) const;
|
||||
bool typeMatch(const value* o) const;
|
||||
std::string toString() const;
|
||||
friend bool operator<(const value& l, const value& r)
|
||||
{
|
||||
if (l.typeMatch(r)) {
|
||||
if (l.type == number) {
|
||||
return l.n->val > r.n->val;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false; // We might want to throw an error if this were to happen. Mixing incompatable types
|
||||
}
|
||||
}
|
||||
friend std::ostream& operator << (std::ostream& out, const value& c) {
|
||||
if (c.type == string) {
|
||||
out << c.s->getValue();
|
||||
@ -85,7 +77,7 @@ namespace dms {
|
||||
else if (c.type == custom) {
|
||||
out << "Custom Data: " << c;
|
||||
}
|
||||
else if (c.type == variable) {
|
||||
else if (c.type == datatypes::variable) {
|
||||
out << c.s->getValue(); // Do the lookup
|
||||
}
|
||||
return out;
|
||||
@ -97,8 +89,8 @@ namespace dms {
|
||||
value* buildValue(bool b);
|
||||
|
||||
struct dms_args {
|
||||
std::vector<value> args;
|
||||
void push(value val);
|
||||
std::vector<value*> args;
|
||||
void push(value* val);
|
||||
friend std::ostream& operator << (std::ostream& out, const dms_args& c) {
|
||||
for (size_t i=0; i < c.args.size(); i++) {
|
||||
if(i==c.args.size()-1)
|
||||
@ -111,11 +103,11 @@ namespace dms {
|
||||
};
|
||||
struct dms_env
|
||||
{
|
||||
std::map<std::string, value> hpart;
|
||||
std::map<double, value> ipart;
|
||||
void pushValue(value val);
|
||||
void pushValue(value ind, value val);
|
||||
value getValue(value val);
|
||||
std::map<std::string, value*> hpart;
|
||||
std::map<double, value*> ipart;
|
||||
void pushValue(value* val);
|
||||
void pushValue(value* ind, value* val);
|
||||
value* getValue(value* val);
|
||||
private:
|
||||
size_t count = 0;
|
||||
};
|
||||
|
||||
BIN
Debug/DMS.exe
BIN
Debug/DMS.exe
Binary file not shown.
BIN
Debug/DMS.ilk
BIN
Debug/DMS.ilk
Binary file not shown.
BIN
Debug/DMS.pdb
BIN
Debug/DMS.pdb
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user