diff --git a/Bobfile b/Bobfile index 761027e..99a13a8 100644 --- a/Bobfile +++ b/Bobfile @@ -1,4 +1,4 @@ compiler "g++"; -binary "mx"; +binary "bogus"; source "src/*.cpp"; compile; diff --git a/bogus b/bogus new file mode 100755 index 0000000..c0915a4 Binary files /dev/null and b/bogus differ diff --git a/mx b/mx deleted file mode 100755 index e640673..0000000 Binary files a/mx and /dev/null differ diff --git a/names.mx b/names.bo similarity index 100% rename from names.mx rename to names.bo diff --git a/password.bo b/password.bo new file mode 100644 index 0000000..d53b779 --- /dev/null +++ b/password.bo @@ -0,0 +1,5 @@ +print "Enter your password: "; +let str passwdInput input; +if passwdInput == "dingus" { + println "Thank you for entering the right password."; +} diff --git a/src/ArgParser.cpp b/src/ArgParser.cpp index 27c6cbd..161bfc4 100644 --- a/src/ArgParser.cpp +++ b/src/ArgParser.cpp @@ -14,16 +14,16 @@ ArgParser::ArgParser(int argc, char* argv[]) { debugMode = true; args.erase(args.begin() + i); } else if (args[i] == "--help") { - cout << "mxlang interpreter" << endl; - cout << "Usage: mx [file]" << endl; + cout << "Boguslang interpreter" << endl; + cout << "Usage: bogus [file]" << endl; cout << "Options:" << endl; cout << " --debug Enable debug mode" << endl; cout << " --help Show this help message" << endl; cout << "Issues? Send an email to max@maxwellj.xyz" << endl; - cout << "Report bugs at https://git.maxwellj.xyz/max/mx" << endl; + cout << "Report bugs at https://git.maxwellj.xyz/max/bogus" << endl; exit(0); } else if (args[i] == "--version") { - cout << "mxlang, version 0.0.2" << endl; + cout << "Boguslang, version 0.0.3" << endl; exit(0); } diff --git a/src/Interpreter.cpp b/src/Interpreter.cpp index 38b11ad..da1e1a0 100644 --- a/src/Interpreter.cpp +++ b/src/Interpreter.cpp @@ -1,4 +1,5 @@ #include "Interpreter.h" +#include "common.h" optional Interpreter::consume() { tokenIndex++; @@ -43,12 +44,26 @@ void Interpreter::convertToTokens(vector tokenList) { auto varIt = variables.find(potentialVarName); if (varIt != variables.end()) { - // Replace the token with the variable's value - Token newToken; - newToken.keyword = keywords::VALUE; - newToken.type = varIt->second.type; - newToken.value = varIt->second; - currentInstruction[i] = newToken; + // This is pretty crappy code but it exists for now. Lists are gonna break this so much it's not even gonna be funny + if (varIt->second.type == valtype::LIST) { + if (peek()->keyword == keywords::OSQUA) { + if (peek(2)->keyword == keywords::VALUE && peek(2)->type == valtype::INT && peek(2)->type == valtype::INT && peek(3)->keyword == keywords::CSQUA) { + Token newToken; + Value tokenVal = get(varIt->second.value).value[get(peek(2)->value.value)]; + newToken.keyword = keywords::VALUE; + newToken.type = tokenVal.type; + newToken.value.value = tokenVal.value; + // Do this later + } + } + } else { + // Replace the token with the variable's value + Token newToken; + newToken.keyword = keywords::VALUE; + newToken.type = varIt->second.type; + newToken.value = varIt->second; + currentInstruction[i] = newToken; + } } } else if (currentInstruction[i].keyword == keywords::INPUT) { Token newToken; @@ -405,4 +420,4 @@ void Interpreter::executeCode(vector tokens) { } } } -} \ No newline at end of file +} diff --git a/src/Parser.cpp b/src/Parser.cpp index 0826da3..28cf22b 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -131,6 +131,8 @@ void Parser::processLines() { else if (ct == "<") token.keyword = keywords::LESS; else if (ct == ">") token.keyword = keywords::GREATER; else if (ct == "//") token.keyword = keywords::COMMENT; + else if (ct == "[") token.keyword = keywords::OSQUA; + else if (ct == "]") token.keyword = keywords::CSQUA; else { token.keyword = keywords::VALUE; // Convert the value based on its type diff --git a/src/common.h b/src/common.h index 091d468..adbb7e6 100644 --- a/src/common.h +++ b/src/common.h @@ -10,12 +10,12 @@ using namespace std; enum class valtype { - INT, DEC, STR, BOOL, KEYWORD, UNKNOWN + INT, DEC, STR, BOOL, LIST, KEYWORD, UNKNOWN }; enum class keywords { IF, ELSE, WHILE, INT, DEC, STR, BOOL, FUN, RETURN, - OPARE, CPARE, OBRAC, CBRAC, + OPARE, CPARE, OBRAC, CBRAC, OSQUA, CSQUA, COMMA, SET, ADDTO, SUBTRACTFROM, MULTIPLYTO, DIVIDEFROM, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, LESS, GREATER, EQLESS, EQGREATER, @@ -25,9 +25,16 @@ enum class keywords { COMMENT }; +struct Value; + +struct List { + valtype type; + vector value; +}; + struct Value { valtype type; - variant value; + variant value; }; struct Token { diff --git a/test.mx b/test.bo similarity index 74% rename from test.mx rename to test.bo index 180f2ac..951f1a4 100644 --- a/test.mx +++ b/test.bo @@ -1,4 +1,4 @@ -let str thing2 "dingus"; +let str thing1 "dingus"; let str thing2 "dingus"; if thing1 == thing2 { @@ -9,4 +9,4 @@ print "this is printing something without a new line"; println " this is coming from a seperate print statement lols"; print "Say some wise words... "; -println "Ah, '" + input + "', some very wise words indeed!"; \ No newline at end of file +println "Ah, '" + input + "', some very wise words indeed!"; diff --git a/test.fish b/test.fish index 9e82140..35b33ca 100644 --- a/test.fish +++ b/test.fish @@ -2,4 +2,4 @@ bob -./mx test.mx \ No newline at end of file +./bogus test.bo