Rename variables to camel case
This commit is contained in:
parent
df22a7f065
commit
66586a1427
@ -242,10 +242,10 @@ AnalysisResult analyze(Node &ast, Memory &memory) {
|
|||||||
return type;
|
return type;
|
||||||
} break;
|
} break;
|
||||||
case NodeType::Assignment: {
|
case NodeType::Assignment: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
if (!memory.contains(identifier))
|
if (!memory.contains(identifier))
|
||||||
throw TypeError(ErrorType::UnknownIdentifier, identifierTok.pos, identifier);
|
throw TypeError(ErrorType::UnknownIdentifier, identifier_token.pos, identifier);
|
||||||
|
|
||||||
Type type = memory.get(identifier).type;
|
Type type = memory.get(identifier).type;
|
||||||
AnalysisResult res = analyze(node.children[1], memory);
|
AnalysisResult res = analyze(node.children[1], memory);
|
||||||
@ -258,11 +258,11 @@ AnalysisResult analyze(Node &ast, Memory &memory) {
|
|||||||
case NodeType::RIncr:
|
case NodeType::RIncr:
|
||||||
case NodeType::LDecr:
|
case NodeType::LDecr:
|
||||||
case NodeType::RDecr: {
|
case NodeType::RDecr: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
if (!memory.contains(identifier))
|
if (!memory.contains(identifier))
|
||||||
throw TypeError(ErrorType::UnknownIdentifier, identifierTok.pos, identifier);
|
throw TypeError(ErrorType::UnknownIdentifier, identifier_token.pos, identifier);
|
||||||
|
|
||||||
return memory.get(identifier).type;
|
return memory.get(identifier).type;
|
||||||
}
|
}
|
||||||
|
@ -148,9 +148,9 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
return {};
|
return {};
|
||||||
} break;
|
} break;
|
||||||
case NodeType::FunctionPrototype: {
|
case NodeType::FunctionPrototype: {
|
||||||
Token retTypeTok = get<Token>(node.children[0]);
|
Token ret_type_token = get<Token>(node.children[0]);
|
||||||
Token identifierTok = get<Token>(node.children[1]);
|
Token identifier_token = get<Token>(node.children[1]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
FunctionPrototype prototype = make_fn_prototype(node);
|
FunctionPrototype prototype = make_fn_prototype(node);
|
||||||
|
|
||||||
@ -162,9 +162,9 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
return {};
|
return {};
|
||||||
} break;
|
} break;
|
||||||
case NodeType::FunctionDeclaration: {
|
case NodeType::FunctionDeclaration: {
|
||||||
Token retTypeTok = get<Token>(node.children[0]);
|
Token ret_type_token = get<Token>(node.children[0]);
|
||||||
Token identifierTok = get<Token>(node.children[1]);
|
Token identifier_token = get<Token>(node.children[1]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
FunctionPrototype prototype = make_fn_prototype(node);
|
FunctionPrototype prototype = make_fn_prototype(node);
|
||||||
|
|
||||||
@ -180,35 +180,35 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
return {};
|
return {};
|
||||||
} break;
|
} break;
|
||||||
case NodeType::FunctionCall: {
|
case NodeType::FunctionCall: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
vector<Node> args = get<InnerNode>(node.children[1]).children;
|
vector<Node> args = get<InnerNode>(node.children[1]).children;
|
||||||
|
|
||||||
MemoryVar& var = memory.get(identifier);
|
MemoryVar& var = memory.get(identifier);
|
||||||
|
|
||||||
if (!var.initialized)
|
if (!var.initialized)
|
||||||
throw RuntimeError(ErrorType::UninitializedIdentifier, identifierTok.pos, memory.get_trace(identifierTok.pos), identifier);
|
throw RuntimeError(ErrorType::UninitializedIdentifier, identifier_token.pos, memory.get_trace(identifier_token.pos), identifier);
|
||||||
|
|
||||||
Function& fn = get<Function>(var.value);
|
Function& fn = get<Function>(var.value);
|
||||||
FunctionPrototype& prototype = get<FunctionPrototype>(var.type.data);
|
FunctionPrototype& prototype = get<FunctionPrototype>(var.type.data);
|
||||||
|
|
||||||
vector<EvalResult> argValues = {};
|
vector<EvalResult> args_values = {};
|
||||||
for (Node arg : args) {
|
for (Node arg : args) {
|
||||||
argValues.push_back(eval(arg, memory));
|
args_values.push_back(eval(arg, memory));
|
||||||
}
|
}
|
||||||
|
|
||||||
EvalResult res = {};
|
EvalResult res = {};
|
||||||
|
|
||||||
if (holds_alternative<UserFunction>(fn)) {
|
if (holds_alternative<UserFunction>(fn)) {
|
||||||
memory.add_scope(ScopeType::Function, &var, identifierTok.pos);
|
memory.add_scope(ScopeType::Function, &var, identifier_token.pos);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (size_t i = 1; i < prototype.size(); i++) {
|
for (size_t i = 1; i < prototype.size(); i++) {
|
||||||
ArgDefinition argDef = prototype[i];
|
ArgDefinition arg_definition = prototype[i];
|
||||||
Type argType = get<0>(argDef);
|
Type arg_type = get<0>(arg_definition);
|
||||||
string argName = get<1>(argDef);
|
string arg_name = get<1>(arg_definition);
|
||||||
memory.declare(argName, argType);
|
memory.declare(arg_name, arg_type);
|
||||||
memory.update(argName, cast_from_type(argType, argValues[i - 1]));
|
memory.update(arg_name, cast_from_type(arg_type, args_values[i - 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -216,7 +216,7 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
|
|
||||||
// Tmp: no flow control
|
// Tmp: no flow control
|
||||||
if (get<0>(prototype[0]).type != TypeType::Void) {
|
if (get<0>(prototype[0]).type != TypeType::Void) {
|
||||||
throw ControlError(ErrorType::ControlReachesEndOfNonVoidFn, identifierTok.pos);
|
throw ControlError(ErrorType::ControlReachesEndOfNonVoidFn, identifier_token.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const ReturnException& e) {
|
catch (const ReturnException& e) {
|
||||||
@ -429,24 +429,24 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NodeType::Declaration: {
|
case NodeType::Declaration: {
|
||||||
Token typeTok = get<Token>(node.children[0]);
|
Token type_token = get<Token>(node.children[0]);
|
||||||
Token identifierTok = get<Token>(node.children[1]);
|
Token identifier_token = get<Token>(node.children[1]);
|
||||||
string typeName = get<string>(typeTok.data);
|
string type_name = get<string>(type_token.data);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
Type type = string_to_type(typeName);
|
Type type = string_to_type(type_name);
|
||||||
memory.declare(identifier, type);
|
memory.declare(identifier, type);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
} break;
|
} break;
|
||||||
case NodeType::AssignedDeclaration: {
|
case NodeType::AssignedDeclaration: {
|
||||||
Token typeTok = get<Token>(node.children[0]);
|
Token type_token = get<Token>(node.children[0]);
|
||||||
Token identifierTok = get<Token>(node.children[1]);
|
Token identifier_token = get<Token>(node.children[1]);
|
||||||
string typeName = get<string>(typeTok.data);
|
string type_name = get<string>(type_token.data);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
EvalResult value = eval(node.children[2], memory);
|
EvalResult value = eval(node.children[2], memory);
|
||||||
|
|
||||||
Type type = string_to_type(typeName);
|
Type type = string_to_type(type_name);
|
||||||
memory.declare(identifier, type);
|
memory.declare(identifier, type);
|
||||||
|
|
||||||
if (type.type == TypeType::Int) {
|
if (type.type == TypeType::Int) {
|
||||||
@ -459,8 +459,8 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
return value;
|
return value;
|
||||||
} break;
|
} break;
|
||||||
case NodeType::Assignment: {
|
case NodeType::Assignment: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
EvalResult value = eval(node.children[1], memory);
|
EvalResult value = eval(node.children[1], memory);
|
||||||
|
|
||||||
Type type = memory.get(identifier).type;
|
Type type = memory.get(identifier).type;
|
||||||
@ -478,13 +478,13 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
return value;
|
return value;
|
||||||
} break;
|
} break;
|
||||||
case NodeType::LIncr: {
|
case NodeType::LIncr: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
MemoryVar& var = memory.get(identifier);
|
MemoryVar& var = memory.get(identifier);
|
||||||
|
|
||||||
if (!var.initialized) {
|
if (!var.initialized) {
|
||||||
throw RuntimeError(ErrorType::UninitializedIdentifier, identifierTok.pos, memory.get_trace(identifierTok.pos), identifier);
|
throw RuntimeError(ErrorType::UninitializedIdentifier, identifier_token.pos, memory.get_trace(identifier_token.pos), identifier);
|
||||||
}
|
}
|
||||||
else if (var.type.type == TypeType::Int) {
|
else if (var.type.type == TypeType::Int) {
|
||||||
memory.update(identifier, get<int>(var.value) + 1);
|
memory.update(identifier, get<int>(var.value) + 1);
|
||||||
@ -495,31 +495,31 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case NodeType::RIncr: {
|
case NodeType::RIncr: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
MemoryVar& var = memory.get(identifier);
|
MemoryVar& var = memory.get(identifier);
|
||||||
|
|
||||||
if (!var.initialized) {
|
if (!var.initialized) {
|
||||||
throw RuntimeError(ErrorType::UninitializedIdentifier, identifierTok.pos, memory.get_trace(identifierTok.pos), identifier);
|
throw RuntimeError(ErrorType::UninitializedIdentifier, identifier_token.pos, memory.get_trace(identifier_token.pos), identifier);
|
||||||
}
|
}
|
||||||
else if (var.type.type == TypeType::Int) {
|
else if (var.type.type == TypeType::Int) {
|
||||||
int oldVal = get<int>(var.value);
|
int old_value = get<int>(var.value);
|
||||||
memory.update(identifier, oldVal + 1);
|
memory.update(identifier, old_value + 1);
|
||||||
return oldVal;
|
return old_value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return var.value;
|
return var.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case NodeType::LDecr: {
|
case NodeType::LDecr: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
MemoryVar& var = memory.get(identifier);
|
MemoryVar& var = memory.get(identifier);
|
||||||
|
|
||||||
if (!var.initialized) {
|
if (!var.initialized) {
|
||||||
throw RuntimeError(ErrorType::UninitializedIdentifier, identifierTok.pos, memory.get_trace(identifierTok.pos), identifier);
|
throw RuntimeError(ErrorType::UninitializedIdentifier, identifier_token.pos, memory.get_trace(identifier_token.pos), identifier);
|
||||||
}
|
}
|
||||||
else if (var.type.type == TypeType::Int) {
|
else if (var.type.type == TypeType::Int) {
|
||||||
memory.update(identifier, get<int>(var.value) - 1);
|
memory.update(identifier, get<int>(var.value) - 1);
|
||||||
@ -530,18 +530,18 @@ EvalResult eval(Node &ast, Memory &memory, vector<string> history) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case NodeType::RDecr: {
|
case NodeType::RDecr: {
|
||||||
Token identifierTok = get<Token>(node.children[0]);
|
Token identifier_token = get<Token>(node.children[0]);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
|
|
||||||
MemoryVar& var = memory.get(identifier);
|
MemoryVar& var = memory.get(identifier);
|
||||||
|
|
||||||
if (!var.initialized) {
|
if (!var.initialized) {
|
||||||
throw RuntimeError(ErrorType::UninitializedIdentifier, identifierTok.pos, memory.get_trace(identifierTok.pos), identifier);
|
throw RuntimeError(ErrorType::UninitializedIdentifier, identifier_token.pos, memory.get_trace(identifier_token.pos), identifier);
|
||||||
}
|
}
|
||||||
else if (var.type.type == TypeType::Int) {
|
else if (var.type.type == TypeType::Int) {
|
||||||
int oldVal = get<int>(var.value);
|
int old_value = get<int>(var.value);
|
||||||
memory.update(identifier, oldVal - 1);
|
memory.update(identifier, old_value - 1);
|
||||||
return oldVal;
|
return old_value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return var.value;
|
return var.value;
|
||||||
|
@ -61,11 +61,11 @@ bool Memory::contains_top(string identifier) {
|
|||||||
|
|
||||||
void Memory::add_scope(ScopeType type, MemoryVar* fn, CodePosition entry_pos) {
|
void Memory::add_scope(ScopeType type, MemoryVar* fn, CodePosition entry_pos) {
|
||||||
Scope& top = scopes.back();
|
Scope& top = scopes.back();
|
||||||
Scope& newScope = scopes.emplace_back();
|
Scope& new_scope = scopes.emplace_back();
|
||||||
newScope.depth = top.depth + 1;
|
new_scope.depth = top.depth + 1;
|
||||||
newScope.type = type;
|
new_scope.type = type;
|
||||||
newScope.fn = fn;
|
new_scope.fn = fn;
|
||||||
newScope.entry_pos = entry_pos;
|
new_scope.entry_pos = entry_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Memory::remove_scope(void) {
|
void Memory::remove_scope(void) {
|
||||||
|
@ -23,9 +23,9 @@ const char* _debug_ast_node_names[] = {
|
|||||||
};
|
};
|
||||||
void _debug_print_tree(const Node& node, int depth, const string& prefix) {
|
void _debug_print_tree(const Node& node, int depth, const string& prefix) {
|
||||||
if (holds_alternative<InnerNode>(node)) {
|
if (holds_alternative<InnerNode>(node)) {
|
||||||
const InnerNode& innerNode = get<InnerNode>(node);
|
const InnerNode& inner_node = get<InnerNode>(node);
|
||||||
|
|
||||||
cout << prefix << _debug_ast_node_names[int(innerNode.type)] << "\n";
|
cout << prefix << _debug_ast_node_names[int(inner_node.type)] << "\n";
|
||||||
|
|
||||||
string new_prefix = prefix;
|
string new_prefix = prefix;
|
||||||
size_t pos = new_prefix.find("└──");
|
size_t pos = new_prefix.find("└──");
|
||||||
@ -40,9 +40,9 @@ void _debug_print_tree(const Node& node, int depth, const string& prefix) {
|
|||||||
pos = new_prefix.find("├──", pos + 6);
|
pos = new_prefix.find("├──", pos + 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < innerNode.children.size(); ++i) {
|
for (size_t i = 0; i < inner_node.children.size(); ++i) {
|
||||||
string childPrefix = (i == innerNode.children.size() - 1) ? "└── " : "├── ";
|
string child_prefix = (i == inner_node.children.size() - 1) ? "└── " : "├── ";
|
||||||
_debug_print_tree(innerNode.children[i], depth + 1, new_prefix + childPrefix);
|
_debug_print_tree(inner_node.children[i], depth + 1, new_prefix + child_prefix);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Token& token = get<Token>(node);
|
const Token& token = get<Token>(node);
|
||||||
|
@ -10,7 +10,7 @@ regex INT_REGEX ("\\d+");
|
|||||||
regex DOUBLE_REGEX ("\\d+\\.\\d*|\\d*\\.\\d+");
|
regex DOUBLE_REGEX ("\\d+\\.\\d*|\\d*\\.\\d+");
|
||||||
regex IDENTIFIER_REGEX ("[A-Za-z_]\\w*");
|
regex IDENTIFIER_REGEX ("[A-Za-z_]\\w*");
|
||||||
|
|
||||||
vector<tuple<string, TokenType>> simpleTokens = {
|
vector<tuple<string, TokenType>> simple_tokens = {
|
||||||
{ "if", TokenType::If },
|
{ "if", TokenType::If },
|
||||||
{ "else", TokenType::Else },
|
{ "else", TokenType::Else },
|
||||||
{ "while", TokenType::While },
|
{ "while", TokenType::While },
|
||||||
@ -236,11 +236,11 @@ vector<Token> tokenize(vector<string> input, int initial_line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool matched = false;
|
bool matched = false;
|
||||||
for (auto simpleToken: simpleTokens) {
|
for (auto simple_token: simple_tokens) {
|
||||||
if (str.starts_with(get<0>(simpleToken))) {
|
if (str.starts_with(get<0>(simple_token))) {
|
||||||
Token token = { .type = get<1>(simpleToken), .pos = pos };
|
Token token = { .type = get<1>(simple_token), .pos = pos };
|
||||||
tokens.emplace_back(token);
|
tokens.emplace_back(token);
|
||||||
j += get<0>(simpleToken).length();
|
j += get<0>(simple_token).length();
|
||||||
matched = true;
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -36,20 +36,20 @@ Type string_to_type(string type_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FunctionPrototype make_fn_prototype(InnerNode node) {
|
FunctionPrototype make_fn_prototype(InnerNode node) {
|
||||||
Token retTypeTok = get<Token>(node.children[0]);
|
Token ret_type_token = get<Token>(node.children[0]);
|
||||||
string retTypeName = get<string>(retTypeTok.data);
|
string ret_type_name = get<string>(ret_type_token.data);
|
||||||
Type retType = string_to_type(retTypeName);
|
Type ret_type = string_to_type(ret_type_name);
|
||||||
|
|
||||||
vector<Node> args = get<InnerNode>(node.children[2]).children;
|
vector<Node> args = get<InnerNode>(node.children[2]).children;
|
||||||
FunctionPrototype prototype = { { retType, "" } };
|
FunctionPrototype prototype = { { ret_type, "" } };
|
||||||
|
|
||||||
for (Node arg : args) {
|
for (Node arg : args) {
|
||||||
InnerNode argInner = get<InnerNode>(arg);
|
InnerNode arg_inner = get<InnerNode>(arg);
|
||||||
Token typeTok = get<Token>(argInner.children[0]);
|
Token type_token = get<Token>(arg_inner.children[0]);
|
||||||
Token identifierTok = get<Token>(argInner.children[1]);
|
Token identifier_token = get<Token>(arg_inner.children[1]);
|
||||||
string typeName = get<string>(typeTok.data);
|
string type_name = get<string>(type_token.data);
|
||||||
string identifier = get<string>(identifierTok.data);
|
string identifier = get<string>(identifier_token.data);
|
||||||
Type type = string_to_type(typeName);
|
Type type = string_to_type(type_name);
|
||||||
prototype.push_back({ type, identifier });
|
prototype.push_back({ type, identifier });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ FunctionPrototype make_fn_prototype(InnerNode node) {
|
|||||||
vector<string> split_string(const string& input, char delimiter) {
|
vector<string> split_string(const string& input, char delimiter) {
|
||||||
vector<string> tokens;
|
vector<string> tokens;
|
||||||
string token;
|
string token;
|
||||||
istringstream tokenStream(input);
|
istringstream token_stream(input);
|
||||||
|
|
||||||
while (getline(tokenStream, token, delimiter)) {
|
while (getline(token_stream, token, delimiter)) {
|
||||||
tokens.push_back(token);
|
tokens.push_back(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ int main() {
|
|||||||
"int", "a", "=", "x", "++", "--", "==", "&&", "||", "<", ">", "<=", ">=", "!=", "!", "*", "/", "%", "=", ";", "(", ")", "{", "}", "if", "else", "while", "for", "break", "continue", "return", ","
|
"int", "a", "=", "x", "++", "--", "==", "&&", "||", "<", ">", "<=", ">=", "!=", "!", "*", "/", "%", "=", ";", "(", ")", "{", "}", "if", "else", "while", "for", "break", "continue", "return", ","
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<TokenType> expectedTypes = {
|
vector<TokenType> expected_types = {
|
||||||
TokenType::Identifier, TokenType::Identifier, TokenType::Equal, TokenType::Identifier,
|
TokenType::Identifier, TokenType::Identifier, TokenType::Equal, TokenType::Identifier,
|
||||||
TokenType::DoublePlus, TokenType::DoubleMinus, TokenType::DoubleEqual, TokenType::Land,
|
TokenType::DoublePlus, TokenType::DoubleMinus, TokenType::DoubleEqual, TokenType::Land,
|
||||||
TokenType::Lor, TokenType::Lt, TokenType::Gt, TokenType::Leq, TokenType::Geq, TokenType::NotEqual,
|
TokenType::Lor, TokenType::Lt, TokenType::Gt, TokenType::Leq, TokenType::Geq, TokenType::NotEqual,
|
||||||
@ -26,8 +26,8 @@ int main() {
|
|||||||
|
|
||||||
for (size_t i = 0; i < inputs.size(); i++) {
|
for (size_t i = 0; i < inputs.size(); i++) {
|
||||||
vector<Token> tokens = tokenize({ inputs[i] });
|
vector<Token> tokens = tokenize({ inputs[i] });
|
||||||
_TEST_ASSERT(tokens.size() == 1, _debug_get_token_type_name(expectedTypes[i]).c_str(), false);
|
_TEST_ASSERT(tokens.size() == 1, _debug_get_token_type_name(expected_types[i]).c_str(), false);
|
||||||
_TEST_ASSERT(tokens[0].type == expectedTypes[i], _debug_get_token_type_name(expectedTypes[i]).c_str(), true);
|
_TEST_ASSERT(tokens[0].type == expected_types[i], _debug_get_token_type_name(expected_types[i]).c_str(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Complex input */
|
/* Complex input */
|
||||||
|
@ -12,7 +12,7 @@ int main() {
|
|||||||
_TEST_PRESENTATION("Variables");
|
_TEST_PRESENTATION("Variables");
|
||||||
|
|
||||||
_TEST_ASSERT(
|
_TEST_ASSERT(
|
||||||
_TEST_NO_EXCEPTION(get<int>(execute("int uneVariableFarfelue__ = 12;")) == 12),
|
_TEST_NO_EXCEPTION(get<int>(execute("int __une_variable_farfelue__ = 12;")) == 12),
|
||||||
"Déclaration avec assignement",
|
"Déclaration avec assignement",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user