void SyntaxTree :: saveNode(Node node, _Memory* dump, bool inclusingNode) { SyntaxTree tree; SyntaxWriter writer(tree); writer.newNode(lxRoot); if (inclusingNode) { if (node.strArgument >= 0) { writer.newNode(node.type, node.identifier()); } else writer.newNode(node.type, node.argument); copyNode(writer, node); writer.closeNode(); } else copyNode(writer, node); writer.closeNode(); tree.save(dump); }
void TreeScriptParser :: parse(_ScriptReader& reader, MemoryDump* output) { MemoryWriter writer(output); writer.writeDWord(0); // HOTFIX : end of tape int sizePos = writer.Position(); writer.writeDWord(0); SyntaxTree tree; SyntaxWriter treeWriter(tree); ScriptBookmark bm = reader.read(); while (!reader.Eof()) { parseStatement(reader, bm, treeWriter); bm = reader.read(); } if (tree.save(output)) { writer.seek(sizePos); writer.writeDWord(output->Length() - sizePos); } else output->clear(); }