WIP conditionals work
This commit is contained in:
35
src/main.cpp
35
src/main.cpp
@@ -164,6 +164,23 @@ namespace HighGround {
|
|||||||
code.push_back(codeBlock);
|
code.push_back(codeBlock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case HGNodeType::Equal: {
|
||||||
|
std::cout << "Equal node children: " << children.size() << "\n";
|
||||||
|
std::cout << "Left outputId: '" << children[0].outputId << "'\n";
|
||||||
|
std::cout << "Right outputId: '" << children[1].outputId << "'\n";
|
||||||
|
HGGroundCodeBlock codeBlock;
|
||||||
|
outputId = "tmp_" + std::to_string(tmpIdIterator++);
|
||||||
|
GroundInstruction gi = groundCreateInstruction(EQUAL);
|
||||||
|
if (children.size() < 2) {
|
||||||
|
std::cout << "Need more stuff to equal\n";
|
||||||
|
}
|
||||||
|
groundAddReferenceToInstruction(&gi, groundCreateReference(VALREF, children[0].outputId.data()));
|
||||||
|
groundAddReferenceToInstruction(&gi, groundCreateReference(VALREF, children[1].outputId.data()));
|
||||||
|
groundAddReferenceToInstruction(&gi, groundCreateReference(DIRREF, outputId.data()));
|
||||||
|
codeBlock.code.push_back(gi);
|
||||||
|
code.push_back(codeBlock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case HGNodeType::Puts: {
|
case HGNodeType::Puts: {
|
||||||
HGGroundCodeBlock codeBlock;
|
HGGroundCodeBlock codeBlock;
|
||||||
GroundInstruction gi = groundCreateInstruction(PRINTLN);
|
GroundInstruction gi = groundCreateInstruction(PRINTLN);
|
||||||
@@ -198,6 +215,7 @@ namespace HighGround {
|
|||||||
GroundInstruction gi3 = groundCreateInstruction(CREATELABEL);
|
GroundInstruction gi3 = groundCreateInstruction(CREATELABEL);
|
||||||
groundAddReferenceToInstruction(&gi3, groundCreateReference(LABEL, labelId.data()));
|
groundAddReferenceToInstruction(&gi3, groundCreateReference(LABEL, labelId.data()));
|
||||||
codeBlock.code.push_back(gi3);
|
codeBlock.code.push_back(gi3);
|
||||||
|
codeBlock.code.push_back(groundCreateInstruction(PAUSE));
|
||||||
code.push_back(codeBlock);
|
code.push_back(codeBlock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -295,6 +313,9 @@ namespace HighGround {
|
|||||||
if (in == "+") {
|
if (in == "+") {
|
||||||
return HGNodeType::Add;
|
return HGNodeType::Add;
|
||||||
}
|
}
|
||||||
|
if (in == "==") {
|
||||||
|
return HGNodeType::Equal;
|
||||||
|
}
|
||||||
if (in == "puts") {
|
if (in == "puts") {
|
||||||
return HGNodeType::Puts;
|
return HGNodeType::Puts;
|
||||||
}
|
}
|
||||||
@@ -369,6 +390,20 @@ namespace HighGround {
|
|||||||
rootNode.addNode(addNode);
|
rootNode.addNode(addNode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case HGNodeType::Equal: {
|
||||||
|
HGNode addNode(HGNodeType::Equal);
|
||||||
|
addNode.addNode(rootNode.children.back());
|
||||||
|
rootNode.children.pop_back();
|
||||||
|
auto tokenopt = consume();
|
||||||
|
if (tokenopt) {
|
||||||
|
addNode.addNode(parseOneToken(tokenopt));
|
||||||
|
} else {
|
||||||
|
std::cout << "FEED ME MORE TOKENS\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
rootNode.addNode(addNode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case HGNodeType::Puts: {
|
case HGNodeType::Puts: {
|
||||||
HGNode putsNode(HGNodeType::Puts);
|
HGNode putsNode(HGNodeType::Puts);
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ if true {
|
|||||||
puts "huzzah"
|
puts "huzzah"
|
||||||
}
|
}
|
||||||
|
|
||||||
if false {
|
if 5 == 10 {
|
||||||
puts "aww"
|
puts "aww"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user