Proper string parsing

This commit is contained in:
2025-12-20 06:58:41 +11:00
parent e8bf7b70f7
commit a8e5f6a0f1
3 changed files with 23 additions and 2 deletions

View File

@@ -212,7 +212,6 @@ namespace HighGround {
GroundInstruction gi3 = groundCreateInstruction(CREATELABEL);
groundAddReferenceToInstruction(&gi3, groundCreateReference(LABEL, labelId.data()));
codeBlock.code.push_back(gi3);
codeBlock.code.push_back(groundCreateInstruction(PAUSE));
code.push_back(codeBlock);
break;
}
@@ -525,9 +524,29 @@ namespace HighGround {
current = 0;
std::vector<std::string> tokens;
std::string buf;
bool inString = false;
while (auto copt = consume()) {
char c = copt.value();
if (inString) {
buf.push_back(c);
if (c == '"') {
tokens.push_back(buf);
buf.clear();
inString = false;
}
continue;
}
switch (c) {
// double quotes are special
case '"': {
if (!buf.empty()) {
tokens.push_back(buf);
buf.clear();
}
buf.push_back(c);
inString = true;
break;
}
// tokens which are not followed by anything
case '\n':
case '(':

View File

@@ -3,3 +3,5 @@ puts 432
puts 3.141
puts 'c'
puts true
puts "now we have proper string lexing!!!!!11!!@!2!1@1@12!!!112!@"

View File

@@ -1,4 +1,4 @@
if true {
if 1 == 1 {
puts "huzzah"
}