Starting to really parse! Fixed the bad syntax trees (reduction copy_construct wasn't actually copying label because param and dest had same name) and fixed the krakenGrammer and CGenerator to allow escaped quotes in regular strings. add_children needs to be finished so the resulting trees don't go nuts with ambiguity, and some situations still cause vector access errors, which is odd. Also added the crazy simple write_file to io and the test_grammer.krak now outputs a syntax_tree.dot
This commit is contained in:
@@ -796,11 +796,14 @@ CCodeTriple CGenerator::generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enc
|
||||
}
|
||||
case value:
|
||||
{
|
||||
// ok, we now check for it being a string and escape all returns if it is (so that multiline strings work)
|
||||
if (data.symbol.getName()[0] == '"') {
|
||||
std::string innerString = strSlice(data.symbol.getName(), 0, 3) == "\"\"\""
|
||||
? strSlice(data.symbol.getName(), 3, -4)
|
||||
: strSlice(data.symbol.getName(), 1, -2);
|
||||
// ok, we now check for it being a multiline string and escape all returns if it is (so that multiline strings work)
|
||||
//if (data.symbol.getName()[0] == '"') {
|
||||
if (data.symbol.getName()[0] == '"' && strSlice(data.symbol.getName(), 0, 3) == "\"\"\"") {
|
||||
//bool multiline_str = strSlice(data.symbol.getName(), 0, 3) == "\"\"\"";
|
||||
//std::string innerString = multiline_str
|
||||
//? strSlice(data.symbol.getName(), 3, -4)
|
||||
//: strSlice(data.symbol.getName(), 1, -2);
|
||||
std::string innerString = strSlice(data.symbol.getName(), 3, -4);
|
||||
std::string newStr;
|
||||
for (auto character: innerString)
|
||||
if (character == '\n')
|
||||
|
||||
Reference in New Issue
Block a user