implemented, grouping, if's, not

This commit is contained in:
Ryan Ward 2020-11-29 14:00:35 -05:00
parent 3f501d4cad
commit 60b8198842
14 changed files with 336 additions and 214 deletions

View File

@ -85,6 +85,7 @@ namespace dms {
bool match_process_return(tokenstream* stream);
bool match_process_condition(tokenstream* stream, value& v);
bool match_process_andor(tokenstream* stream,value& v);
bool match_process_scope(tokenstream* stream);
// Build
void buildGoto(std::string g, bool v = false);
@ -97,6 +98,7 @@ namespace dms {
// Utils
std::string random_string(std::size_t length);
bool notBalanced(std::vector<tokens::token> ts, size_t last_line, tokenstream* stream, std::string o, std::string c);
void badSymbol(errors::errortype err, tokenstream* stream);
void badSymbol(tokenstream* stream);
void badSymbol();

View File

@ -3,6 +3,7 @@ namespace dms {
void LineParser::buildGoto(std::string g, bool v) {
cmd* c = new cmd;
c->opcode = codes::GOTO;
//utils::debug("Building Goto: ",g);
if (v) {
c->args.push(value(g,datatypes::variable));
}
@ -28,6 +29,7 @@ namespace dms {
current_chunk->addCmd(c);
}
void LineParser::buildLabel(std::string l) {
//utils::debug("Building Label: ", l);
cmd* c = new cmd;
c->opcode = codes::LABL;
c->args.push(value(l));

View File

@ -8,8 +8,55 @@ namespace dms {
if (stream->peek().type == tokens::none) {
return false;
}
//!something
if (stream->match(exclamation)) {
stream->next(); // Consume the token
// Within the standard we always get passed a valid value, We need to pass a new value to a recursive call to standard then pass through
if (stream->match(name)) {
v = value(stream->next().name, variable);
cmd* c = new cmd;
c->opcode = codes::KNOT;
c->args.push(v);
current_chunk->addCmd(c);
return true;
}
else if (stream->match(parao)) {
size_t last_line = stream->peek().line_num;
std::vector<tokens::token> toks = stream->next(tokens::parao, tokens::parac);
if (notBalanced(toks, last_line, stream, "(", ")"))
return false;
toks.pop_back(); // Remove the ')'
tokenstream tempstream(&toks);
value var(variable);
if (match_process_standard(&tempstream,var)) {
value assn = value(datatypes::variable); // The variable that we will be setting stuff to
stream->next(); // Consume the equal
cmd* c = new cmd;
c->opcode = codes::ASGN;
c->args.push(assn);
c->args.push(var);
current_chunk->addCmd(c);
c = new cmd;
c->opcode = codes::KNOT;
c->args.push(assn);
current_chunk->addCmd(c);
v.set(assn.s);
v.type = variable;
return true;
}
}
else {
stop = true;
state->push_error(errors::error{ errors::unknown,concat("Unexpected symbol '",stream->next().toString(), "' near '!' \"Not\" can only be used on a varaible or a group!"),true,stream->peek().line_num,current_chunk });
return false;
}
}
if (stream->match(tokens::parao)) {
size_t last_line = stream->peek().line_num;
std::vector<tokens::token> toks = stream->next(tokens::parao, tokens::parac);
if (notBalanced(toks, last_line, stream, "(", ")"))
return false;
toks.pop_back(); // Remove the ')'
toks.push_back(tokens::token{tokens::newline,codes::NOOP,"",stream->peek().line_num});
tokenstream tempstream(&toks);
@ -164,7 +211,7 @@ namespace dms {
stream->next();
}
else {
return false;
return match_process_andor(stream,v);
}
// So if all is good we continue here
value right = value(datatypes::variable);
@ -196,7 +243,10 @@ namespace dms {
if (stream->match(tokens::cbracketo)) {
token start = stream->peek();
token ancor = start;
size_t last_line = stream->last().line_num;
std::vector<token> t = stream->next(tokens::cbracketo, tokens::cbracketc);
if (notBalanced(t, last_line, stream, "{", "}"))
return false;
tokenstream tempstream(&t);
value ref = value(datatypes::variable);
value length = value();
@ -636,7 +686,10 @@ namespace dms {
// Already we have built: FUNC name val
// Next we add arguments this is where things get interesting
// This is a balanced consuming method (()(()))
size_t last_line = stream->last().line_num;
std::vector<token> t = stream->next(tokens::parao, tokens::parac); // Consume and get tokens
if (notBalanced(t, last_line, stream, "(", ")"))
return false;
//t.pop_back();
tokenstream tempstream(&t);
if (t.size() == 1) { // No arg function!
@ -726,7 +779,10 @@ namespace dms {
// Already we have built: FUNC name val
// Next we add arguments this is where things get interesting
// This is a balanced consuming method (()(()))
size_t last_line = stream->last().line_num;
std::vector<token> t = stream->next(tokens::parao, tokens::parac); // Consume and get tokens
if (notBalanced(t, last_line, stream, "(", ")"))
return false;
t.pop_back();
tokenstream tempstream(&t);
if (t.size() == 1) { // No arg function!
@ -858,6 +914,23 @@ namespace dms {
}
return false;
}
/*
We need to match {...}
This doesn't pass any varaible. It should be used to match and process program flow
*/
bool LineParser::match_process_scope(tokenstream* stream) {
if (stream->match(cbracketo)) {
size_t last_line = stream->last().line_num;
std::vector<token> t = stream->next(cbracketo, cbracketc); // Consume and get tokens
tokenstream tempstream(&t);
if (notBalanced(t, last_line, stream, "{", "}"))
return false;
// We got the balanced match, time to simple do it
ParseLoop(&tempstream); // Done
return true;
}
return false;
}
bool LineParser::match_process_IFFF(tokenstream* stream) {
/*if(this) {
* then()
@ -873,7 +946,10 @@ namespace dms {
// God controls are from a time past... I could refactor, but I'm lazy and would have to change a lot of old code... So we will deal with controls
if (stream->match(tokens::name,tokens::parao) && stream->peek().name == "if") {
stream->next();
size_t last_line = stream->last().line_num;
std::vector<token> ts = stream->next(tokens::parao, tokens::parac);
if (notBalanced(ts, last_line, stream, "(", ")"))
return false;
ts.pop_back();
tokenstream tmpstream(&ts);
value cmp(datatypes::variable);
@ -882,7 +958,10 @@ namespace dms {
std::string ifend = std::string("IFE_") + random_string(4);
std::string next = std::string("IFF_") + random_string(4);
if (stream->match(tokens::cbracketo)) {
size_t last_line = stream->last().line_num;
std::vector<token> toks = stream->next(tokens::cbracketo, tokens::cbracketc);
if (notBalanced(toks, last_line, stream, "{", "}"))
return false;
toks.pop_back();
tokenstream tempstream(&toks);
cmd* c = new cmd;
@ -909,8 +988,8 @@ namespace dms {
stream->next();
buildGoto(ifend);
buildLabel(next);
if (!match_process_function(stream, nil)) {
state->push_error(errors::error{ errors::unknown,"Missing else function",true,stream->peek().line_num,current_chunk });
if (!match_process_function(stream, nil) && !match_process_scope(stream)) {
state->push_error(errors::error{ errors::unknown,"Missing else function or scope",true,stream->peek().line_num,current_chunk });
return false;
}
}
@ -938,7 +1017,10 @@ namespace dms {
bool LineParser::match_process_ELSE(tokenstream* stream, std::string ifend) {
if (stream->match(tokens::name, tokens::cbracketo) && stream->peek().name == "else") {
stream->next();
size_t last_line = stream->last().line_num;
std::vector<token> ts = stream->next(tokens::cbracketo, tokens::cbracketc);
if (notBalanced(ts, last_line, stream, "{", "}"))
return false;
ts.pop_back();
tokenstream tempstream(&ts);
ParseLoop(&tempstream);
@ -949,7 +1031,10 @@ namespace dms {
bool LineParser::match_process_ELIF(tokenstream* stream, std::string ifend) {
if (stream->match(tokens::name, tokens::parao) && stream->peek().name == "elseif") {
stream->next();
size_t last_line = stream->last().line_num;
std::vector<token> ts = stream->next(tokens::parao, tokens::parac);
if (notBalanced(ts, last_line, stream, "(", ")"))
return false;
ts.pop_back();
tokenstream tmpstream(&ts);
value cmp(datatypes::variable);
@ -957,7 +1042,10 @@ namespace dms {
if (match_process_standard(&tmpstream, cmp)) {
std::string next = std::string("IFF_") + random_string(4);
if (stream->match(tokens::cbracketo)) {
size_t last_line = stream->last().line_num;
std::vector<token> toks = stream->next(tokens::cbracketo, tokens::cbracketc);
if (notBalanced(ts, last_line, stream, "{", "}"))
return false;
toks.pop_back();
tokenstream tempstream(&toks);
cmd* c = new cmd;
@ -1017,7 +1105,10 @@ namespace dms {
while (stream->peek().type != tokens::none) {
debugInvoker(stream);
if (stream->match(tokens::parao)) {
size_t last_line = stream->last().line_num;
auto ts = stream->next(tokens::parao, tokens::parac);
if (notBalanced(ts, last_line, stream, "(", ")"))
return false;
tokenstream temp(&ts);
value tmpvalue = value(datatypes::variable);
if (match_process_expression(&temp, tmpvalue)) {
@ -1108,6 +1199,14 @@ namespace dms {
else
badSymbol(stream);
}
else if (stream->match(tokens::string)) {
if (left.isNil())
left = value(stream->next().name,string);
else if (right.isNil())
right = value(stream->next().name, string);
else
badSymbol(stream);
}
else if (stream->match(tokens::name)) {
// We tested functions already! So if that fails and we have a name then... we have a variable lets handle this!
if (left.isNil())

View File

@ -514,12 +514,6 @@ namespace dms {
void LineParser::_Parse(tokenstream* stream) {
if (stop) return;
createBlock("$INIT", blocktype::bt_block);
if (state->isEnabled("debugging")) {
cmd* c = new cmd;
c->opcode = codes::FILE;
c->args.push(value(fn));
current_chunk->addCmd(c);
}
ParseLoop(stream);
if (stop) return;
createBlock("$END", blocktype::bt_block);// Runs code that ensures that last user block is processed into the chunks array. Yes, I could have simply added in the lines of code at the end, but I didn't want to rewrite code again!

View File

@ -11,7 +11,7 @@ namespace dms {
}
token tokenstream::next() {
if (pos > this->tokens.size()-1)
return token{ tokentype::none,codes::NOOP,"EOS",0 };
return token{ tokentype::none,codes::NOOP,"EOS", this->tokens[pos - 2].line_num };
return this->tokens[pos++];
}
void tokenstream::prev() {
@ -38,13 +38,16 @@ namespace dms {
if (peek().type == to) {
open++;
next(); // Consume
while (open != 0) {
while (open != 0 && peek().type!=tokens::none) {
if (peek().type == to)
open++;
else if (peek().type == tc)
open--;
tok.push_back(next());
}
if (tok.back().type == tokens::eof) {
tok.clear(); // Empty the vector
}
}
return tok;
}
@ -68,7 +71,7 @@ namespace dms {
}
token tokenstream::peek() {
if (pos > this->tokens.size()-1)
return token{ tokentype::none,codes::NOOP,"EOS",0 };
return token{ tokentype::none,codes::NOOP,"EOS",this->tokens[pos - 2].line_num };
return this->tokens[pos];
}
tokenstream::tokenstream() {}
@ -133,7 +136,14 @@ namespace dms {
return random_string;
}
bool LineParser::notBalanced(std::vector<tokens::token> ts, size_t last_line, tokenstream* stream, std::string o, std::string c) {
if (ts.size() == 0) {
stop = true;
state->push_error(errors::error{ errors::unknown,utils::concat("Unbalanced match! '",c,"' Expected to close '",o,"' At Line: ",last_line),true,stream->peek().line_num,current_chunk });
return true;
}
return false;
}
bool LineParser::isBlock() {
return isBlock(bt_block); // Default block type
}
@ -257,12 +267,6 @@ namespace dms {
return true;
}
else if (bk_name == "$END") {
/*cmd* c = new cmd;
c->opcode = codes::JUMP;
c->args.push(buildValue("$END"));
current_chunk->addCmd(c);
state->push_chunk(current_chunk->name, current_chunk);
current_chunk = state->chunks["$END"];*/
return true;
}
else {
@ -292,6 +296,14 @@ namespace dms {
current_chunk->name = bk_name;
chunk_type = bk_type;
current_chunk->type = bk_type;
if (state->isEnabled("debugging")) {
cmd* c = new cmd;
c->opcode = codes::FILE;
c->args.push(value(fn));
current_chunk->addCmd(c);
}
state->push_chunk(bk_name, current_chunk);
return true;
}

View File

@ -18,7 +18,7 @@ const std::string dms::codes::list[] = {
"WHLE",
"FUNC",
"IFFF",
"ELIF",
"KNOT",
"ELSE",
"DEFN",
"SKIP",

View File

@ -10,23 +10,23 @@ namespace dms::codes {
LOAD, // Done
VERN, // Done
USIN, // TODO
STAT,
STAT, // Done
DISP, // Done
ASGN, // Done
LABL,
LABL, // Done
CHOI, // Done
OPTN,
FORE,
WHLE,
FUNC, // Done
IFFF,
ELIF,
ELSE,
IFFF, // Done
KNOT, // Done
ELSE, // Scraped
DEFN,
SKIP,
COMP,
COMP, // Done
INDX, // Done
JMPZ,
JMPZ, // Scraped see [COMP]
INST, // Done
ERRO,
GOTO,
@ -54,7 +54,4 @@ namespace dms::codes {
OFUN // Done
};
extern const std::string list[];
static bool isControl(const op code) {
return (code == STAT || code == CHOI || code == FORE || code == WHLE || code == IFFF || code == ELIF || code == ELSE);
};
}

View File

@ -157,7 +157,7 @@ namespace dms {
std::cout << err.err_msg << " On Line <" << err.linenum << ">" << std::endl;
}
else if (isEnabled("debugging")) {
std::cout << err.err_msg << " On Line <" << cur_line << ">" << std::endl;
std::cout << err.err_msg << " In File " << cur_file << " On Line <" << cur_line << ">" << std::endl;
}
else {
std::cout << err.err_msg << std::endl;

View File

@ -33,6 +33,7 @@ namespace dms {
std::string entry = "$undefined";
std::unordered_map<std::string, bool> enables;
std::size_t cur_line=0;
std::string cur_file = "";
int exitcode = 0;
const double Iversion = 1.0;
double Sversion; // The version of

View File

@ -158,6 +158,8 @@ namespace dms {
case DISA:
disable(c->args.args[0].getPrintable());
break;
case codes::FILE:
cur_file = c->args.args[0].getPrintable();
case LOAD:
// Nothing needs to be done here
break;
@ -184,6 +186,22 @@ namespace dms {
}
return true;
break;
case KNOT:
{
value cmp = c->args.args[0];
if (cmp.resolve(this).type == datatypes::boolean || cmp.resolve(this).isNil()) {
if (!cmp.resolve(this).b || cmp.resolve(this).isNil()) {
assign(cmp, value(true));
}
else {
assign(cmp, value(false));
}
}
else {
assign(cmp, value(false));
}
break;
}
case IFFF:
{
value cmp = c->args.args[0].resolve(this);

Binary file not shown.

View File

@ -21,6 +21,9 @@ Line <6> name savestate
Line <6> newline
Line <6> newline
Line <7> newline
Line <8> flag
Line <8> name debugging
Line <8> newline
Line <8> newline
Line <9> flag
Line <9> string loadtest.dms
@ -44,152 +47,147 @@ Line <13> equal =
Line <13> number 10
Line <13> newline
Line <13> newline
Line <14> name a2
Line <14> name b1
Line <14> equal =
Line <14> number 10
Line <14> number 15
Line <14> newline
Line <14> newline
Line <15> name a3
Line <15> name print
Line <15> parao (
Line <15> parao (
Line <15> name a1
Line <15> not !
Line <15> equal =
Line <15> number 10
Line <15> name b1
Line <15> parac )
Line <15> parac )
Line <15> newline
Line <15> newline
Line <16> name b1
Line <16> equal =
Line <16> number 15
Line <16> newline
Line <16> newline
Line <17> name b2
Line <17> name if
Line <17> parao (
Line <17> name a
Line <17> equal =
Line <17> number 15
Line <17> equal =
Line <17> name b
Line <17> parac )
Line <17> cbracketo {
Line <17> newline
Line <17> newline
Line <18> name b3
Line <18> equal =
Line <18> number 15
Line <18> name print
Line <18> parao (
Line <18> string Doing a test!
Line <18> parac )
Line <18> newline
Line <18> newline
Line <19> name if
Line <19> parao (
Line <19> name a
Line <19> not !
Line <19> equal =
Line <19> name b
Line <19> parac )
Line <19> cbracketo {
Line <19> newline
Line <19> newline
Line <20> name print
Line <20> parao (
Line <20> name a1
Line <20> equal =
Line <20> equal =
Line <20> name b1
Line <20> or
Line <20> parao (
Line <20> name a2
Line <20> not !
Line <20> equal =
Line <20> name b2
Line <20> and
Line <20> name a3
Line <20> equal =
Line <20> equal =
Line <20> name a3
Line <20> parac )
Line <20> or
Line <20> name a3
Line <20> anglebracketC >
Line <20> name b3
Line <20> string Doing more tests!
Line <20> parac )
Line <20> newline
Line <20> newline
Line <21> cbracketc }
Line <21> newline
Line <21> newline
Line <22> name if
Line <22> cbracketc }
Line <22> name elseif
Line <22> parao (
Line <22> name a
Line <22> name a1
Line <22> equal =
Line <22> equal =
Line <22> name b
Line <22> number 10
Line <22> parac )
Line <22> cbracketo {
Line <22> newline
Line <22> newline
Line <23> name print
Line <23> parao (
Line <23> string Doing a test!
Line <23> string Does this work?
Line <23> parac )
Line <23> newline
Line <23> newline
Line <24> name if
Line <24> parao (
Line <24> name a
Line <24> not !
Line <24> equal =
Line <24> name b
Line <24> parac )
Line <24> cbracketc }
Line <24> name else
Line <24> cbracketo {
Line <24> newline
Line <24> newline
Line <25> name print
Line <25> parao (
Line <25> string Doing more tests!
Line <25> string This is an else!
Line <25> parac )
Line <25> newline
Line <25> newline
Line <26> cbracketc }
Line <26> newline
Line <26> newline
Line <27> cbracketc }
Line <27> name elseif
Line <27> parao (
Line <27> name a1
Line <27> equal =
Line <27> equal =
Line <27> number 10
Line <27> parac )
Line <27> cbracketo {
Line <27> newline
Line <27> newline
Line <28> name print
Line <28> name if
Line <28> parao (
Line <28> string Does this work?
Line <28> name a1
Line <28> not !
Line <28> equal =
Line <28> number 10
Line <28> parac )
Line <28> name this
Line <28> parao (
Line <28> parac )
Line <28> pipe |
Line <28> cbracketo {
Line <28> newline
Line <28> newline
Line <29> cbracketc }
Line <29> name else
Line <29> cbracketo {
Line <29> name print
Line <29> parao (
Line <29> string Do you work?
Line <29> parac )
Line <29> newline
Line <29> newline
Line <30> name print
Line <30> parao (
Line <30> string This is an else!
Line <30> parac )
Line <30> cbracketc }
Line <30> newline
Line <30> newline
Line <31> cbracketc }
Line <31> newline
Line <31> newline
Line <32> newline
Line <32> newline
Line <33> name if
Line <33> name print
Line <33> parao (
Line <33> name a1
Line <33> equal =
Line <33> equal =
Line <33> number 10
Line <33> string This is coming along nicely!
Line <33> parac )
Line <33> cbracketo {
Line <33> newline
Line <33> newline
Line <34> name print
Line <34> parao (
Line <34> string Hi
Line <34> parac )
Line <34> newline
Line <34> newline
Line <35> cbracketc }
Line <35> name print
Line <35> parao (
Line <35> string concat test
Line <35> parac )
Line <35> newline
Line <35> newline
Line <36> name test1
Line <36> equal =
Line <36> string Hello
Line <36> newline
Line <36> newline
Line <37> name print
Line <37> parao (
Line <37> string This is coming along nicely!
Line <37> number 2.2
Line <37> plus +
Line <37> name test1
Line <37> plus +
Line <37> string World!
Line <37> plus +
Line <37> name fake
Line <37> parac )
Line <37> newline
Line <37> newline
@ -197,136 +195,136 @@ Line <38> newline
Line <39> newline
Line <40> newline
Line <41> newline
Line <41> newline
Line <42> name if
Line <42> parao (
Line <42> name this
Line <42> equal =
Line <42> equal =
Line <42> name that
Line <42> parac )
Line <42> name this
Line <42> parao (
Line <42> parac )
Line <42> pipe |
Line <42> name that
Line <42> parao (
Line <42> parac )
Line <42> newline
Line <42> newline
Line <43> newline
Line <43> newline
Line <44> bracketo [
Line <44> name this
Line <44> colon :
Line <44> name function
Line <44> parao (
Line <44> parac )
Line <44> bracketc ]
Line <44> newline
Line <44> newline
Line <45> name print
Line <45> parao (
Line <45> string This
Line <45> parac )
Line <45> newline
Line <45> newline
Line <46> newline
Line <46> newline
Line <47> bracketo [
Line <47> name that
Line <47> colon :
Line <47> name function
Line <47> parao (
Line <47> parac )
Line <47> bracketc ]
Line <47> newline
Line <47> newline
Line <48> name print
Line <48> parao (
Line <48> string That
Line <48> parac )
Line <48> newline
Line <48> newline
Line <49> newline
Line <49> newline
Line <50> bracketo [
Line <50> name Bob
Line <50> colon :
Line <50> name char
Line <50> bracketc ]
Line <50> newline
Line <50> newline
Line <51> newline
Line <51> newline
Line <52> newline
Line <53> newline
Line <53> newline
Line <54> bracketo [
Line <54> name this
Line <54> colon :
Line <54> name function
Line <54> parao (
Line <54> parac )
Line <54> bracketc ]
Line <54> name unknown
Line <54> equal =
Line <54> string Some Random Guy
Line <54> newline
Line <54> newline
Line <55> name print
Line <55> parao (
Line <55> string This
Line <55> parac )
Line <55> name age
Line <55> equal =
Line <55> number .24
Line <55> newline
Line <55> newline
Line <56> name money
Line <56> equal =
Line <56> number 100
Line <56> newline
Line <56> newline
Line <57> bracketo [
Line <57> name that
Line <57> name excited
Line <57> colon :
Line <57> name function
Line <57> parao (
Line <57> parac )
Line <57> bracketc ]
Line <57> string path/to/file
Line <57> newline
Line <57> newline
Line <58> name print
Line <58> parao (
Line <58> string That
Line <58> parac )
Line <58> newline
Line <58> newline
Line <59> bracketo [
Line <59> name test1
Line <59> colon :
Line <59> name function
Line <59> parao (
Line <59> parac )
Line <59> bracketc ]
Line <59> newline
Line <59> newline
Line <60> bracketo [
Line <60> name Bob
Line <60> colon :
Line <60> name char
Line <60> bracketc ]
Line <60> string Inside a function!
Line <60> newline
Line <60> newline
Line <61> newline
Line <62> newline
Line <63> newline
Line <64> name unknown
Line <64> equal =
Line <64> string Some Random Guy
Line <63> newline
Line <64> bracketo [
Line <64> name newblock
Line <64> colon :
Line <64> name function
Line <64> parao (
Line <64> name a
Line <64> seperator ,
Line <64> name b
Line <64> seperator ,
Line <64> name c
Line <64> parac )
Line <64> bracketc ]
Line <64> newline
Line <64> newline
Line <65> name age
Line <65> equal =
Line <65> number 0.24
Line <65> string Func Arguments: a = `a`, b = `b`, c = `c`
Line <65> newline
Line <65> newline
Line <66> name money
Line <66> equal =
Line <66> number 100
Line <66> string Time to return
Line <66> newline
Line <66> newline
Line <67> name excited
Line <67> colon :
Line <67> string path/to/file
Line <67> ret
Line <67> name a
Line <67> plus +
Line <67> name b
Line <67> plus +
Line <67> name c
Line <67> newline
Line <67> newline
Line <68> newline
Line <68> newline
Line <69> bracketo [
Line <69> name test1
Line <69> colon :
Line <69> name function
Line <69> parao (
Line <69> parac )
Line <69> bracketc ]
Line <69> newline
Line <69> newline
Line <70> string Inside a function!
Line <70> newline
Line <70> newline
Line <71> newline
Line <72> newline
Line <73> newline
Line <73> newline
Line <74> bracketo [
Line <74> name newblock
Line <74> colon :
Line <74> name function
Line <74> parao (
Line <74> name a
Line <74> seperator ,
Line <74> name b
Line <74> seperator ,
Line <74> name c
Line <74> parac )
Line <74> bracketc ]
Line <74> newline
Line <74> newline
Line <75> string Func Arguments: a = `a`, b = `b`, c = `c`
Line <75> newline
Line <75> newline
Line <76> string Time to return
Line <76> newline
Line <76> newline
Line <77> ret
Line <77> name a
Line <77> plus +
Line <77> name b
Line <77> plus +
Line <77> name c
Line <77> newline
Line <77> newline
Line <77> eof
Line <67> eof
Line <1> newline
Line <1> newline
Line <1> bracketo [

View File

@ -5,19 +5,14 @@ enable fullname
enable forwardlabels // Do most of your labels exist ahead?
enable savestate
//enable leaking
//enable debugging
enable debugging
loadfile "loadtest.dms"
version 0.2
using extendedDefine
[main]
a1 = 10
a2 = 10
a3 = 10
b1 = 15
b2 = 15
b3 = 15
print(a1==b1 or (a2!=b2 and a3==a3) or a3>b3)
print((a1!=b1))
if(a==b){
print("Doing a test!")
@ -30,24 +25,21 @@ using extendedDefine
print("This is an else!")
}
if(a1==10) this()|that()
if(a1!=10) this() | {
print("Do you work?")
}
print("This is coming along nicely!")
print("concat test")
test1 = "Hello "
print(2.2+test1+"World!"+fake)
// for(x, 10, 1, -1){
// print(x)
// }
// 0 + (1 * 0) + 0
// if (this==that) this()|that()
// if(this == that){
// } elseif (that > this) {
// } else {
// }
if (this==that) this()|that()
[this:function()]
print("This")

View File

@ -176,7 +176,7 @@ namespace dms {
else if (lhs.type == datatypes::boolean && rhs.type == datatypes::boolean) {
return value((bool)(lhs.b + rhs.b));
}
else if (lhs.type == datatypes::string || rhs.type == datatypes::string) {
else if ((lhs.type == datatypes::string && !(rhs.type == nil)) || rhs.type == datatypes::string && !(lhs.type == nil)) {
return lhs.getPrintable() + rhs.getPrintable();
}
else {
@ -371,7 +371,14 @@ namespace dms {
return s;
}
else if (type == number) {
return std::to_string(n);
std::string temp = std::to_string(n);
while (temp.find(".") != std::string::npos // !=string::npos is important!!!
&& temp.substr(temp.length() - 1, 1) == "0"
|| temp.substr(temp.length() - 1, 1) == ".")
{
temp.pop_back();
}
return temp;
}
else if (type == nil) {
return "nil";