From 484e3065d8a2c5b43733a8b90172fd0669a3faca Mon Sep 17 00:00:00 2001 From: howsohazard <143410553+howsohazard@users.noreply.github.com> Date: Sun, 10 Nov 2024 10:25:38 -0500 Subject: [PATCH] 22121: Improves consistency and handling of data types, especially strings, MAJOR (#302) --- src/Amalgam/AmalgamMain.cpp | 2 +- src/Amalgam/AssetManager.cpp | 33 +- src/Amalgam/AssetManager.h | 13 +- src/Amalgam/GeneralizedDistance.h | 9 +- src/Amalgam/Opcodes.cpp | 21 +- src/Amalgam/Opcodes.h | 19 + src/Amalgam/Parser.cpp | 287 +- src/Amalgam/Parser.h | 49 +- src/Amalgam/amlg_code/full_test.amlg | 28 +- src/Amalgam/amlg_code/test.amlg | 13 +- src/Amalgam/entity/Entity.cpp | 16 +- src/Amalgam/entity/Entity.h | 2 +- src/Amalgam/entity/EntityQueries.cpp | 5 +- src/Amalgam/entity/EntityQueryBuilder.h | 8 +- src/Amalgam/entity/EntityQueryCaches.cpp | 10 +- src/Amalgam/entity/EntityWriteListener.cpp | 2 +- src/Amalgam/evaluablenode/EvaluableNode.cpp | 235 +- src/Amalgam/evaluablenode/EvaluableNode.h | 189 +- .../EvaluableNodeTreeDifference.cpp | 6 +- .../EvaluableNodeTreeFunctions.cpp | 50 +- .../EvaluableNodeTreeFunctions.h | 8 +- src/Amalgam/importexport/FileSupportCSV.cpp | 2 +- src/Amalgam/interpreter/Interpreter.cpp | 16 +- src/Amalgam/interpreter/Interpreter.h | 10 +- .../interpreter/InterpreterDebugger.cpp | 12 +- .../interpreter/InterpreterOpcodesBase.cpp | 35 +- .../InterpreterOpcodesDataTypes.cpp | 28 +- .../InterpreterOpcodesEntityAccess.cpp | 3 +- .../InterpreterOpcodesEntityControl.cpp | 5 +- .../InterpreterOpcodesListManipulation.cpp | 4 +- .../interpreter/InterpreterOpcodesMath.cpp | 2 +- .../InterpreterOpcodesTransformations.cpp | 42 +- src/Amalgam/out.txt | 8309 ++++++++--------- src/Amalgam/string/StringInternPool.h | 2 +- src/Amalgam/string/StringManipulation.cpp | 2 +- src/Amalgam/string/StringManipulation.h | 2 +- 36 files changed, 4797 insertions(+), 4682 deletions(-) diff --git a/src/Amalgam/AmalgamMain.cpp b/src/Amalgam/AmalgamMain.cpp index 44d1ca1a..9bfbb3dd 100644 --- a/src/Amalgam/AmalgamMain.cpp +++ b/src/Amalgam/AmalgamMain.cpp @@ -299,7 +299,7 @@ PLATFORM_MAIN_CONSOLE for(auto &[used_node, _] : nr.nodesReferenced) { std::cerr << "Item:" << std::endl; - std::cerr << Parser::Unparse(used_node, &entity->evaluableNodeManager); + std::cerr << Parser::Unparse(used_node); } } diff --git a/src/Amalgam/AssetManager.cpp b/src/Amalgam/AssetManager.cpp index ca45822e..99a4fa71 100644 --- a/src/Amalgam/AssetManager.cpp +++ b/src/Amalgam/AssetManager.cpp @@ -277,7 +277,7 @@ bool AssetManager::StoreResource(EvaluableNode *code, AssetParameters &asset_par if(!outf.good()) return false; - std::string code_string = Parser::Unparse(code, enm, asset_params.prettyPrint, true, asset_params.sortKeys); + std::string code_string = Parser::Unparse(code, asset_params.prettyPrint, true, asset_params.sortKeys); outf.write(code_string.c_str(), code_string.size()); outf.close(); @@ -297,7 +297,7 @@ bool AssetManager::StoreResource(EvaluableNode *code, AssetParameters &asset_par } else if(asset_params.resourceType == FILE_EXTENSION_COMPRESSED_AMALGAM_CODE) { - std::string code_string = Parser::Unparse(code, enm, asset_params.prettyPrint, true, asset_params.sortKeys); + std::string code_string = Parser::Unparse(code, asset_params.prettyPrint, true, asset_params.sortKeys); //transform into format needed for compression CompactHashMap string_map; @@ -309,7 +309,10 @@ bool AssetManager::StoreResource(EvaluableNode *code, AssetParameters &asset_par } else //binary string { - std::string s = EvaluableNode::ToStringPreservingOpcodeType(code); + if(code == nullptr || code->GetType() != ENT_STRING) + return false; + + const std::string &s = code->GetStringValue(); return StoreFileFromBuffer(asset_params.resource, asset_params.resourceType, s); } @@ -337,6 +340,7 @@ Entity *AssetManager::LoadEntityFromResource(AssetParameters &asset_params, bool } EvaluableNodeReference code = LoadResource(asset_params, &new_entity->evaluableNodeManager, status); + if(!status.loaded) { delete new_entity; @@ -373,25 +377,22 @@ Entity *AssetManager::LoadEntityFromResource(AssetParameters &asset_params, bool if(EvaluableNode::IsAssociativeArray(metadata)) { EvaluableNode **seed = metadata->GetMappedChildNode(GetStringIdFromBuiltInStringId(ENBISI_rand_seed)); - if(seed != nullptr) + if(seed != nullptr && (*seed)->GetType() == ENT_STRING) { - default_random_seed = EvaluableNode::ToStringPreservingOpcodeType(*seed); + default_random_seed = (*seed)->GetStringValue(); new_entity->SetRandomState(default_random_seed, true); } EvaluableNode **version = metadata->GetMappedChildNode(GetStringIdFromBuiltInStringId(ENBISI_version)); - if(version != nullptr) + if(version != nullptr && (*version)->GetType() == ENT_STRING) { - auto [to_str_success, version_str] = EvaluableNode::ToString(*version); - if(to_str_success) + const std::string &version_str = (*version)->GetStringValue(); + auto [error_message, success] = AssetManager::ValidateVersionAgainstAmalgam(version_str); + if(!success) { - auto [error_message, success] = AssetManager::ValidateVersionAgainstAmalgam(version_str); - if(!success) - { - status.SetStatus(false, error_message, version_str); - delete new_entity; - return nullptr; - } + status.SetStatus(false, error_message, version_str); + delete new_entity; + return nullptr; } } } @@ -486,7 +487,7 @@ void AssetManager::SetRootPermission(Entity *entity, bool permission) rootEntities.erase(entity); } -std::pair AssetManager::ValidateVersionAgainstAmalgam(std::string &version) +std::pair AssetManager::ValidateVersionAgainstAmalgam(const std::string &version) { auto sem_ver = StringManipulation::Split(version, '-'); //split on postfix auto version_split = StringManipulation::Split(sem_ver[0], '.'); //ignore postfix diff --git a/src/Amalgam/AssetManager.h b/src/Amalgam/AssetManager.h index b16782c1..0796bed7 100644 --- a/src/Amalgam/AssetManager.h +++ b/src/Amalgam/AssetManager.h @@ -136,8 +136,7 @@ class AssetManager { EvaluableNode *top_entity_code = EntityManipulation::FlattenOnlyTopEntity(&entity->evaluableNodeManager, entity, asset_params.includeRandSeeds, true); - std::string code_string = Parser::Unparse(top_entity_code, &entity->evaluableNodeManager, - asset_params.prettyPrint, true, asset_params.sortKeys, true); + std::string code_string = Parser::Unparse(top_entity_code, asset_params.prettyPrint, true, asset_params.sortKeys, true); entity->evaluableNodeManager.FreeNodeTree(top_entity_code); //loop over contained entities, freeing resources after each entity @@ -147,8 +146,8 @@ class AssetManager EvaluableNode *create_entity_code = EntityManipulation::FlattenOnlyOneContainedEntity( &entity->evaluableNodeManager, cur_entity, entity, asset_params.includeRandSeeds, true); - code_string += Parser::Unparse(create_entity_code, &entity->evaluableNodeManager, - asset_params.prettyPrint, true, asset_params.sortKeys, false, 1); + code_string += Parser::Unparse(create_entity_code, + asset_params.prettyPrint, asset_params.sortKeys, false, 1); entity->evaluableNodeManager.FreeNodeTree(create_entity_code); } @@ -398,7 +397,7 @@ class AssetManager //stores buffer b (of type BufferType of elements BufferElementType) into the filename, returns true if successful, false if not template - static bool StoreFileFromBuffer(const std::string &filename, std::string &file_type, BufferType &b) + static bool StoreFileFromBuffer(const std::string &filename, std::string &file_type, const BufferType &b) { std::ofstream f(filename, std::fstream::binary | std::fstream::out); if(!f.good()) @@ -410,14 +409,14 @@ class AssetManager return false; } - f.write(reinterpret_cast(&b[0]), sizeof(char) * b.size()); + f.write(reinterpret_cast(&b[0]), sizeof(char) * b.size()); return true; } //validates given asset version against Amalgam version //if successful: returns empty string and true //if failure: returns error message and false - static std::pair ValidateVersionAgainstAmalgam(std::string &version); + static std::pair ValidateVersionAgainstAmalgam(const std::string &version); //returns a string representing en's source, empty string if debugSources is false std::string GetEvaluableNodeSourceFromComments(EvaluableNode *en); diff --git a/src/Amalgam/GeneralizedDistance.h b/src/Amalgam/GeneralizedDistance.h index 05fd9520..dcf4fcd7 100644 --- a/src/Amalgam/GeneralizedDistance.h +++ b/src/Amalgam/GeneralizedDistance.h @@ -2,6 +2,7 @@ //project headers: #include "EvaluableNode.h" +#include "EvaluableNodeManagement.h" #include "EvaluableNodeTreeManipulation.h" #include "FastMath.h" @@ -1086,8 +1087,9 @@ class RepeatedGeneralizedDistanceEvaluator : distEvaluator(nullptr) { } - inline RepeatedGeneralizedDistanceEvaluator(GeneralizedDistanceEvaluator *dist_evaluator) - : distEvaluator(dist_evaluator) + inline RepeatedGeneralizedDistanceEvaluator(GeneralizedDistanceEvaluator *dist_evaluator, + EvaluableNodeManager *enm) + : distEvaluator(dist_evaluator), evaluableNodeManager(enm) { } //for the feature index, computes and stores the distance terms for nominal values @@ -1443,4 +1445,7 @@ class RepeatedGeneralizedDistanceEvaluator //for each feature, precomputed distance terms for each interned value looked up by intern index std::vector featureData; + + //node allocations in case unparsing is required + EvaluableNodeManager *evaluableNodeManager; }; diff --git a/src/Amalgam/Opcodes.cpp b/src/Amalgam/Opcodes.cpp index 49355432..043132f8 100644 --- a/src/Amalgam/Opcodes.cpp +++ b/src/Amalgam/Opcodes.cpp @@ -4,7 +4,7 @@ StringInternPool string_intern_pool; -static inline void EmplaceStaticString(EvaluableNodeBuiltInStringId bisid, const char *str) +static inline void EmplaceStaticString(EvaluableNodeBuiltInStringId bisid, std::string str) { auto sid = string_intern_pool.CreateStringReference(str); string_intern_pool.staticStringsIndexToStringID[bisid] = sid; @@ -306,7 +306,26 @@ void StringInternPool::InitializeStaticStrings() EmplaceStaticString(ENBISI_neg_infinity, "-.infinity"); EmplaceStaticString(ENBISI_zero, "0"); EmplaceStaticString(ENBISI_one, "1"); + EmplaceStaticString(ENBISI_two, "2"); + EmplaceStaticString(ENBISI_three, "3"); + EmplaceStaticString(ENBISI_four, "4"); + EmplaceStaticString(ENBISI_five, "5"); + EmplaceStaticString(ENBISI_six, "6"); + EmplaceStaticString(ENBISI_seven, "7"); + EmplaceStaticString(ENBISI_eight, "8"); + EmplaceStaticString(ENBISI_nine, "9"); EmplaceStaticString(ENBISI_neg_one, "-1"); + EmplaceStaticString(ENBISI_zero_number_key, std::string("\0" "0", 2)); + EmplaceStaticString(ENBISI_one_number_key, std::string("\0" "1", 2)); + EmplaceStaticString(ENBISI_two_number_key, std::string("\0" "2", 2)); + EmplaceStaticString(ENBISI_three_number_key, std::string("\0" "3", 2)); + EmplaceStaticString(ENBISI_four_number_key, std::string("\0" "4", 2)); + EmplaceStaticString(ENBISI_five_number_key, std::string("\0" "5", 2)); + EmplaceStaticString(ENBISI_six_number_key, std::string("\0" "6", 2)); + EmplaceStaticString(ENBISI_seven_number_key, std::string("\0" "7", 2)); + EmplaceStaticString(ENBISI_eight_number_key, std::string("\0" "8", 2)); + EmplaceStaticString(ENBISI_nine_number_key, std::string("\0" "9", 2)); + EmplaceStaticString(ENBISI_neg_one_number_key, std::string("\0" "-1", 3)); EmplaceStaticString(ENBISI_empty_null, "(null)"); EmplaceStaticString(ENBISI_empty_list, "(list)"); EmplaceStaticString(ENBISI_empty_assoc, "(assoc)"); diff --git a/src/Amalgam/Opcodes.h b/src/Amalgam/Opcodes.h index 0a7344d2..37a19dfd 100644 --- a/src/Amalgam/Opcodes.h +++ b/src/Amalgam/Opcodes.h @@ -521,7 +521,26 @@ enum EvaluableNodeBuiltInStringId ENBISI_neg_infinity, ENBISI_zero, ENBISI_one, + ENBISI_two, + ENBISI_three, + ENBISI_four, + ENBISI_five, + ENBISI_six, + ENBISI_seven, + ENBISI_eight, + ENBISI_nine, ENBISI_neg_one, + ENBISI_zero_number_key, + ENBISI_one_number_key, + ENBISI_two_number_key, + ENBISI_three_number_key, + ENBISI_four_number_key, + ENBISI_five_number_key, + ENBISI_six_number_key, + ENBISI_seven_number_key, + ENBISI_eight_number_key, + ENBISI_nine_number_key, + ENBISI_neg_one_number_key, ENBISI_empty_null, ENBISI_empty_list, ENBISI_empty_assoc, diff --git a/src/Amalgam/Parser.cpp b/src/Amalgam/Parser.cpp index e69c4b5c..663cddc4 100644 --- a/src/Amalgam/Parser.cpp +++ b/src/Amalgam/Parser.cpp @@ -16,7 +16,6 @@ Parser::Parser() lineStartPos = 0; numOpenParenthesis = 0; originalSource = ""; - topNode = nullptr; charOffsetStartOfLastCompletedCode = std::numeric_limits::max(); } @@ -45,7 +44,6 @@ Parser::Parser(std::string_view code_string, EvaluableNodeManager *enm, } debugSources = debug_sources; - topNode = nullptr; evaluableNodeManager = enm; transactionalParse = transactional_parse; charOffsetStartOfLastCompletedCode = std::numeric_limits::max(); @@ -97,11 +95,11 @@ std::tuple, size_t> { Parser pt(code_string, enm, transactional_parse, original_source, debug_sources); - pt.ParseCode(); + EvaluableNode *top_node = pt.ParseCode(); - pt.PreevaluateNodes(); + pt.PreevaluateNodes(top_node); - return std::make_tuple(EvaluableNodeReference(pt.topNode, true), + return std::make_tuple(EvaluableNodeReference(top_node, true), std::move(pt.warnings), pt.charOffsetStartOfLastCompletedCode); } @@ -117,25 +115,23 @@ std::tuple, size_t> Parser::Par std::tuple, size_t> Parser::ParseNextTransactionalBlock() { - topNode = nullptr; preevaluationNodes.clear(); parentNodes.clear(); - ParseCode(); + EvaluableNode *top_node = ParseCode(); - PreevaluateNodes(); + PreevaluateNodes(top_node); - return std::make_tuple(EvaluableNodeReference(topNode, true), + return std::make_tuple(EvaluableNodeReference(top_node, true), std::move(warnings), charOffsetStartOfLastCompletedCode); } -std::string Parser::Unparse(EvaluableNode *tree, EvaluableNodeManager *enm, +std::string Parser::Unparse(EvaluableNode *tree, bool expanded_whitespace, bool emit_attributes, bool sort_keys, bool first_of_transactional_unparse, size_t starting_indendation) { UnparseData upd; - upd.enm = enm; upd.topNodeIfTransactionUnparsing = (first_of_transactional_unparse ? tree : nullptr); //if the top node needs cycle checks, then need to check all nodes in case there are // multiple ways to get to one @@ -147,8 +143,52 @@ std::string Parser::Unparse(EvaluableNode *tree, EvaluableNodeManager *enm, return upd.result; } +EvaluableNodeReference Parser::ParseFromKeyString(const std::string &code_string, EvaluableNodeManager *enm) +{ + if(code_string.size() == 0 || code_string[0] != '\0') + return EvaluableNodeReference(enm->AllocNode(ENT_STRING, code_string), true); + + std::string_view escaped_string(&code_string[1], code_string.size() - 1); + auto [node, warnings, char_with_error] = Parser::Parse(escaped_string, enm); + return node; +} + +EvaluableNodeReference Parser::ParseFromKeyStringId(StringInternPool::StringID code_string_id, + EvaluableNodeManager *enm) +{ + if(code_string_id == string_intern_pool.NOT_A_STRING_ID) + return EvaluableNodeReference::Null(); + + std::string &code_string = code_string_id->string; + if(code_string.size() == 0 || code_string[0] != '\0') + return EvaluableNodeReference(enm->AllocNode(ENT_STRING, code_string_id), true); + + std::string_view escaped_string(&code_string[1], code_string.size() - 1); + auto [node, warnings, char_with_error] = Parser::Parse(escaped_string, enm); + return node; +} + +std::string Parser::UnparseToKeyString(EvaluableNode *tree) +{ + //if just a regular string, return it + if(tree != nullptr && (tree->GetType() == ENT_STRING || tree->GetType() == ENT_SYMBOL)) + { + const auto &string_value = tree->GetStringValue(); + if(string_value.size() > 0 && string_value[0] != '\0') + return string_value; + } + + std::string unparsed = Parser::Unparse(tree, false, false, true); + + //need to insert a \0 this way, otherwise certain string methods will skip the null terminator + std::string str; + str.assign(1, '\0'); + str.insert(1, unparsed.data(), unparsed.size()); + return str; +} + EvaluableNode *Parser::GetCodeForPathToSharedNodeFromParentAToParentB(UnparseData &upd, - EvaluableNode *shared_node, EvaluableNode *a_parent, EvaluableNode *b_parent) + EvaluableNodeManager &enm, EvaluableNode *shared_node, EvaluableNode *a_parent, EvaluableNode *b_parent) { if(shared_node == nullptr || a_parent == nullptr || b_parent == nullptr) return nullptr; @@ -217,14 +257,14 @@ EvaluableNode *Parser::GetCodeForPathToSharedNodeFromParentAToParentB(UnparseDat } } - b_path_nodes.insert(begin(b_path_nodes), upd.enm->AllocNode(ENT_STRING, key_id)); + b_path_nodes.insert(begin(b_path_nodes), ParseFromKeyStringId(key_id, &enm)); } else if(b_parent->IsOrderedArray()) { auto &bp_ocn = b_parent->GetOrderedChildNodesReference(); const auto &found = std::find(begin(bp_ocn), end(bp_ocn), b); auto index = std::distance(begin(bp_ocn), found); - b_path_nodes.insert(begin(b_path_nodes), upd.enm->AllocNode(static_cast(index))); + b_path_nodes.insert(begin(b_path_nodes), enm.AllocNode(static_cast(index))); } else //didn't work... odd/error condition { @@ -236,9 +276,9 @@ EvaluableNode *Parser::GetCodeForPathToSharedNodeFromParentAToParentB(UnparseDat } //build code to get the reference - EvaluableNode *target = upd.enm->AllocNode(ENT_TARGET); + EvaluableNode *target = enm.AllocNode(ENT_TARGET); //need to include the get (below) in the depth, so add 1 - target->AppendOrderedChildNode(upd.enm->AllocNode(static_cast(a_ancestor_depth + 1))); + target->AppendOrderedChildNode(enm.AllocNode(static_cast(a_ancestor_depth + 1))); EvaluableNode *indices = nullptr; if(b_path_nodes.size() == 0) @@ -246,9 +286,9 @@ EvaluableNode *Parser::GetCodeForPathToSharedNodeFromParentAToParentB(UnparseDat else if(b_path_nodes.size() == 1) indices = b_path_nodes[0]; else - indices = upd.enm->AllocNode(b_path_nodes, false, true); + indices = enm.AllocNode(b_path_nodes, false, true); - EvaluableNode *get = upd.enm->AllocNode(ENT_GET); + EvaluableNode *get = enm.AllocNode(ENT_GET); get->AppendOrderedChildNode(target); get->AppendOrderedChildNode(indices); @@ -453,22 +493,9 @@ std::string Parser::GetNextIdentifier(bool allow_leading_label_marks) } } -EvaluableNode *Parser::GetNextToken(EvaluableNode *parent_node, EvaluableNode *reuse_assoc_token_as_value) +EvaluableNode *Parser::GetNextToken(EvaluableNode *parent_node, bool parsing_assoc_key) { - EvaluableNode *new_token = nullptr; - bool parsing_assoc_key = false; - - if(reuse_assoc_token_as_value == nullptr) - { - new_token = evaluableNodeManager->AllocNode(ENT_NULL); - //if parsing an assoc but haven't been passed a value to reuse, it's a key - if(parent_node != nullptr && parent_node->IsAssociativeArray()) - parsing_assoc_key = true; - } - else - { - new_token = reuse_assoc_token_as_value; - } + EvaluableNode *new_token = evaluableNodeManager->AllocNode(ENT_NULL); SkipWhitespaceAndAccumulateAttributes(new_token); if(pos >= code.size()) @@ -536,7 +563,7 @@ EvaluableNode *Parser::GetNextToken(EvaluableNode *parent_node, EvaluableNode *r } else if(cur_char == '}') { - if(parent_node_type != ENT_ASSOC) + if(parent_node_type != ENT_ASSOC && !parsing_assoc_key) EmitWarning("Mismatched }"); } @@ -545,8 +572,7 @@ EvaluableNode *Parser::GetNextToken(EvaluableNode *parent_node, EvaluableNode *r FreeNode(new_token); return nullptr; } - else if(!parsing_assoc_key - && (StringManipulation::IsUtf8ArabicNumerals(cur_char) || cur_char == '-' || cur_char == '.')) + else if(StringManipulation::IsUtf8ArabicNumerals(cur_char) || cur_char == '-' || cur_char == '.') { size_t start_pos = pos; SkipToEndOfIdentifier(); @@ -590,8 +616,9 @@ void Parser::FreeNode(EvaluableNode *node) preevaluationNodes.pop_back(); } -void Parser::ParseCode() +EvaluableNode *Parser::ParseCode(bool parsing_assoc_key) { + EvaluableNode *top_node = nullptr; EvaluableNode *cur_node = nullptr; //as long as code left @@ -599,10 +626,44 @@ void Parser::ParseCode() { //if at the top level node and starting to parse a new structure, //then all previous ones have completed and can mark this new position as a successful start - if(topNode != nullptr && cur_node == topNode) + if(top_node != nullptr && cur_node == top_node) charOffsetStartOfLastCompletedCode = pos; - EvaluableNode *n = GetNextToken(cur_node); + EvaluableNode *key_node = nullptr; + if(cur_node != nullptr && cur_node->IsAssociativeArray()) + { + key_node = ParseCode(true); + //if end of assoc + if(key_node == nullptr) + { + //nothing here at all + if(cur_node == nullptr) + break; + + const auto &parent = parentNodes.find(cur_node); + + //if no parent, then all finished + if(parent == end(parentNodes) || parent->second == nullptr) + break; + + //jump up to the parent node + cur_node = parent->second; + continue; + } + } + + EvaluableNode *n = GetNextToken(cur_node, parsing_assoc_key); + //early-out if already have key + if(parsing_assoc_key) + { + //already have completed the expression + if(n == nullptr) + return top_node; + + //if it's a singular value + if(cur_node == nullptr && n->IsImmediate()) + return n; + } //if end of a list if(n == nullptr) @@ -611,6 +672,23 @@ void Parser::ParseCode() if(cur_node == nullptr) break; + //if key_node should be added to an associative array, but the node is nullptr, just add it + if(key_node != nullptr && cur_node->IsAssociativeArray()) + { + if((key_node->GetType() == ENT_STRING || key_node->GetType() == ENT_SYMBOL) + && !DoesStringNeedUnparsingToKey(key_node->GetStringValue())) + { + StringInternPool::StringID index_sid + = EvaluableNode::ToStringIDTakingReferenceAndClearing(key_node, true); + cur_node->SetMappedChildNodeWithReferenceHandoff(index_sid, nullptr, true); + } + else + { + std::string s = Parser::UnparseToKeyString(key_node); + cur_node->SetMappedChildNode(s, nullptr, true); + } + } + const auto &parent = parentNodes.find(cur_node); //if no parent, then all finished @@ -624,9 +702,9 @@ void Parser::ParseCode() else //got some token { //if it's the first token, then put it up top - if(topNode == nullptr) + if(top_node == nullptr) { - topNode = n; + top_node = n; cur_node = n; continue; } @@ -637,53 +715,41 @@ void Parser::ParseCode() } else if(cur_node->IsAssociativeArray()) { - //if it's not an immediate value, then need to retrieve closing parenthesis - if(!IsEvaluableNodeTypeImmediate(n->GetType())) + //transfer any attributes from key_node to n + if(key_node != nullptr) { - SkipWhitespaceAndAccumulateAttributes(n); - if(pos <= code.size()) + if(key_node->HasComments()) { - auto cur_char = code[pos]; - if(cur_char == ')') - { - pos++; - numOpenParenthesis--; - } - else - { - EmitWarning("Missing )"); - } + std::string appended = key_node->GetCommentsString() + "\r\n" + n->GetCommentsString(); + n->SetComments(appended); + key_node->ClearComments(); } - else //no more code + + size_t num_key_node_labels = key_node->GetNumLabels(); + if(num_key_node_labels > 0) { - break; + for(size_t i = 0; i < num_key_node_labels; i++) + n->AppendLabelStringId(key_node->GetLabelStringId(i)); + key_node->ClearLabels(); } } - //n is the id, so need to get the next token - StringInternPool::StringID index_sid = EvaluableNode::ToStringIDTakingReferenceAndClearing(n); - - //reset the node type but continue to accumulate any attributes - n->SetType(ENT_NULL, evaluableNodeManager, false); - n = GetNextToken(cur_node, n); - cur_node->SetMappedChildNodeWithReferenceHandoff(index_sid, n, true); - - //handle case if uneven number of arguments - if(n == nullptr) + if(EvaluableNode::IsNull(key_node) + || ((key_node->GetType() == ENT_STRING || key_node->GetType() == ENT_SYMBOL) + && !DoesStringNeedUnparsingToKey(key_node->GetStringValue()))) { - //nothing here at all - if(cur_node == nullptr) - break; - - const auto &parent = parentNodes.find(cur_node); + StringInternPool::StringID index_sid + = EvaluableNode::ToStringIDTakingReferenceAndClearing(key_node, true); - //if no parent, then all finished - if(parent == end(parentNodes) || parent->second == nullptr) - break; + //reset the node type but continue to accumulate any attributes + cur_node->SetMappedChildNodeWithReferenceHandoff(index_sid, n, true); + } + else //need to unparse to key + { + std::string s = Parser::UnparseToKeyString(key_node); + //don't free the node to make sure it doesn't get picked up as an incorrect node in parent tree - //jump up to the parent node - cur_node = parent->second; - continue; + cur_node->SetMappedChildNode(s, n, true); } } @@ -701,7 +767,7 @@ void Parser::ParseCode() } } - if(transactionalParse && warnings.size() > 0 && cur_node == topNode) + if(transactionalParse && warnings.size() > 0 && cur_node == top_node) break; } @@ -713,24 +779,29 @@ void Parser::ParseCode() //if anything went wrong with the last transaction, remove it if(warnings.size() > 0 || numOpenParenthesis > 1) { - if(EvaluableNode::IsOrderedArray(topNode)) + if(EvaluableNode::IsOrderedArray(top_node)) { - auto &top_node_ocn = topNode->GetOrderedChildNodesReference(); + auto &top_node_ocn = top_node->GetOrderedChildNodesReference(); top_node_ocn.pop_back(); } else //nothing came through correctly { - topNode = nullptr; + top_node = nullptr; } } } - if(numOpenParenthesis > num_allowed_open_parens) - EmitWarning(StringManipulation::NumberToString( - static_cast(numOpenParenthesis - num_allowed_open_parens)) + " missing closing parenthesis"); - else if(numOpenParenthesis < 0) - EmitWarning(StringManipulation::NumberToString(static_cast(-numOpenParenthesis)) - + " extra closing parenthesis"); + if(!parsing_assoc_key) + { + if(numOpenParenthesis > num_allowed_open_parens) + EmitWarning(StringManipulation::NumberToString( + static_cast(numOpenParenthesis - num_allowed_open_parens)) + " missing closing parenthesis"); + else if(numOpenParenthesis < 0) + EmitWarning(StringManipulation::NumberToString(static_cast(-numOpenParenthesis)) + + " extra closing parenthesis"); + } + + return top_node; } void Parser::AppendComments(EvaluableNode *n, size_t indentation_depth, bool pretty, std::string &to_append) @@ -864,16 +935,25 @@ void Parser::AppendAssocKeyValuePair(UnparseData &upd, StringInternPool::StringI { auto &key_str = string_intern_pool.GetStringFromID(key_sid); - //surround in quotes only if needed - if(HasCharactersBeyondIdentifier(key_str)) + if(!Parser::DoesStringNeedUnparsingToKey(key_str)) { - upd.result.push_back('"'); - upd.result.append(Backslashify(key_str)); - upd.result.push_back('"'); + //surround in quotes only if needed + if(HasCharactersBeyondIdentifier(key_str)) + { + upd.result.push_back('"'); + upd.result.append(Backslashify(key_str)); + upd.result.push_back('"'); + } + else + { + upd.result.append(key_str); + } } - else + else //raw code { - upd.result.append(key_str); + //skip the 0 character at the beginning + std::string_view code_string(key_str.data() + 1, key_str.size() - 1); + upd.result.append(code_string); } } @@ -897,14 +977,15 @@ void Parser::Unparse(UnparseData &upd, EvaluableNode *tree, EvaluableNode *paren { upd.preevaluationNeeded = true; + EvaluableNodeManager enm; EvaluableNode *code_to_print = GetCodeForPathToSharedNodeFromParentAToParentB(upd, - tree, parent, dest_node_with_parent->second); + enm, tree, parent, dest_node_with_parent->second); //unparse the path using a new set of parentNodes as to not pollute the one currently being unparsed EvaluableNode::ReferenceAssocType references; std::swap(upd.parentNodes, references); Unparse(upd, code_to_print, nullptr, expanded_whitespace, indentation_depth, need_initial_indent); std::swap(upd.parentNodes, references); //put the old parentNodes back - upd.enm->FreeNodeTree(code_to_print); + enm.FreeNodeTree(code_to_print); return; } @@ -946,7 +1027,7 @@ void Parser::Unparse(UnparseData &upd, EvaluableNode *tree, EvaluableNode *paren switch(tree_type) { case ENT_NUMBER: - upd.result.append(EvaluableNode::ToStringPreservingOpcodeType(tree)); + upd.result.append(StringManipulation::NumberToString(tree->GetNumberValueReference())); break; case ENT_STRING: { @@ -1140,7 +1221,7 @@ static EvaluableNode *GetNodeRelativeToIndex(EvaluableNode *node, EvaluableNode //if it's an assoc, then treat the index as a string if(node->IsAssociativeArray()) { - StringInternPool::StringID index_sid = EvaluableNode::ToStringIDIfExists(index_node); + StringInternPool::StringID index_sid = EvaluableNode::ToStringIDIfExists(index_node, true); EvaluableNode **found = node->GetMappedChildNode(index_sid); if(found != nullptr) return *found; @@ -1236,7 +1317,7 @@ EvaluableNode *Parser::GetNodeFromRelativeCodePath(EvaluableNode *path) return nullptr; } -void Parser::PreevaluateNodes() +void Parser::PreevaluateNodes(EvaluableNode *top_node) { //only need to update flags if any nodes actually change bool any_nodes_changed = false; @@ -1286,11 +1367,11 @@ void Parser::PreevaluateNodes() if(any_nodes_changed) { - EvaluableNodeManager::UpdateFlagsForNodeTree(topNode); + EvaluableNodeManager::UpdateFlagsForNodeTree(top_node); } else { - if(topNode != nullptr) - EvaluableNodeManager::UpdateIdempotencyFlagsForNonCyclicNodeTree(topNode); + if(top_node != nullptr) + EvaluableNodeManager::UpdateIdempotencyFlagsForNonCyclicNodeTree(top_node); } } diff --git a/src/Amalgam/Parser.h b/src/Amalgam/Parser.h index fbfd6389..0053cc0d 100644 --- a/src/Amalgam/Parser.h +++ b/src/Amalgam/Parser.h @@ -132,10 +132,41 @@ class Parser // if sort_keys, then it will perform a sort on all unordered nodes // if first_of_transactional_unparse, it will not emit the final closing parenthesis or appropriate other character // starting_indentation indicates where it will start, in case there was other code prior to which it is being concatenated - static std::string Unparse(EvaluableNode *tree, EvaluableNodeManager *enm, + static std::string Unparse(EvaluableNode *tree, bool expanded_whitespace = true, bool emit_attributes = true, bool sort_keys = false, bool first_of_transactional_unparse = false, size_t starting_indendation = 0); + //transforms the code_string into evaluable nodes + static EvaluableNodeReference ParseFromKeyString(const std::string &code_string, EvaluableNodeManager *enm); + + //transforms the code_string_id into evaluable nodes + static EvaluableNodeReference ParseFromKeyStringId(StringInternPool::StringID code_string_id, EvaluableNodeManager *enm); + + //transforms tree into a string value that will match if the evaluable node trees match + static std::string UnparseToKeyString(EvaluableNode *tree); + + //like UnparseToKeyString, but for numbers only + template + static inline std::string UnparseNumberToKeyString(NumberType number) + { + std::string unparsed = StringManipulation::NumberToString(number); + + //need to insert a \0 this way, otherwise certain string methods will skip the null terminator + std::string str; + str.assign(1, '\0'); + str.insert(1, unparsed.data(), unparsed.size()); + return str; + } + + //returns true if string needs to be run through UnparseStringToKeyString + static inline bool DoesStringNeedUnparsingToKey(const std::string &s) + { + if(s.size() == 0 || s[0] != '\0') + return false; + + return true; + } + //string to be appended after Unparse calls when the first one is called with first_of_transactional_unparse inline static const std::string transactionTermination = ")"; @@ -154,8 +185,6 @@ class Parser //parentNodes contains each reference as the key and the parent as the value EvaluableNode::ReferenceAssocType parentNodes; - EvaluableNodeManager *enm; - //if transactional unparsing, then this will be the top node //if not, it will be nullptr EvaluableNode *topNodeIfTransactionUnparsing; @@ -175,7 +204,7 @@ class Parser //Returns code that will get from location a to b. static EvaluableNode *GetCodeForPathToSharedNodeFromParentAToParentB(UnparseData &upd, - EvaluableNode *shared_node, EvaluableNode *a_parent, EvaluableNode *b_parent); + EvaluableNodeManager &enm, EvaluableNode *shared_node, EvaluableNode *a_parent, EvaluableNode *b_parent); //Skips whitespace and accumulates any attributes (e.g., labels, comments) on to target void SkipWhitespaceAndAccumulateAttributes(EvaluableNode *target); @@ -193,14 +222,13 @@ class Parser //Returns a EvaluableNode containing the next token, null if none left in current context // parent_node is primarily to check for errors or warnings - //if reuse_assoc_token_as_value is not nullptr, it will put the token in the EvaluableNode provided, otherwise will return a new one - EvaluableNode *GetNextToken(EvaluableNode *parent_node, EvaluableNode *reuse_assoc_token_as_value = nullptr); + EvaluableNode *GetNextToken(EvaluableNode *parent_node, bool parsing_assoc_key = false); //deallocates the current node in case there is an early exit or error void FreeNode(EvaluableNode *node); - //Parses the next block of code into topNode - void ParseCode(); + //Parses the next block of code and returns the top node + EvaluableNode *ParseCode(bool parsing_assoc_key = false); //Prints out all comments for the respective node static void AppendComments(EvaluableNode *n, size_t indentation_depth, bool pretty, std::string &to_append); @@ -249,7 +277,7 @@ class Parser EvaluableNode *GetNodeFromRelativeCodePath(EvaluableNode *path); //resolves any nodes that require preevaluation (such as assocs or circular references) - void PreevaluateNodes(); + void PreevaluateNodes(EvaluableNode *top_node); //string of the code currently being parsed std::string_view code; @@ -272,9 +300,6 @@ class Parser //if true, will prepend debug sources to node comments bool debugSources; - //the top node of everything being parsed - EvaluableNode *topNode; - //contains a list of nodes that need to be preevaluated on parsing std::vector preevaluationNodes; diff --git a/src/Amalgam/amlg_code/full_test.amlg b/src/Amalgam/amlg_code/full_test.amlg index 60900fed..f12d6cd7 100644 --- a/src/Amalgam/amlg_code/full_test.amlg +++ b/src/Amalgam/amlg_code/full_test.amlg @@ -399,7 +399,7 @@ (print (dot_product (list 0.5 0.25 0.25) (list 4 8 8)) "\n") (print (dot_product (associate "a" 0.5 "b" 0.25 "c" 0.25) (associate "a" 4 "b" 8 "c" 8)) "\n") - (print (dot_product (associate "0" 0.5 "1" 0.25 "2" 0.25) (list 4 8 8)) "\n") + (print (dot_product (associate 0 0.5 1 0.25 2 0.25) (list 4 8 8)) "\n") (print "--generalized_distance--\n") (print " 0 " (generalized_distance (null) (null) (null) (null) 0.01 (map 10000 (range 0 200)) ) "\n") @@ -783,8 +783,8 @@ (lambda (+ (get (current_value) 0) (get (current_value) 1) (get (current_value) 2)) ) - (associate "0" 0 "1" 1 "a" 3) - (associate "0" 1 "a" 4) + (associate 0 0 1 1 "a" 3) + (associate 0 1 "a" 4) (list 2 2 2 2) )) @@ -918,6 +918,11 @@ (print (indices (associate "a" 1 "b" 2 "c" 3 4 "d"))) (print (indices (list "a" 1 "b" 2 "c" 3 4 "d"))) + ;these should all print lists of numbers + (print (indices (range 0 3))) + (print (indices (zip (range 0 3)))) + (print (indices (zip (list 0 1 2 3)))) + (print "--values--\n") (print (values (associate "a" 1 "b" 2 "c" 3 4 "d"))) (print (values (list "a" 1 "b" 2 "c" 3 4 "d"))) @@ -1007,6 +1012,23 @@ (print (get (assoc (null) 3) (null)) "\n") + (let { + complex_assoc { + "4" "string" + 4 "number" + [4] "list" + {4 4} "assoc" + } + } + + (print (get complex_assoc 4) "\n") + (print (get complex_assoc "4") "\n") + ;need to surround with list to not confuse with traversal path + (print (get complex_assoc [[4]]) "\n") + (print (get complex_assoc {4 4}) "\n") + (print (indices complex_assoc)) + ) + (print "--set--\n") (print (set (associate "a" 1 "b" 2 "c" 3 4 "d") "e" 5)) (print (set (list 0 1 2 3 4) 2 10)) diff --git a/src/Amalgam/amlg_code/test.amlg b/src/Amalgam/amlg_code/test.amlg index 065c2750..9d2696b3 100644 --- a/src/Amalgam/amlg_code/test.amlg +++ b/src/Amalgam/amlg_code/test.amlg @@ -1,11 +1,6 @@ (seq - (print (parse - "(seq (+ 1 2) (+ (+ 3 4) 5))" - )) - - (print (parse - "(seq (+ 1 2) (+ (3 4) 5)" - )) - - + (print {"Can't continue terminated series."}) + ;(declare {warnings {}}) + ;(accum (assoc warnings (assoc "Can't continue terminated series.") )) + ;(print warnings) ) \ No newline at end of file diff --git a/src/Amalgam/entity/Entity.cpp b/src/Amalgam/entity/Entity.cpp index b272738e..558df5dd 100644 --- a/src/Amalgam/entity/Entity.cpp +++ b/src/Amalgam/entity/Entity.cpp @@ -222,7 +222,7 @@ bool Entity::GetValueAtLabelAsString(StringInternPool::StringID label_sid, std:: return false; } - value_out = Parser::Unparse(label->second, &evaluableNodeManager, false, false); + value_out = Parser::Unparse(label->second, false, false, true); return true; } @@ -894,7 +894,7 @@ void Entity::SetRoot(EvaluableNode *_code, bool allocated_with_entity_enm, Evalu { if(write_listeners->size() > 0) { - std::string new_code_string = Parser::Unparse(evaluableNodeManager.GetRootNode(), &evaluableNodeManager); + std::string new_code_string = Parser::Unparse(evaluableNodeManager.GetRootNode(), false, true); for(auto &wl : *write_listeners) wl->LogWriteToEntity(this, new_code_string); @@ -950,18 +950,14 @@ void Entity::AccumRoot(EvaluableNodeReference accum_code, bool allocated_with_en if(new_root != previous_root) evaluableNodeManager.SetRootNode(new_root); - //optimistically create references for the new labels, delete them if find collisions - string_intern_pool.CreateStringReferences(new_labels, [](auto l) { return l.first; }); - //attempt to insert the new labels as long as there's no collision for(auto &[label, value] : new_labels) { auto [new_entry, inserted] = labelIndex.emplace(label, value); - if(!inserted) - { - string_intern_pool.DestroyStringReference(label); + if(inserted) + string_intern_pool.CreateStringReference(label); + else no_label_collisions = false; - } } EntityQueryCaches *container_caches = GetContainerQueryCaches(); @@ -999,7 +995,7 @@ void Entity::AccumRoot(EvaluableNodeReference accum_code, bool allocated_with_en { if(write_listeners->size() > 0) { - std::string new_code_string = Parser::Unparse(new_root, &evaluableNodeManager); + std::string new_code_string = Parser::Unparse(new_root, false, true); for(auto &wl : *write_listeners) wl->LogWriteToEntity(this, new_code_string); diff --git a/src/Amalgam/entity/Entity.h b/src/Amalgam/entity/Entity.h index 5d7506e8..28abd60e 100644 --- a/src/Amalgam/entity/Entity.h +++ b/src/Amalgam/entity/Entity.h @@ -259,7 +259,7 @@ class Entity //Returns the code for the Entity in string form inline std::string GetCodeAsString() { - return Parser::Unparse(evaluableNodeManager.GetRootNode(), &evaluableNodeManager); + return Parser::Unparse(evaluableNodeManager.GetRootNode()); } //Returns the root of the entity diff --git a/src/Amalgam/entity/EntityQueries.cpp b/src/Amalgam/entity/EntityQueries.cpp index 404e3053..978218c8 100644 --- a/src/Amalgam/entity/EntityQueries.cpp +++ b/src/Amalgam/entity/EntityQueries.cpp @@ -462,9 +462,8 @@ EvaluableNodeReference EntityQueryCondition::GetMatchingEntities(Entity *contain //get values auto &exist_labels = existLabels; - string_intern_pool.CreateStringReferences(exist_labels); for(auto label_sid : exist_labels) - entity_values->SetMappedChildNodeWithReferenceHandoff(label_sid, matching_entities[i]->GetValueAtLabel(label_sid, enm, false)); + entity_values->SetMappedChildNode(label_sid, matching_entities[i]->GetValueAtLabel(label_sid, enm, false)); } return EvaluableNodeReference(query_return, true); @@ -646,7 +645,7 @@ EvaluableNodeReference EntityQueryCondition::GetMatchingEntities(Entity *contain std::string string_value; for(auto &[value, weight] : value_weights) { - string_value = EvaluableNode::NumberToString(value); + string_value = EvaluableNode::NumberToString(value, true); assoc->SetMappedChildNode(string_value, enm->AllocNode(weight)); } diff --git a/src/Amalgam/entity/EntityQueryBuilder.h b/src/Amalgam/entity/EntityQueryBuilder.h index 745eda40..023b9fee 100644 --- a/src/Amalgam/entity/EntityQueryBuilder.h +++ b/src/Amalgam/entity/EntityQueryBuilder.h @@ -470,7 +470,7 @@ namespace EntityQueryBuilder //set random seed cur_condition->hasRandomStream = (ocn.size() > RANDOM_SEED && !EvaluableNode::IsNull(ocn[RANDOM_SEED])); if(cur_condition->hasRandomStream) - cur_condition->randomStream.SetState(EvaluableNode::ToStringPreservingOpcodeType(ocn[RANDOM_SEED])); + cur_condition->randomStream.SetState(EvaluableNode::ToString(ocn[RANDOM_SEED])); else cur_condition->randomStream = rs.CreateOtherStreamViaRand(); @@ -667,7 +667,7 @@ namespace EntityQueryBuilder cur_condition->hasRandomStream = (ocn.size() >= 3 && !EvaluableNode::IsNull(ocn[2])); if(cur_condition->hasRandomStream) - cur_condition->randomStream.SetState(EvaluableNode::ToStringPreservingOpcodeType(ocn[2])); + cur_condition->randomStream.SetState(EvaluableNode::ToString(ocn[2])); else cur_condition->randomStream = rs.CreateOtherStreamViaRand(); @@ -678,7 +678,7 @@ namespace EntityQueryBuilder cur_condition->maxToRetrieve = (ocn.size() > 0) ? EvaluableNode::ToNumber(ocn[0], 0.0) : 1; cur_condition->hasRandomStream = (ocn.size() > 1 && !EvaluableNode::IsNull(ocn[1])); if(cur_condition->hasRandomStream) - cur_condition->randomStream.SetState(EvaluableNode::ToStringPreservingOpcodeType(ocn[1])); + cur_condition->randomStream.SetState(EvaluableNode::ToString(ocn[1])); else cur_condition->randomStream = rs.CreateOtherStreamViaRand(); break; @@ -689,7 +689,7 @@ namespace EntityQueryBuilder cur_condition->maxToRetrieve = (ocn.size() > 1) ? EvaluableNode::ToNumber(ocn[1], 0.0) : 1; cur_condition->hasRandomStream = (ocn.size() > 2 && !EvaluableNode::IsNull(ocn[2])); if(cur_condition->hasRandomStream) - cur_condition->randomStream.SetState(EvaluableNode::ToStringPreservingOpcodeType(ocn[2])); + cur_condition->randomStream.SetState(EvaluableNode::ToString(ocn[2])); else cur_condition->randomStream = rs.CreateOtherStreamViaRand(); break; diff --git a/src/Amalgam/entity/EntityQueryCaches.cpp b/src/Amalgam/entity/EntityQueryCaches.cpp index d1293290..95434c46 100644 --- a/src/Amalgam/entity/EntityQueryCaches.cpp +++ b/src/Amalgam/entity/EntityQueryCaches.cpp @@ -1084,7 +1084,7 @@ EvaluableNodeReference EntityQueryCaches::GetMatchingEntitiesFromQueryCaches(Ent std::string string_value; for(auto &[value, weight] : value_weights) { - string_value = EvaluableNode::NumberToString(value); + string_value = EvaluableNode::NumberToString(value, true); assoc->SetMappedChildNode(string_value, enm->AllocNode(weight)); } @@ -1278,10 +1278,6 @@ EvaluableNodeReference EntityQueryCaches::GetMatchingEntitiesFromQueryCaches(Ent EvaluableNode *query_return = enm->AllocNode(ENT_ASSOC); query_return->ReserveMappedChildNodes(matching_ents.size()); - //create a string reference for each entity - string_intern_pool.CreateStringReferences(matching_ents, - [&contained_entities](auto entity_index) { return contained_entities[entity_index]->GetIdStringId(); }); - auto &exist_labels = last_query->existLabels; if(exist_labels.size() > 0) @@ -1294,7 +1290,7 @@ EvaluableNodeReference EntityQueryCaches::GetMatchingEntitiesFromQueryCaches(Ent //create assoc for values for each entity EvaluableNode *entity_values = enm->AllocNode(ENT_ASSOC); entity_values->ReserveMappedChildNodes(exist_labels.size()); - query_return->SetMappedChildNodeWithReferenceHandoff(contained_entities[entity_index]->GetIdStringId(), entity_values); + query_return->SetMappedChildNode(contained_entities[entity_index]->GetIdStringId(), entity_values); //get values for(auto &label_sid : exist_labels) @@ -1305,7 +1301,7 @@ EvaluableNodeReference EntityQueryCaches::GetMatchingEntitiesFromQueryCaches(Ent { //create a null for every entry, since nothing requested for(const auto &entity_index : matching_ents) - query_return->SetMappedChildNodeWithReferenceHandoff(contained_entities[entity_index]->GetIdStringId(), nullptr); + query_return->SetMappedChildNode(contained_entities[entity_index]->GetIdStringId(), nullptr); } return EvaluableNodeReference(query_return, true); diff --git a/src/Amalgam/entity/EntityWriteListener.cpp b/src/Amalgam/entity/EntityWriteListener.cpp index ff73e07c..ca05475b 100644 --- a/src/Amalgam/entity/EntityWriteListener.cpp +++ b/src/Amalgam/entity/EntityWriteListener.cpp @@ -187,7 +187,7 @@ void EntityWriteListener::LogNewEntry(EvaluableNode *new_entry, bool flush) if(logFile.is_open() && logFile.good()) { //one extra indentation because already have the sequence - logFile << Parser::Unparse(new_entry, &listenerStorage, false) << "\r\n"; + logFile << Parser::Unparse(new_entry, false, true, false) << "\r\n"; if(flush) logFile.flush(); } diff --git a/src/Amalgam/evaluablenode/EvaluableNode.cpp b/src/Amalgam/evaluablenode/EvaluableNode.cpp index a3a7e385..98957770 100644 --- a/src/Amalgam/evaluablenode/EvaluableNode.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNode.cpp @@ -3,6 +3,7 @@ #include "EvaluableNodeTreeFunctions.h" #include "EvaluableNodeManagement.h" #include "FastMath.h" +#include "Parser.h" #include "StringInternPool.h" //system headers: @@ -171,8 +172,8 @@ int EvaluableNode::Compare(EvaluableNode *a, EvaluableNode *b) return 0; } - std::string a_str = EvaluableNode::ToStringPreservingOpcodeType(a); - std::string b_str = EvaluableNode::ToStringPreservingOpcodeType(b); + std::string a_str = EvaluableNode::ToString(a, true); + std::string b_str = EvaluableNode::ToString(b, true); return StringManipulation::StringNaturalCompare(a_str, b_str); } @@ -208,79 +209,70 @@ double EvaluableNode::ToNumber(EvaluableNode *e, double value_if_null) } } -const std::string EvaluableNode::ToStringPreservingOpcodeType(EvaluableNode *e) +std::string EvaluableNode::NumberToString(double value, bool key_string) { - if(e == nullptr) - return "null"; - - switch(e->GetType()) - { - case ENT_NUMBER: - return NumberToString(e->GetNumberValueReference()); - - case ENT_STRING: - case ENT_SYMBOL: - return e->GetStringValue(); + if(key_string) + return Parser::UnparseNumberToKeyString(value); + else + return StringManipulation::NumberToString(value); +} - default: - return GetStringFromEvaluableNodeType(e->GetType()); - } +std::string EvaluableNode::NumberToString(size_t value, bool key_string) +{ + if(key_string) + return Parser::UnparseNumberToKeyString(value); + return StringManipulation::NumberToString(value); } -std::pair EvaluableNode::ToString(EvaluableNode *e) +std::string EvaluableNode::ToString(EvaluableNode *e, bool key_string) { - if(IsNull(e)) - return std::make_pair(false, "(null)"); + if(key_string) + return Parser::UnparseToKeyString(e); - switch(e->GetType()) - { - case ENT_NUMBER: - return std::make_pair(true, NumberToString(e->GetNumberValueReference())); + if(EvaluableNode::IsNull(e)) + return "(null)"; - case ENT_STRING: - case ENT_SYMBOL: - return std::make_pair(true, e->GetStringValue()); + if(e->GetType() == ENT_STRING) + return e->GetStringValue(); - default: - return std::make_pair(true, GetStringFromEvaluableNodeType(e->GetType())); - } + if(e->GetType() == ENT_NUMBER) + return StringManipulation::NumberToString(e->GetNumberValueReference()); - return std::make_pair(true, ""); + return Parser::Unparse(e, false, false, true); } -StringInternPool::StringID EvaluableNode::ToStringIDIfExists(EvaluableNode *e) +StringInternPool::StringID EvaluableNode::ToStringIDIfExists(EvaluableNode *e, bool key_string) { if(EvaluableNode::IsNull(e)) return StringInternPool::NOT_A_STRING_ID; - if((e->GetType() == ENT_STRING || e->GetType() == ENT_SYMBOL)) + if(e->GetType() == ENT_STRING) return e->GetStringIDReference(); - //see if the string exists even if it is not stored as a StringID - const std::string str_value = ToStringPreservingOpcodeType(e); + std::string str_value = ToString(e, key_string); //will return empty string if not found return string_intern_pool.GetIDFromString(str_value); } -StringInternPool::StringID EvaluableNode::ToStringIDWithReference(EvaluableNode *e) +StringInternPool::StringID EvaluableNode::ToStringIDWithReference(EvaluableNode *e, bool key_string) { if(EvaluableNode::IsNull(e)) return StringInternPool::NOT_A_STRING_ID; - if(e->GetType() == ENT_STRING || e->GetType() == ENT_SYMBOL) + if(e->GetType() == ENT_STRING) return string_intern_pool.CreateStringReference(e->GetStringIDReference()); - std::string stringified = ToStringPreservingOpcodeType(e); - return string_intern_pool.CreateStringReference(stringified); + std::string str_value = ToString(e, key_string); + return string_intern_pool.CreateStringReference(str_value); } -StringInternPool::StringID EvaluableNode::ToStringIDTakingReferenceAndClearing(EvaluableNode *e) +StringInternPool::StringID EvaluableNode::ToStringIDTakingReferenceAndClearing(EvaluableNode *e, bool include_symbol, bool key_string) { //null doesn't need a reference if(IsNull(e)) return StringInternPool::NOT_A_STRING_ID; - if(e->GetType() == ENT_STRING || e->GetType() == ENT_SYMBOL) + if(e->GetType() == ENT_STRING || (include_symbol && e->GetType() == ENT_SYMBOL)) { //clear the reference and return it StringInternPool::StringID &sid_reference = e->GetStringIDReference(); @@ -289,8 +281,8 @@ StringInternPool::StringID EvaluableNode::ToStringIDTakingReferenceAndClearing(E return sid_to_return; } - std::string stringified = ToStringPreservingOpcodeType(e); - return string_intern_pool.CreateStringReference(stringified); + std::string str_value = ToString(e, key_string); + return string_intern_pool.CreateStringReference(str_value); } void EvaluableNode::ConvertOrderedListToNumberedAssoc() @@ -309,7 +301,10 @@ void EvaluableNode::ConvertOrderedListToNumberedAssoc() auto &ocn = GetOrderedChildNodes(); new_map.reserve(ocn.size()); for(size_t i = 0; i < ocn.size(); i++) - new_map[string_intern_pool.CreateStringReference(NumberToString(i))] = ocn[i]; + { + std::string s = NumberToString(i, true); + new_map.emplace(string_intern_pool.CreateStringReference(s), ocn[i]); + } InitMappedChildNodes(); type = ENT_ASSOC; @@ -391,17 +386,13 @@ void EvaluableNode::InitializeType(EvaluableNode *n, bool copy_labels, bool copy { value.ConstructMappedChildNodes(); value.mappedChildNodes = n->GetMappedChildNodesReference(); - string_intern_pool.CreateStringReferences(value.mappedChildNodes, [](auto n) { return n.first; }); - //update idempotency SetIsIdempotent(true); - for(auto &[_, cn] : value.mappedChildNodes) + for(auto &[sid, cn] : value.mappedChildNodes) { + string_intern_pool.CreateStringReference(sid); if(cn != nullptr && !cn->GetIsIdempotent()) - { SetIsIdempotent(false); - break; - } } } else if(DoesEvaluableNodeTypeUseNumberData(type)) @@ -639,7 +630,7 @@ void EvaluableNode::SetType(EvaluableNodeType new_type, EvaluableNodeManager *en new_map.reserve((ocn.size() + 1) / 2); for(size_t i = 0; i < ocn.size(); i += 2) { - auto sid = ToStringIDWithReference(ocn[i]); + auto sid = ToStringIDWithReference(ocn[i], true); EvaluableNode *value = nullptr; if(i + 1 < ocn.size()) @@ -1920,3 +1911,145 @@ size_t EvaluableNode::GetDeepSizeNoCycleRecurse(EvaluableNode *n) return size; } + +void EvaluableNodeImmediateValueWithType::CopyValueFromEvaluableNode(EvaluableNode *en) +{ + if(en == nullptr) + { + nodeType = ENIVT_NULL; + nodeValue = EvaluableNodeImmediateValue(std::numeric_limits::quiet_NaN()); + return; + } + + auto en_type = en->GetType(); + if(en_type == ENT_NULL) + { + nodeType = ENIVT_NULL; + nodeValue = EvaluableNodeImmediateValue(std::numeric_limits::quiet_NaN()); + return; + } + + if(en_type == ENT_NUMBER) + { + nodeType = ENIVT_NUMBER; + nodeValue = EvaluableNodeImmediateValue(en->GetNumberValueReference()); + return; + } + + if(en_type == ENT_STRING) + { + nodeType = ENIVT_STRING_ID; + nodeValue = EvaluableNodeImmediateValue(en->GetStringIDReference()); + return; + } + + nodeType = ENIVT_CODE; + nodeValue = EvaluableNodeImmediateValue(en); +} + +bool EvaluableNodeImmediateValueWithType::GetValueAsBoolean() +{ + if(nodeType == ENIVT_NUMBER) + { + if(nodeValue.number == 0.0) + return false; + return true; + } + + if(nodeType == ENIVT_STRING_ID) + { + if(nodeValue.stringID == string_intern_pool.NOT_A_STRING_ID + || nodeValue.stringID == string_intern_pool.emptyStringId) + return false; + return true; + } + + if(nodeType == ENIVT_CODE) + return EvaluableNode::IsTrue(nodeValue.code); + + //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX + return false; +} + +double EvaluableNodeImmediateValueWithType::GetValueAsNumber(double value_if_null) +{ + if(nodeType == ENIVT_NUMBER) + return nodeValue.number; + + if(nodeType == ENIVT_STRING_ID) + { + if(nodeValue.stringID == string_intern_pool.NOT_A_STRING_ID) + return value_if_null; + + auto &str = string_intern_pool.GetStringFromID(nodeValue.stringID); + auto [value, success] = Platform_StringToNumber(str); + if(success) + return value; + return value_if_null; + } + + if(nodeType == ENIVT_CODE) + return EvaluableNode::ToNumber(nodeValue.code); + + //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX + return value_if_null; +} + +std::pair EvaluableNodeImmediateValueWithType::GetValueAsString(bool key_string) +{ + if(nodeType == ENIVT_STRING_ID) + { + if(nodeValue.stringID == string_intern_pool.NOT_A_STRING_ID) + return std::make_pair(false, ""); + + auto &str = string_intern_pool.GetStringFromID(nodeValue.stringID); + return std::make_pair(true, str); + } + + if(nodeType == ENIVT_NUMBER) + return std::make_pair(true, EvaluableNode::NumberToString(nodeValue.number, key_string)); + + if(nodeType == ENIVT_CODE && !EvaluableNode::IsNull(nodeValue.code)) + { + if(nodeValue.code != nullptr && nodeValue.code->GetType() == ENT_STRING) + return std::make_pair(true, nodeValue.code->GetStringValue()); + + if(key_string) + return std::make_pair(true, Parser::UnparseToKeyString(nodeValue.code)); + else + return std::make_pair(true, Parser::Unparse(nodeValue.code, false, false, true)); + } + + //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX + return std::make_pair(false, ""); +} + +StringInternPool::StringID EvaluableNodeImmediateValueWithType::GetValueAsStringIDIfExists(bool key_string) +{ + if(nodeType == ENIVT_STRING_ID) + return nodeValue.stringID; + + if(nodeType == ENIVT_CODE && nodeValue.code != nullptr && nodeValue.code->GetType() == ENT_STRING) + return nodeValue.code->GetStringIDReference(); + + auto [valid, str_value] = GetValueAsString(key_string); + if(!valid) + return string_intern_pool.NOT_A_STRING_ID; + + return string_intern_pool.GetIDFromString(str_value); +} + +StringInternPool::StringID EvaluableNodeImmediateValueWithType::GetValueAsStringIDWithReference(bool key_string) +{ + if(nodeType == ENIVT_STRING_ID) + return string_intern_pool.CreateStringReference(nodeValue.stringID); + + if(nodeType == ENIVT_CODE && nodeValue.code != nullptr && nodeValue.code->GetType() == ENT_STRING) + return string_intern_pool.CreateStringReference(nodeValue.code->GetStringIDReference()); + + auto [valid, str_value] = GetValueAsString(key_string); + if(!valid) + return string_intern_pool.NOT_A_STRING_ID; + + return string_intern_pool.CreateStringReference(str_value); +} \ No newline at end of file diff --git a/src/Amalgam/evaluablenode/EvaluableNode.h b/src/Amalgam/evaluablenode/EvaluableNode.h index f667d638..e33ed89f 100644 --- a/src/Amalgam/evaluablenode/EvaluableNode.h +++ b/src/Amalgam/evaluablenode/EvaluableNode.h @@ -362,31 +362,26 @@ class EvaluableNode } //Converts a number to a string in a consistent way that should be used for anything dealing with EvaluableNode - static __forceinline std::string NumberToString(double value) - { - return StringManipulation::NumberToString(value); - } - - static __forceinline std::string NumberToString(size_t value) - { - return StringManipulation::NumberToString(value); - } - - //converts the node to a string that represents the opcode - const static std::string ToStringPreservingOpcodeType(EvaluableNode *e); + static std::string NumberToString(double value, bool key_string = false); + static std::string NumberToString(size_t value, bool key_string = false); - //converts the node to a string, returning true if valid. If it doesn't exist or it's null, it returns false - static std::pair ToString(EvaluableNode *e); + //converts the node to a key string that can be used in assocs + //if key_string is true, then it will generate a string used for comparing in assoc keys + static std::string ToString(EvaluableNode *e, bool key_string = false); //converts node to an existing string. If it doesn't exist or it's null, it returns NOT_A_STRING_ID - static StringInternPool::StringID ToStringIDIfExists(EvaluableNode *e); + //if key_string is true, then it will generate a string used for comparing in assoc keys + static StringInternPool::StringID ToStringIDIfExists(EvaluableNode *e, bool key_string = false); //converts node to a string. Creates a reference to the string that must be destroyed, regardless of whether the string existed or not (if it did not exist, then it creates one) - static StringInternPool::StringID ToStringIDWithReference(EvaluableNode *e); + //if key_string is true, then it will generate a string used for comparing in assoc keys + static StringInternPool::StringID ToStringIDWithReference(EvaluableNode *e, bool key_string = false); //converts node to a string. Creates a reference to the string that must be destroyed, regardless of whether the string existed or not // if e is a string, it will clear it and hand the reference to the caller - static StringInternPool::StringID ToStringIDTakingReferenceAndClearing(EvaluableNode *e); + //if include_symbol is true, then it will also apply to ENT_SYMBOL + //if key_string is true, then it will generate a string used for comparing in assoc keys + static StringInternPool::StringID ToStringIDTakingReferenceAndClearing(EvaluableNode *e, bool include_symbol = false, bool key_string = false); //returns the comments as a new string static inline StringInternPool::StringID GetCommentsStringId(EvaluableNode *e) @@ -487,6 +482,20 @@ class EvaluableNode } } + //changes the type by setting it to the string id value specified + inline void SetTypeViaStringIdValue(StringInternPool::StringID v) + { + if(v == string_intern_pool.NOT_A_STRING_ID) + { + SetType(ENT_NULL, nullptr, false); + } + else + { + SetType(ENT_STRING, nullptr, false); + GetStringIDReference() = string_intern_pool.CreateStringReference(v); + } + } + //changes the type by setting it to the string id value specified, handing off the reference inline void SetTypeViaStringIdValueWithReferenceHandoff(StringInternPool::StringID v) { @@ -770,6 +779,8 @@ class EvaluableNode EvaluableNode *EraseMappedChildNode(const StringInternPool::StringID sid); void AppendMappedChildNodes(AssocType &mcn_to_append); + //helper function to obtain a typed value from mapped child nodes + //note that it can only be used on string key lookups, no code or numeric keys template static void GetValueFromMappedChildNodesReference(EvaluableNode::AssocType &mcn, EvaluableNodeBuiltInStringId key, T &value) { @@ -781,7 +792,7 @@ class EvaluableNode else if constexpr(std::is_same::value) value = EvaluableNode::ToNumber(found_value->second); else if constexpr(std::is_same::value) - value = EvaluableNode::ToStringPreservingOpcodeType(found_value->second); + value = EvaluableNode::ToString(found_value->second); else value = found_value->second; } @@ -1203,147 +1214,17 @@ class EvaluableNodeImmediateValueWithType } //copies the value from en and returns the EvaluableNodeConcreteValueType - void CopyValueFromEvaluableNode(EvaluableNode *en) - { - if(en == nullptr) - { - nodeType = ENIVT_NULL; - nodeValue = EvaluableNodeImmediateValue(std::numeric_limits::quiet_NaN()); - return; - } - - auto en_type = en->GetType(); - if(en_type == ENT_NULL) - { - nodeType = ENIVT_NULL; - nodeValue = EvaluableNodeImmediateValue(std::numeric_limits::quiet_NaN()); - return; - } + void CopyValueFromEvaluableNode(EvaluableNode *en); - if(en_type == ENT_NUMBER) - { - nodeType = ENIVT_NUMBER; - nodeValue = EvaluableNodeImmediateValue(en->GetNumberValueReference()); - return; - } + bool GetValueAsBoolean(); - if(en_type == ENT_STRING) - { - nodeType = ENIVT_STRING_ID; - nodeValue = EvaluableNodeImmediateValue(en->GetStringIDReference()); - return; - } + double GetValueAsNumber(double value_if_null = std::numeric_limits::quiet_NaN()); - nodeType = ENIVT_CODE; - nodeValue = EvaluableNodeImmediateValue(en); - } + std::pair GetValueAsString(bool key_string = false); - bool GetValueAsBoolean() - { - if(nodeType == ENIVT_NUMBER) - { - if(nodeValue.number == 0.0) - return false; - return true; - } + StringInternPool::StringID GetValueAsStringIDIfExists(bool key_string = false); - if(nodeType == ENIVT_STRING_ID) - { - if(nodeValue.stringID == string_intern_pool.NOT_A_STRING_ID - || nodeValue.stringID == string_intern_pool.emptyStringId) - return false; - return true; - } - - if(nodeType == ENIVT_CODE) - return EvaluableNode::IsTrue(nodeValue.code); - - //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX - return false; - } - - double GetValueAsNumber(double value_if_null = std::numeric_limits::quiet_NaN()) - { - if(nodeType == ENIVT_NUMBER) - return nodeValue.number; - - if(nodeType == ENIVT_STRING_ID) - { - if(nodeValue.stringID == string_intern_pool.NOT_A_STRING_ID) - return value_if_null; - - auto &str = string_intern_pool.GetStringFromID(nodeValue.stringID); - auto [value, success] = Platform_StringToNumber(str); - if(success) - return value; - return value_if_null; - } - - if(nodeType == ENIVT_CODE) - return EvaluableNode::ToNumber(nodeValue.code); - - //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX - return value_if_null; - } - - std::pair GetValueAsString() - { - if(nodeType == ENIVT_NUMBER) - return std::make_pair(true, EvaluableNode::NumberToString(nodeValue.number)); - - if(nodeType == ENIVT_STRING_ID) - { - if(nodeValue.stringID == string_intern_pool.NOT_A_STRING_ID) - return std::make_pair(false, ""); - - auto &str = string_intern_pool.GetStringFromID(nodeValue.stringID); - return std::make_pair(true, str); - } - - if(nodeType == ENIVT_CODE) - return std::make_pair(true, EvaluableNode::ToStringPreservingOpcodeType(nodeValue.code)); - - //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX - return std::make_pair(false, ""); - } - - StringInternPool::StringID GetValueAsStringIDIfExists() - { - if(nodeType == ENIVT_NUMBER) - { - const std::string str_value = EvaluableNode::NumberToString(nodeValue.number); - //will return empty string if not found - return string_intern_pool.GetIDFromString(str_value); - } - - if(nodeType == ENIVT_STRING_ID) - return nodeValue.stringID; - - if(nodeType == ENIVT_CODE) - return EvaluableNode::ToStringIDIfExists(nodeValue.code); - - //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX - return string_intern_pool.NOT_A_STRING_ID; - } - - StringInternPool::StringID GetValueAsStringIDWithReference() - { - if(nodeType == ENIVT_NUMBER) - { - const std::string str_value = EvaluableNode::NumberToString(nodeValue.number); - //will return empty string if not found - return string_intern_pool.CreateStringReference(str_value); - } - - if(nodeType == ENIVT_STRING_ID) - return string_intern_pool.CreateStringReference(nodeValue.stringID); - - if(nodeType == ENIVT_CODE) - return EvaluableNode::ToStringIDWithReference(nodeValue.code); - - //nodeType is one of ENIVT_NOT_EXIST, ENIVT_NULL, ENIVT_NUMBER_INDIRECTION_INDEX - return string_intern_pool.NOT_A_STRING_ID; - } + StringInternPool::StringID GetValueAsStringIDWithReference(bool key_string = false); static inline bool AreEqual(EvaluableNodeImmediateValueWithType &a, EvaluableNodeImmediateValueWithType &b) { diff --git a/src/Amalgam/evaluablenode/EvaluableNodeTreeDifference.cpp b/src/Amalgam/evaluablenode/EvaluableNodeTreeDifference.cpp index 5639980e..c96dcdfc 100644 --- a/src/Amalgam/evaluablenode/EvaluableNodeTreeDifference.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNodeTreeDifference.cpp @@ -193,13 +193,15 @@ EvaluableNode *EvaluableNodeTreeDifference::DifferenceTrees(EvaluableNodeManager else { //build (get (current_value 1) ...) - EvaluableNode *retrieval = enm->AllocNode(ENT_GET); + EvaluableNodeReference retrieval(enm->AllocNode(ENT_GET), true); replacement->SetMappedChildNode(cn_id, retrieval, true); EvaluableNode *target = enm->AllocNode(ENT_CURRENT_VALUE); target->AppendOrderedChildNode(enm->AllocNode(1.0)); retrieval->AppendOrderedChildNode(target); - retrieval->AppendOrderedChildNode(enm->AllocNode(ENT_STRING, cn_id)); + EvaluableNodeReference key_node = Parser::ParseFromKeyStringId(cn_id, enm); + retrieval->AppendOrderedChildNode(key_node); + retrieval.UpdatePropertiesBasedOnAttachedNode(key_node); } } } diff --git a/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp b/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp index 818ec844..a96863cb 100644 --- a/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp @@ -234,7 +234,7 @@ EvaluableNode *GetTraversalPathListFromAToB(EvaluableNodeManager *enm, Evaluable if(a == nullptr || b == nullptr) return nullptr; - EvaluableNode *path_list = enm->AllocNode(ENT_LIST); + EvaluableNodeReference path_list(enm->AllocNode(ENT_LIST), true); //find a path from b back to a by way of parents EvaluableNode::ReferenceSetType nodes_visited; @@ -260,7 +260,9 @@ EvaluableNode *GetTraversalPathListFromAToB(EvaluableNodeManager *enm, Evaluable } } - path_list->AppendOrderedChildNode(enm->AllocNode(ENT_STRING, key_sid)); + EvaluableNodeReference key_node = Parser::ParseFromKeyStringId(key_sid, enm); + path_list->AppendOrderedChildNode(key_node); + path_list.UpdatePropertiesBasedOnAttachedNode(key_node); } else if(b_ancestor_parent->IsOrderedArray()) { @@ -333,7 +335,7 @@ EvaluableNode **GetRelativeEvaluableNodeFromTraversalPathList(EvaluableNode **so if(!addr_empty) { //string must already exist if can't create anything - key_sid = EvaluableNode::ToStringIDIfExists(addr); + key_sid = EvaluableNode::ToStringIDIfExists(addr, true); if(key_sid == StringInternPool::NOT_A_STRING_ID) { destination = nullptr; @@ -353,7 +355,7 @@ EvaluableNode **GetRelativeEvaluableNodeFromTraversalPathList(EvaluableNode **so } else //create entry if it doesn't exist { - auto key_sid = EvaluableNode::ToStringIDWithReference(addr); + auto key_sid = EvaluableNode::ToStringIDWithReference(addr, true); //attempt to insert the new key auto [inserted_key, inserted] = mcn.insert(std::make_pair(key_sid, nullptr)); @@ -466,7 +468,7 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef auto &vvn_ocn = variable_value_node->GetOrderedChildNodes(); for(size_t i = 0; i + 1 < vvn_ocn.size(); i += 2) { - StringInternPool::StringID key_sid = EvaluableNode::ToStringIDWithReference(vvn_ocn[i]); + StringInternPool::StringID key_sid = EvaluableNode::ToStringIDWithReference(vvn_ocn[i], true); value_destination_node->SetMappedChildNodeWithReferenceHandoff(key_sid, vvn_ocn[i + 1]); } } @@ -479,14 +481,12 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef } else if(value_destination_node->GetType() == ENT_STRING) { - auto [cur_value_valid, cur_value] = EvaluableNode::ToString(value_destination_node); - auto [inc_value_valid, inc_value] = EvaluableNode::ToString(variable_value_node); - - //string will default to invalid value -- only set if both strings are valid - if(cur_value_valid && inc_value_valid) + //concatenate a string only if it is a valid string + if(variable_value_node != nullptr && variable_value_node->GetType() == ENT_STRING) { value_destination_node->SetType(ENT_STRING, nullptr, false); - value_destination_node->SetStringValue(cur_value.append(inc_value)); + std::string result = value_destination_node->GetStringValue() + variable_value_node->GetStringValue(); + value_destination_node->SetStringValue(result); } else { @@ -505,8 +505,10 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef for(auto &[cn_id, cn] : variable_value_node->GetMappedChildNodesReference()) { - value_destination_node->AppendOrderedChildNode(enm->AllocNode(ENT_STRING, cn_id)); + EvaluableNodeReference key_node = Parser::ParseFromKeyStringId(cn_id, enm); + value_destination_node->AppendOrderedChildNode(key_node); value_destination_node->AppendOrderedChildNode(cn); + value_destination_node.UpdatePropertiesBasedOnAttachedNode(key_node); } enm->FreeNodeIfPossible(variable_value_node); @@ -553,7 +555,7 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef auto &vvn_ocn = variable_value_node->GetOrderedChildNodes(); for(size_t i = 0; i + 1 < vvn_ocn.size(); i += 2) { - StringInternPool::StringID key_sid = EvaluableNode::ToStringIDWithReference(vvn_ocn[i]); + StringInternPool::StringID key_sid = EvaluableNode::ToStringIDWithReference(vvn_ocn[i], true); new_list->SetMappedChildNodeWithReferenceHandoff(key_sid, vvn_ocn[i + 1]); } } @@ -566,18 +568,22 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef } else if(value_destination_node->GetType() == ENT_STRING) { - auto [cur_value_valid, cur_value] = EvaluableNode::ToString(value_destination_node); - auto [inc_value_valid, inc_value] = EvaluableNode::ToString(variable_value_node); - - //string will default to invalid value -- only set if both strings are valid - if(cur_value_valid && inc_value_valid) - value_destination_node.SetReference(enm->AllocNode(ENT_STRING, cur_value.append(inc_value)), true); + //concatenate a string only if it is a valid string + if(variable_value_node != nullptr && variable_value_node->GetType() == ENT_STRING) + { + value_destination_node->SetType(ENT_STRING, nullptr, false); + std::string result = value_destination_node->GetStringValue() + variable_value_node->GetStringValue(); + value_destination_node->SetStringValue(result); + value_destination_node.SetReference(enm->AllocNode(ENT_STRING, result), true); + } else + { value_destination_node.SetReference(enm->AllocNode(ENT_NULL), true); + } } else //add ordered child node { - EvaluableNode *new_list = enm->AllocNode(value_destination_node); + EvaluableNodeReference new_list(enm->AllocNode(value_destination_node), true); if(EvaluableNode::IsAssociativeArray(variable_value_node)) { auto &vvn_mcn = variable_value_node->GetMappedChildNodesReference(); @@ -585,8 +591,10 @@ EvaluableNodeReference AccumulateEvaluableNodeIntoEvaluableNode(EvaluableNodeRef new_list->ReserveOrderedChildNodes(value_destination_node->GetOrderedChildNodes().size() + 2 * vvn_mcn.size()); for(auto &[cn_id, cn] : vvn_mcn) { - new_list->AppendOrderedChildNode(enm->AllocNode(ENT_STRING, cn_id)); + EvaluableNodeReference key_node = Parser::ParseFromKeyStringId(cn_id, enm); + new_list->AppendOrderedChildNode(key_node); new_list->AppendOrderedChildNode(cn); + new_list.UpdatePropertiesBasedOnAttachedNode(key_node); } enm->FreeNodeIfPossible(variable_value_node); diff --git a/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.h b/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.h index ca9cd9f5..fc50092d 100644 --- a/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.h +++ b/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.h @@ -403,12 +403,10 @@ inline EvaluableNodeReference CreateAssocOfNumbersFromIteratorAndFunctions(IDVal EvaluableNode *assoc = enm->AllocNode(ENT_ASSOC); assoc->ReserveMappedChildNodes(id_value_container.size()); - string_intern_pool.CreateStringReferences(id_value_container, get_string_id); - for(auto &id_value_iterator : id_value_container) { StringInternPool::StringID entity_sid = get_string_id(id_value_iterator); - assoc->SetMappedChildNodeWithReferenceHandoff(entity_sid, enm->AllocNode(get_number(id_value_iterator))); + assoc->SetMappedChildNode(entity_sid, enm->AllocNode(get_number(id_value_iterator))); } return EvaluableNodeReference(assoc, true); @@ -438,11 +436,9 @@ inline EvaluableNodeReference CreateListOfStringsIdsFromIteratorAndFunction(Stri EvaluableNode *list = enm->AllocListNodeWithOrderedChildNodes(ENT_STRING, string_container.size()); auto &ocn = list->GetOrderedChildNodesReference(); - string_intern_pool.CreateStringReferences(string_container, get_string_id); - size_t index = 0; for(auto string_element : string_container) - ocn[index++]->SetTypeViaStringIdValueWithReferenceHandoff(get_string_id(string_element)); + ocn[index++]->SetTypeViaStringIdValue(get_string_id(string_element)); return EvaluableNodeReference(list, true); } diff --git a/src/Amalgam/importexport/FileSupportCSV.cpp b/src/Amalgam/importexport/FileSupportCSV.cpp index 5af08814..f435685b 100644 --- a/src/Amalgam/importexport/FileSupportCSV.cpp +++ b/src/Amalgam/importexport/FileSupportCSV.cpp @@ -185,7 +185,7 @@ bool FileSupportCSV::Store(EvaluableNode *code, const std::string &resource_path if(EvaluableNode::IsNull(column_node)) continue; - std::string original_string = EvaluableNode::ToStringPreservingOpcodeType(column_node); + std::string original_string = EvaluableNode::ToString(column_node); std::string escaped_str = EscapeCSVStringIfNeeded(original_string); data_string.append(escaped_str); } diff --git a/src/Amalgam/interpreter/Interpreter.cpp b/src/Amalgam/interpreter/Interpreter.cpp index 390bc87e..a553998d 100644 --- a/src/Amalgam/interpreter/Interpreter.cpp +++ b/src/Amalgam/interpreter/Interpreter.cpp @@ -523,7 +523,7 @@ EvaluableNode *Interpreter::GetCurrentCallStackContext() return callStackNodes->back(); } -std::pair Interpreter::InterpretNodeIntoStringValue(EvaluableNode *n) +std::pair Interpreter::InterpretNodeIntoStringValue(EvaluableNode *n, bool key_string) { if(EvaluableNode::IsNull(n)) return std::make_pair(false, ""); @@ -535,13 +535,13 @@ std::pair Interpreter::InterpretNodeIntoStringValue(Evaluable auto result = InterpretNodeForImmediateUse(n, true); auto &result_value = result.GetValue(); - auto [valid, str] = result_value.GetValueAsString(); + auto [valid, str] = result_value.GetValueAsString(key_string); evaluableNodeManager->FreeNodeTreeIfPossible(result); return std::make_pair(valid, str); } -StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueIfExists(EvaluableNode *n) +StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueIfExists(EvaluableNode *n, bool key_string) { //shortcut if the node has what is being asked if(n != nullptr && n->GetType() == ENT_STRING) @@ -550,13 +550,13 @@ StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueIfExists(E auto result = InterpretNodeForImmediateUse(n, true); auto &result_value = result.GetValue(); - auto sid = result_value.GetValueAsStringIDIfExists(); + auto sid = result_value.GetValueAsStringIDIfExists(key_string); //ID already exists outside of this, so not expecting to keep this reference evaluableNodeManager->FreeNodeTreeIfPossible(result); return sid; } -StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueWithReference(EvaluableNode *n) +StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueWithReference(EvaluableNode *n, bool key_string) { //shortcut if the node has what is being asked if(n != nullptr && n->GetType() == ENT_STRING) @@ -573,7 +573,7 @@ StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueWithRefere return result_value.nodeValue.stringID; //create new reference - return result_value.GetValueAsStringIDWithReference(); + return result_value.GetValueAsStringIDWithReference(key_string); } else //not immediate { @@ -584,14 +584,14 @@ StringInternPool::StringID Interpreter::InterpretNodeIntoStringIDValueWithRefere if(result != nullptr && result->GetType() == ENT_STRING) result_sid = result->GetAndClearStringIDWithReference(); else - result_sid = EvaluableNode::ToStringIDWithReference(result); + result_sid = EvaluableNode::ToStringIDWithReference(result, key_string); evaluableNodeManager->FreeNodeTree(result); return result_sid; } else //not unique, so can't free { - return EvaluableNode::ToStringIDWithReference(result); + return EvaluableNode::ToStringIDWithReference(result, key_string); } } } diff --git a/src/Amalgam/interpreter/Interpreter.h b/src/Amalgam/interpreter/Interpreter.h index 37b96b49..f13f1b9c 100644 --- a/src/Amalgam/interpreter/Interpreter.h +++ b/src/Amalgam/interpreter/Interpreter.h @@ -527,13 +527,13 @@ class Interpreter //Calls InterpretNode on n, converts to std::string and stores in value to return, then cleans up any resources used //returns a pair of bool, whether it was a valid string (and not NaS), and the string - std::pair InterpretNodeIntoStringValue(EvaluableNode *n); + std::pair InterpretNodeIntoStringValue(EvaluableNode *n, bool key_string = false); //Calls InterpretNode on n, converts to std::string and stores in value to return, then cleans up any resources used // but if n is null, it will return an empty string - inline std::string InterpretNodeIntoStringValueEmptyNull(EvaluableNode *n) + inline std::string InterpretNodeIntoStringValueEmptyNull(EvaluableNode *n, bool key_string = false) { - auto [valid, str] = InterpretNodeIntoStringValue(n); + auto [valid, str] = InterpretNodeIntoStringValue(n, key_string); if(!valid) return ""; return str; @@ -541,11 +541,11 @@ class Interpreter //like InterpretNodeIntoStringValue, but returns the ID only if the string already exists, // otherwise it returns NOT_A_STRING_ID - StringInternPool::StringID InterpretNodeIntoStringIDValueIfExists(EvaluableNode *n); + StringInternPool::StringID InterpretNodeIntoStringIDValueIfExists(EvaluableNode *n, bool key_string = false); //like InterpretNodeIntoStringValue, but creates a reference to the string that must be destroyed, // regardless of whether the string existed or not (if it did not exist, then it creates one) - StringInternPool::StringID InterpretNodeIntoStringIDValueWithReference(EvaluableNode *n); + StringInternPool::StringID InterpretNodeIntoStringIDValueWithReference(EvaluableNode *n, bool key_string = false); //Calls InterpretNode on n, convers to a string, and makes sure that the node returned is // new and unique so that it can be modified diff --git a/src/Amalgam/interpreter/InterpreterDebugger.cpp b/src/Amalgam/interpreter/InterpreterDebugger.cpp index 8f260fd9..0ac65975 100644 --- a/src/Amalgam/interpreter/InterpreterDebugger.cpp +++ b/src/Amalgam/interpreter/InterpreterDebugger.cpp @@ -99,7 +99,7 @@ std::pair StringifyNode(EvaluableNode *en, EvaluableNo //if no comments, then can just print if(en == nullptr || en->GetCommentsStringId() == string_intern_pool.NOT_A_STRING_ID) { - std::string code_str = Parser::Unparse(en, enm, false, true, true); + std::string code_str = Parser::Unparse(en, false, true, true); ClampSingleLineStringLength(code_str, max_num_chars); return std::make_pair(std::string(), code_str); } @@ -118,7 +118,7 @@ std::pair StringifyNode(EvaluableNode *en, EvaluableNo //append with code EvaluableNode en_without_comment(en); en_without_comment.ClearComments(); - std::string code_str = Parser::Unparse(&en_without_comment, enm, false, true, true); + std::string code_str = Parser::Unparse(&en_without_comment, false, true, true); ClampSingleLineStringLength(code_str, max_num_chars); return std::make_pair(comment_str, code_str); @@ -518,12 +518,12 @@ EvaluableNodeReference Interpreter::InterpretNode_DEBUG(EvaluableNode *en, bool if(value_exists) { if(command == "p") - std::cout << Parser::Unparse(node, evaluableNodeManager, true, true, true) << std::endl; + std::cout << Parser::Unparse(node, true, true, true) << std::endl; else if(command == "pv") - std::cout << Parser::Unparse(node, evaluableNodeManager, true, false, true) << std::endl; + std::cout << Parser::Unparse(node, true, false, true) << std::endl; else if(command == "pp") { - std::string var_preview = Parser::Unparse(node, evaluableNodeManager, true, false, true); + std::string var_preview = Parser::Unparse(node, true, false, true); if(var_preview.size() > 1023) var_preview.resize(1023); std::cout << var_preview << std::endl; @@ -539,7 +539,7 @@ EvaluableNodeReference Interpreter::InterpretNode_DEBUG(EvaluableNode *en, bool std::cerr << w << std::endl; EvaluableNodeReference result = InterpretNodeForImmediateUse(node); - std::cout << Parser::Unparse(result, evaluableNodeManager, true, true, true) << std::endl; + std::cout << Parser::Unparse(result, true, true, true) << std::endl; SetDebuggingState(true); } else if(command == "validate") diff --git a/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp b/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp index ab634afc..2940cac3 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp @@ -344,7 +344,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_UNPARSE(EvaluableNode *en, deterministic_order = InterpretNodeIntoBoolValue(ocn[2]); auto tree = InterpretNodeForImmediateUse(ocn[0]); - std::string s = Parser::Unparse(tree, evaluableNodeManager, pretty, true, deterministic_order); + std::string s = Parser::Unparse(tree, pretty, true, deterministic_order); return ReuseOrAllocReturn(tree, s, immediate_result); } @@ -957,7 +957,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ASSIGN_and_ACCUM(Evaluable //using a single variable StringRef variable_sid; - variable_sid.SetIDWithReferenceHandoff(InterpretNodeIntoStringIDValueWithReference(ocn[0])); + variable_sid.SetIDWithReferenceHandoff(InterpretNodeIntoStringIDValueWithReference(ocn[0], true)); if(variable_sid == StringInternPool::NOT_A_STRING_ID) return EvaluableNodeReference::Null(); @@ -1133,7 +1133,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_RETRIEVE(EvaluableNode *en //get the value(s) if(EvaluableNode::IsNull(to_lookup) || IsEvaluableNodeTypeImmediate(to_lookup->GetType())) { - StringInternPool::StringID symbol_name_sid = EvaluableNode::ToStringIDIfExists(to_lookup); + StringInternPool::StringID symbol_name_sid = EvaluableNode::ToStringIDIfExists(to_lookup, true); EvaluableNode* symbol_value = GetCallStackSymbol(symbol_name_sid); evaluableNodeManager->FreeNodeTreeIfPossible(to_lookup); return EvaluableNodeReference(symbol_value, false); @@ -1162,7 +1162,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_RETRIEVE(EvaluableNode *en //overwrite values in the ordered for(auto &cn : to_lookup->GetOrderedChildNodes()) { - StringInternPool::StringID symbol_name_sid = EvaluableNode::ToStringIDIfExists(cn); + StringInternPool::StringID symbol_name_sid = EvaluableNode::ToStringIDIfExists(cn, true); if(symbol_name_sid == StringInternPool::NOT_A_STRING_ID) { cn = nullptr; @@ -1382,7 +1382,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_CURRENT_INDEX(EvaluableNod if(enivwt.nodeType == ENIVT_NUMBER) return AllocReturn(enivwt.nodeValue.number, immediate_result); else if(enivwt.nodeType == ENIVT_STRING_ID) - return AllocReturn(enivwt.nodeValue.stringID, immediate_result); + return Parser::ParseFromKeyStringId(enivwt.nodeValue.stringID, evaluableNodeManager); else return EvaluableNodeReference::Null(); } @@ -1711,7 +1711,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_RAND(EvaluableNode *en, bo //given an assoc of StringID -> value representing the probability weight of each, and a random stream, it randomly selects from the assoc // if it can't find an appropriate probability, it returns an empty string // if normalize is true, then it will accumulate the probability and then normalize -StringInternPool::StringID GetRandomWeightedKey(EvaluableNode::AssocType &assoc, RandomStream &rs, bool normalize) +static StringInternPool::StringID GetRandomWeightedKey(EvaluableNode::AssocType &assoc, RandomStream &rs, bool normalize) { double probability_target = rs.RandFull(); double accumulated_probability = 0.0; @@ -1792,7 +1792,7 @@ StringInternPool::StringID GetRandomWeightedKey(EvaluableNode::AssocType &assoc, //given a vector of vector of the probability weight of each value as probability_nodes, and a random stream, it randomly selects by probability and returns the index // if it can't find an appropriate probability, it returns the size of the probabilities list // if normalize is true, then it will accumulate the probability and then normalize -size_t GetRandomWeightedValueIndex(std::vector &probability_nodes, RandomStream &rs, bool normalize) +static size_t GetRandomWeightedValueIndex(std::vector &probability_nodes, RandomStream &rs, bool normalize) { double probability_target = rs.RandFull(); double accumulated_probability = 0.0; @@ -1861,7 +1861,8 @@ size_t GetRandomWeightedValueIndex(std::vector &probability_nod //Generates an EvaluableNode containing a random value based on the random parameter param, using enm and random_stream // if any part of param is preserved in the return value, then can_free_param will be set to false, otherwise it will be left alone -EvaluableNodeReference GenerateWeightedRandomValueBasedOnRandParam(EvaluableNodeReference param, EvaluableNodeManager *enm, RandomStream &random_stream, bool &can_free_param) +static EvaluableNodeReference GenerateWeightedRandomValueBasedOnRandParam(EvaluableNodeReference param, + EvaluableNodeManager *enm, RandomStream &random_stream, bool &can_free_param) { if(EvaluableNode::IsNull(param)) return EvaluableNodeReference::Null(); @@ -1886,7 +1887,7 @@ EvaluableNodeReference GenerateWeightedRandomValueBasedOnRandParam(EvaluableNode if(mcn.size() > 0) { StringInternPool::StringID id_selected = GetRandomWeightedKey(mcn, random_stream, true); - return EvaluableNodeReference(enm->AllocNode(ENT_STRING, id_selected), true); + return Parser::ParseFromKeyStringId(id_selected, enm); } return EvaluableNodeReference::Null(); @@ -1931,7 +1932,8 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_WEIGHTED_RAND(EvaluableNod if(!generate_list) { bool can_free_param = true; - EvaluableNodeReference rand_value = GenerateWeightedRandomValueBasedOnRandParam(param, evaluableNodeManager, randomStream, can_free_param); + EvaluableNodeReference rand_value = GenerateWeightedRandomValueBasedOnRandParam(param, + evaluableNodeManager, randomStream, can_free_param); if(can_free_param) evaluableNodeManager->FreeNodeTreeIfPossible(param); @@ -1981,9 +1983,9 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_WEIGHTED_RAND(EvaluableNod number_to_generate = std::min(number_to_generate, param->GetMappedChildNodesReference().size()); //want to generate multiple values, so return a list - EvaluableNodeReference retval( - evaluableNodeManager->AllocListNodeWithOrderedChildNodes(ENT_STRING, number_to_generate), true); + EvaluableNodeReference retval(evaluableNodeManager->AllocNode(ENT_LIST), true); auto &retval_ocn = retval->GetOrderedChildNodesReference(); + retval_ocn.reserve(number_to_generate); //make a copy of all of the probabilities so they can be removed one at a time EvaluableNode::AssocType assoc(param->GetMappedChildNodesReference()); @@ -1991,7 +1993,9 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_WEIGHTED_RAND(EvaluableNod for(size_t i = 0; i < number_to_generate; i++) { StringInternPool::StringID selected_sid = GetRandomWeightedKey(assoc, randomStream, true); - retval_ocn[i]->SetStringID(selected_sid); + EvaluableNodeReference selected_value = Parser::ParseFromKeyStringId(selected_sid, evaluableNodeManager); + retval_ocn.push_back(selected_value); + retval.UpdatePropertiesBasedOnAttachedNode(selected_value); //remove the element so it won't be reselected assoc.erase(selected_sid); @@ -2049,8 +2053,9 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_WEIGHTED_RAND(EvaluableNod EvaluableNode::AssocType, EvaluableNodeAsDouble> wdrst(mcn, false); for(size_t i = 0; i < number_to_generate; i++) { - EvaluableNode *rand_value = evaluableNodeManager->AllocNode(ENT_STRING, wdrst.WeightedDiscreteRand(randomStream)); + EvaluableNodeReference rand_value(Parser::ParseFromKeyStringId(wdrst.WeightedDiscreteRand(randomStream), evaluableNodeManager)); retval->AppendOrderedChildNode(rand_value); + retval.UpdatePropertiesBasedOnAttachedNode(rand_value); } evaluableNodeManager->FreeNodeTreeIfPossible(param); @@ -2098,7 +2103,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_SET_RAND_SEED(EvaluableNod if(seed_node != nullptr && seed_node->GetType() == ENT_STRING) seed_string = seed_node->GetStringValue(); else - seed_string = Parser::Unparse(seed_node, evaluableNodeManager, false, false, true); + seed_string = Parser::Unparse(seed_node, false, false, true); randomStream.SetState(seed_string); diff --git a/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp b/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp index ae6922b4..24f76113 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp @@ -178,7 +178,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_STRING(EvaluableNode *en, EvaluableNodeReference Interpreter::InterpretNode_ENT_SYMBOL(EvaluableNode *en, bool immediate_result) { - StringInternPool::StringID sid = EvaluableNode::ToStringIDIfExists(en); + StringInternPool::StringID sid = en->GetStringIDReference(); if(sid == StringInternPool::NOT_A_STRING_ID) return EvaluableNodeReference::Null(); @@ -611,7 +611,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, EvaluableNode::GetValueFromMappedChildNodesReference(mcn, ENBISI_sort_keys, sort_keys); } - string_value = Parser::Unparse(code_value, evaluableNodeManager, false, true, sort_keys); + string_value = Parser::Unparse(code_value, false, false, sort_keys); } } else if(to_type == GetStringIdFromBuiltInStringId(ENBISI_Base16) || to_type == GetStringIdFromBuiltInStringId(ENBISI_Base64)) @@ -649,7 +649,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, //if using code, just reuse string value if(use_code) - string_value = Parser::Unparse(code_value, evaluableNodeManager, false); + string_value = Parser::Unparse(code_value, false, false, true); if(to_type == GetStringIdFromBuiltInStringId(ENBISI_Base16)) string_value = StringManipulation::BinaryStringToBase16(string_value); @@ -927,10 +927,9 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET_ALL_LABELS(EvaluableNo auto [label_sids_to_nodes, _] = EvaluableNodeTreeManipulation::RetrieveLabelIndexesFromTree(n); - string_intern_pool.CreateStringReferences(label_sids_to_nodes, [](auto it) { return it.first; }); result->ReserveMappedChildNodes(label_sids_to_nodes.size()); for(auto &[node_id, node] : label_sids_to_nodes) - result->SetMappedChildNodeWithReferenceHandoff(node_id, node); + result->SetMappedChildNode(node_id, node); //can't guarantee there weren't any cycles if more than one label if(label_sids_to_nodes.size() > 1) @@ -1797,22 +1796,13 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_PRINT(EvaluableNode *en, b std::string s; if(cur == nullptr) - { s = "(null)"; - } - else if(IsEvaluableNodeTypeImmediate(cur->GetType())) - { - if(DoesEvaluableNodeTypeUseStringData(cur->GetType())) - s = cur->GetStringValue(); - else if(DoesEvaluableNodeTypeUseNumberData(cur->GetType())) - s = EvaluableNode::NumberToString(cur->GetNumberValueReference()); - else - s = EvaluableNode::ToStringPreservingOpcodeType(cur); - } + else if(DoesEvaluableNodeTypeUseStringData(cur->GetType())) + s = cur->GetStringValue(); + else if(DoesEvaluableNodeTypeUseNumberData(cur->GetType())) + s = EvaluableNode::NumberToString(cur->GetNumberValueReference()); else - { - s = Parser::Unparse(cur, evaluableNodeManager, true, true, true); - } + s = Parser::Unparse(cur, true, true, true); evaluableNodeManager->FreeNodeTreeIfPossible(cur); diff --git a/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp b/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp index a2017425..fc3f2698 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp @@ -109,9 +109,8 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_CONTAINED_ENTITIES_and_COM auto &result_ocn = result->GetOrderedChildNodesReference(); //create the string references all at once and hand off - string_intern_pool.CreateStringReferences(contained_entities, [](Entity *e) { return e->GetIdStringId(); }); for(size_t i = 0; i < contained_entities.size(); i++) - result_ocn[i]->SetTypeViaStringIdValueWithReferenceHandoff(contained_entities[i]->GetIdStringId()); + result_ocn[i]->SetTypeViaStringIdValue(contained_entities[i]->GetIdStringId()); //if not using SBFDS, make sure always return in the same order for consistency, regardless of cashing, hashing, etc. //if using SBFDS, then the order is assumed to not matter for other queries, so don't pay the cost of sorting here diff --git a/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp b/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp index cadd7054..94b4b152 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp @@ -100,7 +100,6 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET_ENTITY_COMMENTS(Evalua params_list->ReserveMappedChildNodes(mcn.size()); //create the string references all at once and hand off - string_intern_pool.CreateStringReferences(mcn, [](auto it) { return it.first; }); for(auto &[cn_id, cn] : mcn) { //create list with comment and default value @@ -111,7 +110,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET_ENTITY_COMMENTS(Evalua param_info_ocn[1] = evaluableNodeManager->DeepAllocCopy(cn, EvaluableNodeManager::ENMM_REMOVE_ALL); //add to the params - params_list->SetMappedChildNodeWithReferenceHandoff(cn_id, param_info); + params_list->SetMappedChildNode(cn_id, param_info); } return retval; @@ -260,7 +259,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_SET_ENTITY_RAND_SEED(Evalu if(seed_node != nullptr && seed_node->GetType() == ENT_STRING) seed_string = seed_node->GetStringValue(); else - seed_string = Parser::Unparse(seed_node, evaluableNodeManager, false, false, true); + seed_string = Parser::Unparse(seed_node, false, false, true); auto node_stack = CreateOpcodeStackStateSaver(seed_node); //get the entity diff --git a/src/Amalgam/interpreter/InterpreterOpcodesListManipulation.cpp b/src/Amalgam/interpreter/InterpreterOpcodesListManipulation.cpp index 5ff022d5..4deabc23 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesListManipulation.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesListManipulation.cpp @@ -483,7 +483,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_APPEND(EvaluableNode *en, for(size_t i = 0; i < new_elements_ocn.size(); i++, new_list_cur_index++) { //look for first index not used - std::string index_string = EvaluableNode::NumberToString(new_list_cur_index); + std::string index_string = EvaluableNode::NumberToString(new_list_cur_index, true); EvaluableNode **found = new_list->GetMappedChildNode(index_string); if(found != nullptr) { @@ -510,7 +510,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_APPEND(EvaluableNode *en, //find the next unused index std::string index_string; do { - index_string = EvaluableNode::NumberToString(static_cast(new_list_cur_index++)); + index_string = EvaluableNode::NumberToString(new_list_cur_index++, true); } while(new_list->GetMappedChildNode(index_string) != nullptr); new_list->SetMappedChildNode(index_string, new_elements); diff --git a/src/Amalgam/interpreter/InterpreterOpcodesMath.cpp b/src/Amalgam/interpreter/InterpreterOpcodesMath.cpp index 23012ea0..1bd6d01e 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesMath.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesMath.cpp @@ -1147,7 +1147,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ENTROPY(EvaluableNode *en, q_copied_values.reserve(p_num_elements); for(size_t index = 0; index < p_num_elements; index++) { - StringInternPool::StringID key_sid = EvaluableNode::ToStringIDIfExists((*p_values)[index]); + StringInternPool::StringID key_sid = EvaluableNode::ToStringIDIfExists((*p_values)[index], true); EvaluableNode **found = q_node->GetMappedChildNode(key_sid); if(found != nullptr) diff --git a/src/Amalgam/interpreter/InterpreterOpcodesTransformations.cpp b/src/Amalgam/interpreter/InterpreterOpcodesTransformations.cpp index 2f24ee12..5c38bb7e 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesTransformations.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesTransformations.cpp @@ -127,9 +127,8 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_MAP(EvaluableNode *en, boo //and because iterators may be invalidated when the map is changed auto &result_mcn = result->GetMappedChildNodesReference(); result_mcn.reserve(num_nodes); - string_intern_pool.CreateStringReferences(list_mcn, [](auto it) { return it.first; }); for(auto &[sid, cn] : list_mcn) - result_mcn.emplace(sid, nullptr); + result_mcn.emplace(string_intern_pool.CreateStringReference(sid), nullptr); #ifdef MULTITHREAD_SUPPORT if(en->GetConcurrency() && num_nodes > 1) @@ -287,7 +286,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_MAP(EvaluableNode *en, boo } else if(inputs[i]->IsAssociativeArray()) { - const std::string index_string = EvaluableNode::NumberToString(index); + const std::string index_string = EvaluableNode::NumberToString(index, true); EvaluableNode **found = inputs[i]->GetMappedChildNode(index_string); if(found != nullptr) is_ocn[i] = *found; @@ -301,7 +300,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_MAP(EvaluableNode *en, boo SetTopCurrentValueInConstructionStack(input_slice); EvaluableNodeReference element_result = InterpretNode(function); - std::string index_string = EvaluableNode::NumberToString(index); + std::string index_string = EvaluableNode::NumberToString(index, true); result->SetMappedChildNode(index_string, element_result); result.UpdatePropertiesBasedOnAttachedNode(element_result); @@ -1033,15 +1032,16 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_INDICES(EvaluableNode *en, if(container->IsAssociativeArray()) { auto &container_mcn = container->GetMappedChildNodesReference(); - index_list.SetReference(evaluableNodeManager->AllocListNodeWithOrderedChildNodes(ENT_STRING, container_mcn.size())); - - //create all the string references at once for speed (especially multithreading) - string_intern_pool.CreateStringReferences(container_mcn, [](auto n) { return n.first; }); + index_list.SetReference(evaluableNodeManager->AllocNode(ENT_LIST)); auto &index_list_ocn = index_list->GetOrderedChildNodesReference(); - size_t index = 0; + index_list_ocn.reserve(container_mcn.size()); for(auto &[node_id, _] : container_mcn) - index_list_ocn[index++]->SetTypeViaStringIdValueWithReferenceHandoff(node_id); + { + EvaluableNodeReference key_node = Parser::ParseFromKeyStringId(node_id, evaluableNodeManager); + index_list_ocn.push_back(key_node); + index_list.UpdatePropertiesBasedOnAttachedNode(key_node); + } } else if(container->IsOrderedArray()) { @@ -1128,7 +1128,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_VALUES(EvaluableNode *en, { for(auto &n : container->GetOrderedChildNodesReference()) { - std::string str_value = Parser::Unparse(n, evaluableNodeManager, false, false, true); + std::string str_value = Parser::UnparseToKeyString(n); if(values_in_existence.emplace(str_value).second) result->AppendOrderedChildNode(n); } @@ -1137,7 +1137,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_VALUES(EvaluableNode *en, { for(auto &[_, cn] : container->GetMappedChildNodesReference()) { - std::string str_value = Parser::Unparse(cn, evaluableNodeManager, false, false, true); + std::string str_value = Parser::UnparseToKeyString(cn); if(values_in_existence.emplace(str_value).second) result->AppendOrderedChildNode(cn); } @@ -1223,7 +1223,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_CONTAINS_VALUE(EvaluableNo //compute regular expression auto &s = container->GetStringValue(); - std::string value_as_str = EvaluableNode::ToStringPreservingOpcodeType(value); + std::string value_as_str = EvaluableNode::ToString(value); //use nosubs to prevent unnecessary memory allocations since this is just matching std::regex rx; @@ -1271,7 +1271,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_REMOVE(EvaluableNode *en, { if(container->IsAssociativeArray()) { - StringInternPool::StringID key_sid = indices.GetValue().GetValueAsStringIDIfExists(); + StringInternPool::StringID key_sid = indices.GetValue().GetValueAsStringIDIfExists(true); removed_node.SetReference(container->EraseMappedChildNode(key_sid)); } else if(container->IsOrderedArray()) @@ -1304,7 +1304,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_REMOVE(EvaluableNode *en, { for(auto &cn : indices_ocn) { - StringInternPool::StringID key_sid = EvaluableNode::ToStringIDIfExists(cn); + StringInternPool::StringID key_sid = EvaluableNode::ToStringIDIfExists(cn, true); removed_node.SetReference(container->EraseMappedChildNode(key_sid)); evaluableNodeManager->FreeNodeTreeIfPossible(removed_node); } @@ -1378,7 +1378,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_KEEP(EvaluableNode *en, bo { if(container->IsAssociativeArray()) { - StringInternPool::StringID key_sid = indices.GetValue().GetValueAsStringIDWithReference(); + StringInternPool::StringID key_sid = indices.GetValue().GetValueAsStringIDWithReference(true); auto &container_mcn = container->GetMappedChildNodesReference(); //find what should be kept, or clear key_sid if not found @@ -1449,7 +1449,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_KEEP(EvaluableNode *en, bo for(auto &cn : indices_ocn) { - StringInternPool::StringID key_sid = EvaluableNode::ToStringIDIfExists(cn); + StringInternPool::StringID key_sid = EvaluableNode::ToStringIDIfExists(cn, true); //if found, move it over to the new container auto found_to_keep = container_mcn.find(key_sid); @@ -1600,7 +1600,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ASSOCIATE(EvaluableNode *e for(size_t i = 0; i < num_nodes; i += 2) { //get key - StringInternPool::StringID key_sid = InterpretNodeIntoStringIDValueWithReference(ocn[i]); + StringInternPool::StringID key_sid = InterpretNodeIntoStringIDValueWithReference(ocn[i], true); SetTopCurrentIndexInConstructionStack(key_sid); @@ -1695,9 +1695,9 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ZIP(EvaluableNode *en, boo //obtain the index, reusing the sid reference if possible StringInternPool::StringID index_sid = string_intern_pool.emptyStringId; if(index_list.unique) - index_sid = EvaluableNode::ToStringIDTakingReferenceAndClearing(index); + index_sid = EvaluableNode::ToStringIDTakingReferenceAndClearing(index, false, true); else - index_sid = EvaluableNode::ToStringIDWithReference(index); + index_sid = EvaluableNode::ToStringIDWithReference(index, true); //get value EvaluableNode *value = nullptr; @@ -1782,7 +1782,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_UNZIP(EvaluableNode *en, b { for(auto &index : index_list_ocn) { - StringInternPool::StringID index_sid = EvaluableNode::ToStringIDIfExists(index); + StringInternPool::StringID index_sid = EvaluableNode::ToStringIDIfExists(index, true); EvaluableNode **found = zipped->GetMappedChildNode(index_sid); if(found != nullptr) diff --git a/src/Amalgam/out.txt b/src/Amalgam/out.txt index 04be5b44..17f7c7fe 100644 --- a/src/Amalgam/out.txt +++ b/src/Amalgam/out.txt @@ -5,264 +5,264 @@ hello world: 12 and 2 hello world: 12 and 2 --get_defaults-- -{ - != 0.65 - !~ 0.1 - * 0.65 - + 0.9 - "-" 0.65 - / 0.6 - < 0.85 - <= 0.85 - = 1.2 - > 0.85 - >= 0.85 - abs 0.4 - accum 0.25 - accum_entity_roots 0.01 - accum_to_entities 0.5 - acos 0.2 - acosh 0.07 - and 0.75 - append 0.65 - apply 0.5 - args 0.08 - asin 0.2 - asinh 0.07 - assign 0.95 - assign_entity_roots 0.01 - assign_to_entities 0.5 - assoc 3 - associate 0.8 - atan 0.2 - atanh 0.07 - call 1.5 - call_container 0.5 - call_entity 0.5 - call_entity_get_changes 0.05 - call_sandboxed 0.25 - ceil 0.6 - clone_entities 0.1 - commonality 0.2 - commonality_entities 0.02 - compute_entity_convictions 0.2 - compute_entity_distance_contributions 0.2 - compute_entity_group_kl_divergence 0.2 - compute_entity_kl_divergences 0.2 - compute_on_contained_entities 0.3 - concat 0.2 - conclude 0.05 - contained_entities 0.3 - contains_entity 0.1 - contains_index 0.5 - contains_label 0.5 - contains_value 0.5 - cos 0.2 - cosh 0.07 - create_entities 0.1 - crypto_sign 0.01 - crypto_sign_verify 0.01 - current_index 0.1 - current_value 0.1 - declare 0.5 - decrypt 0.01 - destroy_entities 0.1 - difference 0.2 - difference_entities 0.02 - direct_assign_to_entities 0.01 - direct_retrieve_from_entity 0.01 - dot_product 0.2 - edit_distance 0.2 - edit_distance_entities 0.02 - encrypt 0.01 - erf 0.05 - exp 0.4 - explode 0.02 - false 0.1 - filter 0.5 - first 0.65 - flatten_entity 0.02 - floor 0.6 - format 0.05 - generalized_distance 0.15 - get 3 - get_all_labels 0.05 - get_comments 0.05 - get_concurrency 0.01 - get_defaults 0.01 - get_digits 0.1 - get_entity_comments 0.01 - get_entity_rand_seed 0.01 - get_entity_root_permission 0.01 - get_labels 0.1 - get_rand_seed 0.02 - get_type 0.25 - get_type_string 0.25 - get_value 0.15 - if 1 - indices 0.5 - intersect 0.2 - intersect_entities 0.02 - keep 0.5 - lambda 1.5 - last 0.65 - let 0.95 - lgamma 0.07 - list 2 - load 0.01 - load_entity 0.01 - log 0.4 - map 1.1 - max 0.4 - min 0.4 - mix 0.2 - mix_entities 0.02 - mix_labels 0.2 - mod 0.2 - move_entities 0.15 - mutate 0.2 - mutate_entity 0.02 - not 0.75 - null 0.75 - number 8 - opcode_stack 0.01 - or 0.75 - parallel 0.5 - parse 0.05 - pow 0.2 - previous_result 0.05 - print 0.01 - query_among 0.2 - query_between 0.2 - query_equals 0.2 - query_exists 0.2 - query_generalized_mean 0.2 - query_greater_or_equal_to 0.2 - query_in_entity_list 0.2 - query_less_or_equal_to 0.2 - query_max 0.2 - query_max_difference 0.2 - query_min 0.2 - query_min_difference 0.2 - query_mode 0.2 - query_nearest_generalized_distance 0.2 - query_not_among 0.2 - query_not_between 0.2 - query_not_equals 0.2 - query_not_exists 0.2 - query_not_in_entity_list 0.2 - query_quantile 0.2 - query_sample 0.2 - query_select 0.2 - query_sum 0.2 - query_value_masses 0.2 - query_weighted_sample 0.2 - query_within_generalized_distance 0.2 - rand 0.4 - range 0.5 - reduce 0.7 - remove 0.5 - replace 0.1 - retrieve 0.1 - retrieve_entity_root 0.01 - retrieve_from_entity 0.5 - return 0.05 - reverse 0.4 - rewrite 0.1 - round 0.6 - seq 0.5 - set 0.35 - set_comments 0.05 - set_concurrency 0.01 - set_digits 0.1 - set_entity_rand_seed 0.01 - set_entity_root_permission 0.01 - set_labels 0.1 - set_rand_seed 0.02 - set_type 0.35 - set_value 0.15 - sin 0.2 - sinh 0.07 - size 0.6 - sort 0.5 - split 0.2 - sqrt 0.2 - stack 0.05 - store 0.01 - store_entity 0.01 - string 4 - substr 0.2 - symbol 10 - system 0.05 - system_time 0.01 - tail 0.65 - tan 0.2 - tanh 0.07 - target 0.1 - tgamma 0.07 - total_entity_size 0.02 - total_size 0.2 - true 0.1 - trunc 0.65 - union 0.2 - union_entities 0.02 - unparse 0.05 - unzip 0.25 - values 0.5 - weave 0.2 - weighted_rand 0.02 - while 0.1 - xor 0.75 - zip 0.35 - zip_labels 0.02 - ~ 0.1 -} -{ - change_label 0.04 - change_type 0.28 - deep_copy_elements 0.05 - delete 0.12 - delete_elements 0.04 - insert 0.23 - swap_elements 0.24 -} +{ + != 0.65 + !~ 0.1 + * 0.65 + + 0.9 + "-" 0.65 + / 0.6 + < 0.85 + <= 0.85 + = 1.2 + > 0.85 + >= 0.85 + abs 0.4 + accum 0.25 + accum_entity_roots 0.01 + accum_to_entities 0.5 + acos 0.2 + acosh 0.07 + and 0.75 + append 0.65 + apply 0.5 + args 0.08 + asin 0.2 + asinh 0.07 + assign 0.95 + assign_entity_roots 0.01 + assign_to_entities 0.5 + assoc 3 + associate 0.8 + atan 0.2 + atanh 0.07 + call 1.5 + call_container 0.5 + call_entity 0.5 + call_entity_get_changes 0.05 + call_sandboxed 0.25 + ceil 0.6 + clone_entities 0.1 + commonality 0.2 + commonality_entities 0.02 + compute_entity_convictions 0.2 + compute_entity_distance_contributions 0.2 + compute_entity_group_kl_divergence 0.2 + compute_entity_kl_divergences 0.2 + compute_on_contained_entities 0.3 + concat 0.2 + conclude 0.05 + contained_entities 0.3 + contains_entity 0.1 + contains_index 0.5 + contains_label 0.5 + contains_value 0.5 + cos 0.2 + cosh 0.07 + create_entities 0.1 + crypto_sign 0.01 + crypto_sign_verify 0.01 + current_index 0.1 + current_value 0.1 + declare 0.5 + decrypt 0.01 + destroy_entities 0.1 + difference 0.2 + difference_entities 0.02 + direct_assign_to_entities 0.01 + direct_retrieve_from_entity 0.01 + dot_product 0.2 + edit_distance 0.2 + edit_distance_entities 0.02 + encrypt 0.01 + erf 0.05 + exp 0.4 + explode 0.02 + false 0.1 + filter 0.5 + first 0.65 + flatten_entity 0.02 + floor 0.6 + format 0.05 + generalized_distance 0.15 + get 3 + get_all_labels 0.05 + get_comments 0.05 + get_concurrency 0.01 + get_defaults 0.01 + get_digits 0.1 + get_entity_comments 0.01 + get_entity_rand_seed 0.01 + get_entity_root_permission 0.01 + get_labels 0.1 + get_rand_seed 0.02 + get_type 0.25 + get_type_string 0.25 + get_value 0.15 + if 1 + indices 0.5 + intersect 0.2 + intersect_entities 0.02 + keep 0.5 + lambda 1.5 + last 0.65 + let 0.95 + lgamma 0.07 + list 2 + load 0.01 + load_entity 0.01 + log 0.4 + map 1.1 + max 0.4 + min 0.4 + mix 0.2 + mix_entities 0.02 + mix_labels 0.2 + mod 0.2 + move_entities 0.15 + mutate 0.2 + mutate_entity 0.02 + not 0.75 + null 0.75 + number 8 + opcode_stack 0.01 + or 0.75 + parallel 0.5 + parse 0.05 + pow 0.2 + previous_result 0.05 + print 0.01 + query_among 0.2 + query_between 0.2 + query_equals 0.2 + query_exists 0.2 + query_generalized_mean 0.2 + query_greater_or_equal_to 0.2 + query_in_entity_list 0.2 + query_less_or_equal_to 0.2 + query_max 0.2 + query_max_difference 0.2 + query_min 0.2 + query_min_difference 0.2 + query_mode 0.2 + query_nearest_generalized_distance 0.2 + query_not_among 0.2 + query_not_between 0.2 + query_not_equals 0.2 + query_not_exists 0.2 + query_not_in_entity_list 0.2 + query_quantile 0.2 + query_sample 0.2 + query_select 0.2 + query_sum 0.2 + query_value_masses 0.2 + query_weighted_sample 0.2 + query_within_generalized_distance 0.2 + rand 0.4 + range 0.5 + reduce 0.7 + remove 0.5 + replace 0.1 + retrieve 0.1 + retrieve_entity_root 0.01 + retrieve_from_entity 0.5 + return 0.05 + reverse 0.4 + rewrite 0.1 + round 0.6 + seq 0.5 + set 0.35 + set_comments 0.05 + set_concurrency 0.01 + set_digits 0.1 + set_entity_rand_seed 0.01 + set_entity_root_permission 0.01 + set_labels 0.1 + set_rand_seed 0.02 + set_type 0.35 + set_value 0.15 + sin 0.2 + sinh 0.07 + size 0.6 + sort 0.5 + split 0.2 + sqrt 0.2 + stack 0.05 + store 0.01 + store_entity 0.01 + string 4 + substr 0.2 + symbol 10 + system 0.05 + system_time 0.01 + tail 0.65 + tan 0.2 + tanh 0.07 + target 0.1 + tgamma 0.07 + total_entity_size 0.02 + total_size 0.2 + true 0.1 + trunc 0.65 + union 0.2 + union_entities 0.02 + unparse 0.05 + unzip 0.25 + values 0.5 + weave 0.2 + weighted_rand 0.02 + while 0.1 + xor 0.75 + zip 0.35 + zip_labels 0.02 + ~ 0.1 +} +{ + change_label 0.04 + change_type 0.28 + deep_copy_elements 0.05 + delete 0.12 + delete_elements 0.04 + insert 0.23 + swap_elements 0.24 +} --parse and unparse-- (print "hello") -[(null) (null) .infinity -.infinity] +[(null) (null) .infinity -.infinity] {c ["alpha" "beta" "gamma"] a 1 b 2} -{ - c ["alpha" "beta" "gamma"] - a 1 - b 2 -} - -(apply "6") - -(apply "notakeyword") - -(seq - (+ 1 2) -) -[ - (seq - (+ 1 2) - (+) - ) - ["Warning: 2 missing closing parenthesis at line 1, column 17"] -] -[ - (seq - (+ 1 2) - ) - ["Warning: 1 missing closing parenthesis at line 1, column 17"] -] -[ - (seq - (+ 1 2) - ) - ["Warning: Invalid opcode \"a\"; transforming to apply opcode using the invalid opcode type at line 1, column 19"] -] +{ + c ["alpha" "beta" "gamma"] + a 1 + b 2 +} + +(apply "6") + +(apply "notakeyword") + +(seq + (+ 1 2) +) +[ + (seq + (+ 1 2) + (+) + ) + ["Warning: 2 missing closing parenthesis at line 1, column 17"] +] +[ + (seq + (+ 1 2) + ) + ["Warning: 1 missing closing parenthesis at line 1, column 17"] +] +[ + (seq + (+ 1 2) + ) + ["Warning: Invalid opcode \"a\"; transforming to apply opcode using the invalid opcode type at line 1, column 19"] +] --if-- if 1 if 2 @@ -272,17 +272,17 @@ if 2 2 3 --lambda and call-- -(declare - {x 6} - (+ x 2) -) +(declare + {x 6} + (+ x 2) +) 5 -(lambda - (+ 1 2) -) +(lambda + (+ 1 2) +) --call_sandboxed-- 7 -(null) +(null) 11 (null) @@ -318,78 +318,78 @@ declare1 success --assign-- 10 20 -[ - 0 - 1 - 2 - {a 1 b 2 c 3} -] -[ - 0 - "not 1" - 2 - {a 1 b 2 c 3} -] -[ - 0 - "not 1" - 2 - { - a ["a attribute"] - b 2 - c ["c attribute"] - } -] +[ + 0 + 1 + 2 + {a 1 b 2 c 3} +] +[ + 0 + "not 1" + 2 + {a 1 b 2 c 3} +] +[ + 0 + "not 1" + 2 + { + a ["a attribute"] + b 2 + c ["c attribute"] + } +] --accum-- 10 11 abcdef -[1 2 3 4 5 6] - -[ - 1 - 2 - 3 - 4 - 5 - 6 - "7" - 8 -] - -{ - a 1 - b 2 - c 3 - d 4 -} - -{ - a 1 - b 2 - c 3 - d 4 - e 5 -} +[1 2 3 4 5 6] + +[ + 1 + 2 + 3 + 4 + 5 + 6 + "7" + 8 +] + +{ + a 1 + b 2 + c 3 + d 4 +} + +{ + a 1 + b 2 + c 3 + d 4 + e 5 +} 5 -[ - 0 - 2 - 2 - {a 1 b 2 c 3} -] +[ + 0 + 2 + 2 + {a 1 b 2 c 3} +] --retrieve-- 1 1 -[1 2] -{raaa 2 rwww 1} +[1 2] +{raaa 2 rwww 1} --assign-- 8 12 -[0 1 10 3 4] -{a 3 b 2} +[0 1 10 3 4] +{a 3 b 2} --+-- 10 ----- @@ -402,86 +402,86 @@ abcdef --mod-- 1 --get_digits-- -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 0 - 0 - 0 -] -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 8 - 9 - 9 -] -[ - 5 - 6 - 7 - 8 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -] -[1 1 1] -[1 0 0 0 0] -[1 2 0] -[1 1 1 1] -[1 0 0 0 0] -[2 0] -[0 0 0 0 1 1] -[1 0] -[ - 1 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - 0 - 0 - 1 -] -[1 2 3 4 5] -[5 6 7 8 0] -[1 2 3 4 5] -[5 6 7 8 0] -[] -[] -[] -[ - 4 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -] +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 0 + 0 + 0 +] +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 8 + 9 + 9 +] +[ + 5 + 6 + 7 + 8 + 0 + 0 + 0 + 0 + 0 + 0 + 0 +] +[1 1 1] +[1 0 0 0 0] +[1 2 0] +[1 1 1 1] +[1 0 0 0 0] +[2 0] +[0 0 0 0 1 1] +[1 0] +[ + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 +] +[1 2 3 4 5] +[5 6 7 8 0] +[1 2 3 4 5] +[5 6 7 8 0] +[] +[] +[] +[ + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 +] --set_digits-- 5554567.8 1234567.555 @@ -496,9 +496,9 @@ abcdef 5.555567800000001e+100 1.2345555499999999e+100 1.23456585e+100 -[1 0 1 0] -[1 0 1 0] -[1 0 1 0] +[1 0 1 0] +[1 0 1 0] +[1 0 1 0] --floor-- 1 --ceil-- @@ -546,7 +546,7 @@ abcdef --cosh-- 1.1276259652063807 --acosh-- -(null) +(null) --tanh-- 0.46211715726000974 @@ -605,7 +605,7 @@ abcdef 26 2.23606797749979 27 3.0000000031604355 28 3 -29 (null) +29 (null) 30 6 31 4 @@ -636,40 +636,40 @@ abcdef 1 0 a -(null) +(null) --tail-- -[9.2 "this"] -[2 3 4 5 6] -[5 6] -[3 4 5 6] -[] -[1 2 3 4 5 6] -[1 2 3 4 5 6] -[] -{ - a 1 - b 2 - c 3 - e 5 - f 6 -} -{b 2 e 5} -{ - a 1 - b 2 - e 5 - f 6 -} -{ - a 1 - b 2 - c 3 - d 4 - e 5 - f 6 -} -{} +[9.2 "this"] +[2 3 4 5 6] +[5 6] +[3 4 5 6] +[] +[1 2 3 4 5 6] +[1 2 3 4 5 6] +[] +{ + a 1 + b 2 + c 3 + d 4 + e 5 +} +{b 2 e 5} +{ + a 1 + b 2 + d 4 + e 5 +} +{ + a 1 + b 2 + c 3 + d 4 + e 5 + f 6 +} +{} 2 0 bcdef @@ -679,7 +679,7 @@ abcdef abcdef -(null) +(null) --last-- this @@ -687,40 +687,40 @@ this 1 0 c -(null) +(null) --trunc-- -[4 9.2] -[1 2 3 4 5] -[1 2] -[1 2 3 4] -[] -[1 2 3 4 5 6] -[1 2 3 4 5 6] -[] -{ - a 1 - b 2 - c 3 - e 5 - f 6 -} -{b 2 e 5} -{ - a 1 - b 2 - e 5 - f 6 -} -{ - a 1 - b 2 - c 3 - d 4 - e 5 - f 6 -} -{} +[4 9.2] +[1 2 3 4 5] +[1 2] +[1 2 3 4] +[] +[1 2 3 4 5 6] +[1 2 3 4 5 6] +[] +{ + a 1 + b 2 + c 3 + d 4 + e 5 +} +{b 2 e 5} +{ + a 1 + b 2 + d 4 + e 5 +} +{ + a 1 + b 2 + c 3 + d 4 + e 5 + f 6 +} +{} 2 0 abcde @@ -730,252 +730,252 @@ abcdef abcdef -(null) +(null) --append-- -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -] -{ - 0 1 - 1 2 - 2 3 - 3 7 - 4 8 - 5 9 - a 4 - b 5 - c 6 - d 10 - e 11 -} -[4 9.2 "this" "end"] -{ - 0 4 - 1 9.2 - 2 "this" - 3 "end" -} +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +] +{ + 0 1 + 1 2 + 2 3 + 3 7 + 4 8 + 5 9 + a 4 + b 5 + c 6 + d 10 + e 11 +} +[4 9.2 "this" "end"] +{ + 0 4 + 1 9.2 + 2 "this" + 3 "end" +} --size-- 3 4 5 --range-- -[ - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 -] -[ - 10 - 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0 -] -[] -[0 1 2 3 4 5] -[12 12 12 12 12 12] -[1 2 3 4 5 6] -[1 2 3 4 5 6] +[ + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 +] +[ + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 +] +[] +[0 1 2 3 4 5] +[12 12 12 12 12 12] +[1 2 3 4 5 6] +[1 2 3 4 5 6] --replace-- -[ - {a 13} -] -[ - [4 5 6] - (null) - 1 -] -[ - [4 5 6] - (null) - 1 -] -[ - {a 1 b 2} -] +[ + {a 13} +] +[ + [4 5 6] + (null) + 1 +] +[ + [4 5 6] + (null) + 1 +] +[ + {a 1 b 2} +] --rewrite-- -[ - {a 14} -] -[ - (associate "a" 312) -] -[ - 8 - 8 - 8 - 8 - 8 - 8 - 8 - 8 - 8 -] -(+ 17 a) +[ + {a 14} +] +[ + (associate "a" 312) +] +[ + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 +] +(+ 17 a) --map-- -[2 4 6 8] -[ - 10 - 2 - 22 - 5 - 34 - 8 - 46 - 11 -] -{ - 10 11 - 20 22 - 30 33 - 40 44 -} -[3 4 5 6 7 8] -[3 4 5 6 7 (null)] -{ - 0 3 - 1 (null) - 2 (null) - 3 (null) - a (null) -} +[2 4 6 8] +[ + 10 + 2 + 22 + 5 + 34 + 8 + 46 + 11 +] +{ + 10 11 + 20 22 + 30 33 + 40 44 +} +[3 4 5 6 7 8] +[3 4 5 6 7 (null)] +{ + 0 3 + 1 (null) + 2 (null) + 3 (null) + a (null) +} --filter-- -[3 4] -[10 1 20] -{10 1} -[10 1 20 30 40 4] -[ - 10 - 1 - 20 - 30 - "" - 40 - 4 -] -{ - a 10 - b 1 - c 20 - d "" - e 30 - f 3 - h 4 -} -{ - a 10 - b 1 - c 20 - d "" - e 30 - f 3 - h 4 -} +[3 4] +[10 1 20] +{10 1} +[10 1 20 30 40 4] +[ + 10 + 1 + 20 + 30 + "" + 40 + 4 +] +{ + a 10 + b 1 + c 20 + d "" + e 30 + f 3 + h 4 +} +{ + a 10 + b 1 + c 20 + d "" + e 30 + f 3 + h 4 +} --weave-- -[1 2 3] - -[1 2 3 4 5 6] - -[2 (null) 4 (null) 6 (null)] - -["a" 2 @(get (target 2) 0) 4 @(get (target 2) 0) 6] - -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -] - -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 -] - -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 -] - -[ - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - 20 - 22 - 24 -] - -[1 2 3 4 5 6] - -[ - 1 - 2 - 3 - 5 - 4 - 5 - 6 - 6 - 7 -] - -[3 4 5] +[1 2 3] + +[1 2 3 4 5 6] + +[2 (null) 4 (null) 6 (null)] + +["a" 2 @(get (target 2) 0) 4 @(get (target 2) 0) 6] + +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +] + +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 +] + +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 +] + +[ + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + 20 + 22 + 24 +] + +[1 2 3 4 5 6] + +[ + 1 + 2 + 3 + 5 + 4 + 5 + 6 + 6 + 7 +] + +[3 4 5] --reduce-- 24 24 @@ -984,275 +984,288 @@ abcdef 15 10 --reverse-- -[5 4 3 2 1] +[5 4 3 2 1] --sort-- -[1 3 4 5 9] -[ - 1 - 3.2 - 4 - "b" - "hello" - [1 2 3] - "n" - "soy" -] -[ - 1 - "1x" - "10" - 20 - "z2" - "z10" - "z100" -] -[ - "001x" - "010" - 1 - 20 - "z002" - "z010" - "z100" -] -[1 3 4 5 9] -[ - 1 - 6 - 2 - 7 - 0 - 3 - 4 - 10 - 5 - 8 - 9 -] -[ - "2020-06-08 lunes 11.32.36" - "2020-06-08 lunes 11.32.37" - "2020-06-08 lunes 11.32.38" - "2020-06-08 lunes 11.32.39" - "2020-06-08 lunes 11.32.46" - "2020-06-08 lunes 11.32.47" - "2020-06-08 lunes 11.32.48" - "2020-06-08 lunes 11.32.49" - "2020-06-08 lunes 11.32.56" - "2020-06-08 lunes 11.32.57" - "2020-06-08 lunes 11.32.58" - "2020-06-08 lunes 11.32.59" - "2020-06-08 lunes 11.33.36" - "2020-06-08 lunes 11.33.37" - "2020-06-08 lunes 11.33.38" - "2020-06-08 lunes 11.33.39" - "2020-06-08 lunes 11.33.40" - "2020-06-08 lunes 11.33.41" - "2020-06-08 lunes 11.33.42" - "2020-06-08 lunes 11.33.43" - "2020-06-08 lunes 11.33.44" - "2020-06-08 lunes 11.33.45" - "2020-06-08 lunes 11.33.46" - "2020-06-08 lunes 11.33.47" - "2020-06-08 lunes 11.33.48" -] -[1 3] -[9 5] -[1 3] -[9 5] +[1 3 4 5 9] +[ + 1 + 3.2 + 4 + [1 2 3] + "b" + "hello" + "n" + "soy" +] +[ + 1 + 20 + "1x" + "10" + "z2" + "z10" + "z100" +] +[ + 1 + 20 + "001x" + "010" + "z002" + "z010" + "z100" +] +[1 3 4 5 9] +[ + 1 + 2 + 9 + 3 + 0 + 4 + 5 + 8 + 7 + 10 + 6 +] +[ + "2020-06-08 lunes 11.32.36" + "2020-06-08 lunes 11.32.37" + "2020-06-08 lunes 11.32.38" + "2020-06-08 lunes 11.32.39" + "2020-06-08 lunes 11.32.46" + "2020-06-08 lunes 11.32.47" + "2020-06-08 lunes 11.32.48" + "2020-06-08 lunes 11.32.49" + "2020-06-08 lunes 11.32.56" + "2020-06-08 lunes 11.32.57" + "2020-06-08 lunes 11.32.58" + "2020-06-08 lunes 11.32.59" + "2020-06-08 lunes 11.33.36" + "2020-06-08 lunes 11.33.37" + "2020-06-08 lunes 11.33.38" + "2020-06-08 lunes 11.33.39" + "2020-06-08 lunes 11.33.40" + "2020-06-08 lunes 11.33.41" + "2020-06-08 lunes 11.33.42" + "2020-06-08 lunes 11.33.43" + "2020-06-08 lunes 11.33.44" + "2020-06-08 lunes 11.33.45" + "2020-06-08 lunes 11.33.46" + "2020-06-08 lunes 11.33.47" + "2020-06-08 lunes 11.33.48" +] +[1 3] +[9 5] +[1 3] +[9 5] --indices-- -["4" "c" "a" "b"] -[ - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 -] +["c" 4 "a" "b"] +[ + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 +] +[0 1 2 3] +[0 2 3 1] +[0 2 1 3] --values-- -[3 "d" 1 2] -[ - "a" - 1 - "b" - 2 - "c" - 3 - 4 - "d" -] -[ - "a" - 1 - "b" - 2 - "c" - 3 - 4 - "d" -] -[3 1 2 "d"] -[ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 -] +[3 "d" 1 2] +[ + "a" + 1 + "b" + 2 + "c" + 3 + 4 + "d" +] +[ + "a" + 1 + "b" + 2 + "c" + 3 + 4 + "d" +] +[3 "d" 1 2] +[ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 +] --contains_index-- -(true) +(true) -(false) +(false) -(true) +(true) -(false) +(false) --contains_value-- -(true) +(true) -(false) +(false) -(true) +(true) -(false) +(false) -(true) -(true) -(true) -(true) -(false) -(true) +(true) +(true) +(true) +(true) +(false) +(true) --remove-- -{a 1 b 2 c 3} -[ - "a" - 1 - "b" - 2 - 3 - 4 - "d" -] -{b 2 c 3} -[ - "a" - 1 - "b" - 2 - 3 - 4 - "d" -] -[1 3 4 5] -[0 1 2 3 4] -[1 2 3 4] -[] +{a 1 b 2 c 3} +[ + "a" + 1 + "b" + 2 + 3 + 4 + "d" +] +{b 2 c 3} +[ + "a" + 1 + "b" + 2 + 3 + 4 + "d" +] +[1 3 4 5] +[0 1 2 3 4] +[1 2 3 4] +[] --keep-- -{4 "d"} -["c"] -{4 "d" a 1} -["c"] -[0 2] -[5] -[0 5] -[0 1 2 3 4 5] +{4 "d"} +["c"] +{4 "d" a 1} +["c"] +[0 2] +[5] +[0 5] +[0 1 2 3 4 5] --zip-- -{ - a 1 - b 2 - c 3 - d 4 -} -{ - a (null) - b (null) - c (null) - d (null) -} -{ - a 3 - b @(get - (target 2) - "a" - ) - c @(get - (target 2) - "a" - ) - d @(get - (target 2) - "a" - ) -} -{ - a 4 - b 2 - c 3 - d 4 -} -{ - a 5 - b 2 - c 3 - d 4 -} -{ - a 2 - b 1 - c @(get - (target 2) - "b" - ) - d @(get - (target 2) - "b" - ) -} +{ + a 1 + b 2 + c 3 + d 4 +} +{ + a (null) + b (null) + c (null) + d (null) +} +{ + a 3 + b @(get + (target 2) + "a" + ) + c @(get + (target 2) + "a" + ) + d @(get + (target 2) + "a" + ) +} +{ + a 4 + b 2 + c 3 + d 4 +} +{ + a 5 + b 2 + c 3 + d 4 +} +{ + a 2 + b 1 + c @(get + (target 2) + "b" + ) + d @(get + (target 2) + "b" + ) +} --unzip-- -[1 2] -[1 3 2] +[1 2] +[1 3 2] --get-- -[4 9.2 "this"] +[4 9.2 "this"] 9.2 3 1 -[9.2 "this"] +[9.2 "this"] 2: 2 (null): (null) (null): (null) 3 +number +string +list +assoc +[ + "4" + {4 4} + 4 + [4] +] --set-- -{ - 4 "d" - a 1 - b 2 - c 3 - e 5 -} -[0 1 10 3 4] -{a 3 b 2} +{ + 4 "d" + a 1 + b 2 + c 3 + e 5 +} +[0 1 10 3 4] +{a 3 b 2} --target-- -[1 2 3 (null) (null)] +[1 2 3 (null) (null)] --current_index-- 3 (null) @@ -1272,369 +1285,369 @@ current_index: 2 (null) --opcode_stack-- 4 -(seq - (seq - (opcode_stack 2) - ) -) +(seq + (seq + (opcode_stack 2) + ) +) -;Full test -;This is a suite of unit tests. -; This is the second line of the unit test description. -(seq) +;Full test +;This is a suite of unit tests. +; This is the second line of the unit test description. +(seq) --stack-- -[ - { - abcdefghijklmnop 1 - accum_assoc { - a 1 - b 2 - c 3 - d 4 - e 5 - } - accum_list [ - 1 - 2 - 3 - 4 - 5 - 6 - "7" - 8 - ] - accum_string "abcdef" - argv ["C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] - bar (declare - {x 6} - (+ x 2) - ) - foo (declare - {x 6} - (+ x 2) - ) - get_test_assoc { - A {B 2} - B 2 - } - interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" - raaa 2 - rmdir "rmdir /s /q " - rmfile "del /s /q " - rwww 1 - slash "\\" - start_time 1730659255.572875 - www 1 - x 12 - zz 10 - } -] +[ + { + abcdefghijklmnop 1 + accum_assoc { + a 1 + b 2 + c 3 + d 4 + e 5 + } + accum_list [ + 1 + 2 + 3 + 4 + 5 + 6 + "7" + 8 + ] + accum_string "abcdef" + argv ["C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] + bar (declare + {x 6} + (+ x 2) + ) + foo (declare + {x 6} + (+ x 2) + ) + get_test_assoc { + A {B 2} + B 2 + } + interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + raaa 2 + rmdir "rmdir /s /q " + rmfile "del /s /q " + rwww 1 + slash "\\" + start_time 1731075188.452971 + www 1 + x 12 + zz 10 + } +] --args-- -{ - abcdefghijklmnop 1 - accum_assoc { - a 1 - b 2 - c 3 - d 4 - e 5 - } - accum_list [ - 1 - 2 - 3 - 4 - 5 - 6 - "7" - 8 - ] - accum_string "abcdef" - argv ["C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] - bar (declare - {x 6} - (+ x 2) - ) - foo (declare - {x 6} - (+ x 2) - ) - get_test_assoc { - A {B 2} - B 2 - } - interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" - raaa 2 - rmdir "rmdir /s /q " - rmfile "del /s /q " - rwww 1 - slash "\\" - start_time 1730659255.572875 - www 1 - x 12 - zz 10 -} -{bbb 3} -{ - abcdefghijklmnop 1 - accum_assoc { - a 1 - b 2 - c 3 - d 4 - e 5 - } - accum_list [ - 1 - 2 - 3 - 4 - 5 - 6 - "7" - 8 - ] - accum_string "abcdef" - argv ["C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] - bar (declare - {x 6} - (+ x 2) - ) - foo (declare - {x 6} - (+ x 2) - ) - get_test_assoc { - A {B 2} - B 2 - } - interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" - raaa 2 - rmdir "rmdir /s /q " - rmfile "del /s /q " - rwww 1 - slash "\\" - start_time 1730659255.572875 - www 1 - x 12 - zz 10 -} +{ + abcdefghijklmnop 1 + accum_assoc { + a 1 + b 2 + c 3 + d 4 + e 5 + } + accum_list [ + 1 + 2 + 3 + 4 + 5 + 6 + "7" + 8 + ] + accum_string "abcdef" + argv ["C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] + bar (declare + {x 6} + (+ x 2) + ) + foo (declare + {x 6} + (+ x 2) + ) + get_test_assoc { + A {B 2} + B 2 + } + interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + raaa 2 + rmdir "rmdir /s /q " + rmfile "del /s /q " + rwww 1 + slash "\\" + start_time 1731075188.452971 + www 1 + x 12 + zz 10 +} +{bbb 3} +{ + abcdefghijklmnop 1 + accum_assoc { + a 1 + b 2 + c 3 + d 4 + e 5 + } + accum_list [ + 1 + 2 + 3 + 4 + 5 + 6 + "7" + 8 + ] + accum_string "abcdef" + argv ["C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] + bar (declare + {x 6} + (+ x 2) + ) + foo (declare + {x 6} + (+ x 2) + ) + get_test_assoc { + A {B 2} + B 2 + } + interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + raaa 2 + rmdir "rmdir /s /q " + rmfile "del /s /q " + rwww 1 + slash "\\" + start_time 1731075188.452971 + www 1 + x 12 + zz 10 +} --and-- true -(false) +(false) --or-- 1 1 -(false) +(false) --xor-- -(true) +(true) -(false) +(false) --not-- -(false) +(false) -(true) +(true) --=-- -(false) +(false) -(true) +(true) -(true) +(true) -(true) +(true) -(true) +(true) -(false) +(false) --!=-- -(false) +(false) -(true) +(true) -(false) +(false) -(false) +(false) -(false) +(false) -(false) +(false) -(true) +(true) --<-- -(true) +(true) -(false) +(false) -(true) +(true) -(false) +(false) --<=-- -(true) +(true) -(true) +(true) -(true) +(true) -(false) +(false) -(false) +(false) -(false) +(false) -->-- -(true) +(true) -(false) +(false) -(true) +(true) -(false) +(false) -->=-- -(true) +(true) -(true) +(true) -(true) +(true) -(false) +(false) -(false) +(false) -(false) +(false) --~-- -(true) +(true) -(false) +(false) --!~-- -(false) +(false) -(true) +(true) --rand-- -0.4354658822862165 -0.21633478712323329 -16.519946352271695 -4 +0.3085212072078084 +0.8108604140462151 +36.53852784176681 7 -[] +7 +[] -[1] +[9] -[ - 9 - 2 - 5 - 0 - 8 - 3 - 10 - 1 - 4 - 7 -] +[ + 8 + 6 + 1 + 9 + 5 + 0 + 3 + 4 + 7 + 2 +] -[7.171706438820119 32.23595572370973 31.007463842801343 46.83241306269183] +[15.147298145412242 2.8707229850232165 1.1842755192409848 26.133999503489054] --weighted_rand-- b -["a" "a" "a" "a"] +["b" "a" "b" "b"] b -["a" "b" @(get (target 2) 1) @(get (target 2) 1)] +["b" @(get (target 2) 0) "a" @(get (target 2) 2)] -["a" @(get (target 2) 0) @(get (target 2) 0) @(get (target 2) 0)] +["b" @(get (target 2) 0) @(get (target 2) 0) "a"] -infinity test c or d: ["c" "c" "c" "c"] +infinity test c or d: ["c" "c" "d" "c"] -infinity test c or d: ["c" @(get (target 2) 0) @(get (target 2) 0) @(get (target 2) 0)] +infinity test c or d: ["c" "d" @(get (target 2) 1) @(get (target 2) 0)] -{a 18 b 53 c 29} +{a 34 b 50 c 16} -{a 25 b 50 c 25} +{a 30 b 50 c 20} -["2" "5" "1"] +[1 2 4] --get_rand_seed-- - A)p1͉ +0R'`!cl --set_rand_seed-- -0.45713181313394535 -0.2514913417952701 -0.45713181313394535 -0.2514913417952701 +0.14733430167075878 +0.7960497320657874 +0.14733430167075878 +0.7960497320657874 --true-- -(true) +(true) --false-- -(false) +(false) --null-- -(null) +(null) -(null - (+ 3 5) - 7 -) +(null + (+ 3 5) + 7 +) --node null-- -#nulltest (null) +#nulltest (null) --infinity-- .infinity -.infinity --list-- -["a" 1 "b"] +["a" 1 "b"] --associate-- -{ - 4 "d" - a 1 - b 2 - c 3 -} +{ + 4 "d" + a 1 + b 2 + c 3 +} --assoc-- -{b 2 c 3} -{(null) 3} +{b 2 c 3} +{(null) 3} --get_type-- -(+) +(+) --get_type_string-- + string --set_type-- -(- 3 4) -["a" 4 "b" 3] -["a" 4 "b" 3] -{a 4 b 3} +(- 3 4) +["a" 4 "b" 3] +["a" 4 "b" 3] +{a 4 b 3} 8.7 -(parallel - #react - (+ 3 4) -) +(parallel + #react + (+ 3 4) +) --format-- -[ - 97 - 98 - 99 - 100 - 101 - 102 - 103 - -17 - -84 - -105 - -22 - -83 - -106 - -49 - -95 -] +[ + 97 + 98 + 99 + 100 + 101 + 102 + 103 + -17 + -84 + -105 + -22 + -83 + -106 + -49 + -95 +] 1: A 2: -100 3: -100 @@ -1655,21 +1668,21 @@ string 18: Many hands make light work. 19: Many hands make light work.. 19: Many hands make light work... -20: [ - {a 3 b 4} - {c "c"} -] -21: [{"a":3,"b":4},{"d":null,"c":"c"}] +20: [ + {a 3 b 4} + {c "c"} +] +21: [{"a":3,"b":4},{"c":"c","d":null}] 22: [{"a":3,"b":4},{"c":"c","d":null}] -23: d: 4 -c: 3 +23: c: 3 +d: 4 a: 1 -b: 2 e: - a - b - - .inf +b: 2 24: a: 1 b: 2 @@ -1681,8 +1694,8 @@ e: - - .inf -25: {a 1} -current date-time in epoch: 2024-11-03-13.40.56.2811770 +25: {a 1} +current date-time in epoch: 2024-11-08-09.13.08.5143700 2020-06-07 00:22:59 1391230800 1391230800 @@ -1720,140 +1733,140 @@ domingo, jun. 07, 2020 12:00:00AM 12:00:00AM --get_labels-- -["labelB"] +["labelB"] --get_all_labels-- -{ - label-number-22 #label-number-22 3 - label21 #label21 - (print - "hello world: " - (* - @(get - (target 4) - "label-number-22" - ) - 4 - ) - #label23 " and " - (* 1 2) - ) - label23 @(get - (target 2) - ["label21" 2] - ) -} -{ - labelA #labelQ #labelA - (lambda - #labelB (true) - ) - labelB @(get - (target 2) - ["labelA" 0] - ) - labelQ @(get - (target 2) - "labelA" - ) -} -{ - labelA #labelQ #labelA - (lambda - #labelB (true) - ) - labelB @(get - (target 2) - ["labelA" 0] - ) - labelQ @(get - (target 2) - "labelA" - ) -} +{ + label-number-22 #label-number-22 3 + label21 #label21 + (print + "hello world: " + (* + @(get + (target 4) + "label-number-22" + ) + 4 + ) + #label23 " and " + (* 1 2) + ) + label23 @(get + (target 2) + ["label21" 2] + ) +} +{ + labelA #labelA #labelQ + (lambda + #labelB (true) + ) + labelB @(get + (target 2) + ["labelA" 0] + ) + labelQ @(get + (target 2) + "labelA" + ) +} +{ + labelA #labelA #labelQ + (lambda + #labelB (true) + ) + labelB @(get + (target 2) + ["labelA" 0] + ) + labelQ @(get + (target 2) + "labelA" + ) +} --set_labels-- -#labelD #labelE (true) +#labelD #labelE (true) --zip_labels-- -[ - #l1 1 - #l2 2 - #l3 3 -] +[ + #l1 1 + #l2 2 + #l3 3 +] --get_comments-- comment too --set_comments-- -;new comment -(true) +;new comment +(true) --get_concurrency-- -(false) +(false) -(true) +(true) -(true) +(true) --set_concurrency-- -||(print "hello") +||(print "hello") -;complex test -#somelabel -||{a "hello" b 4} +;complex test +#somelabel +||{a "hello" b 4} --get_value-- -(true) +(true) --set_value-- 3 --explode-- -[ - "a" - "b" - "c" - "d" - "e" - "f" - "g" - "ﬗ" - "ꭖ" - "ϡ" -] -[ - "a" - "b" - "c" - "d" - "e" - "f" - "g" - "" - "" - "" - "" - "" - "" - "" - "" -] -[ - "ab" - "cd" - "ef" - "g" - "" - "" - "" - "" -] -["abc" "def" "g" "" "ϡ"] -["abcd" "efg" "" "ϡ"] +[ + "a" + "b" + "c" + "d" + "e" + "f" + "g" + "ﬗ" + "ꭖ" + "ϡ" +] +[ + "a" + "b" + "c" + "d" + "e" + "f" + "g" + "" + "" + "" + "" + "" + "" + "" + "" +] +[ + "ab" + "cd" + "ef" + "g" + "" + "" + "" + "" +] +["abc" "def" "g" "" "ϡ"] +["abcd" "efg" "" "ϡ"] --split-- -["hello world"] -["hello" "world"] -["hello" "world" "!"] -["hello" "world !"] -["hello " " the world"] -["abcdefgﬗꭖϡ"] -["abc" "de" "fgﬗꭖϡ"] -["abc" "de" "fgﬗꭖϡ"] -["abc" "de fgﬗꭖϡ"] -["abc de fgﬗꭖϡ"] +["hello world"] +["hello" "world"] +["hello" "world" "!"] +["hello" "world !"] +["hello " " the world"] +["abcdefgﬗꭖϡ"] +["abc" "de" "fgﬗꭖϡ"] +["abc" "de" "fgﬗꭖϡ"] +["abc" "de fgﬗꭖϡ"] +["abc de fgﬗꭖϡ"] --substr-- hello world ello world @@ -1865,32 +1878,32 @@ orl hxlo world e he -["he"] +["he"] -["he" "wo"] +["he" "wo"] -["he" "wo"] +["he" "wo"] -[ - ["he" "e"] -] +[ + ["he" "e"] +] -[ - ["he" "e"] - ["wo" "o"] -] +[ + ["he" "e"] + ["wo" "o"] +] -[ - ["he" "he" "h" "e"] - ["wo" "wo" "w" "o"] -] +[ + ["he" "he" "h" "e"] + ["wo" "wo" "w" "o"] +] -[ - ["he" "h"] - ["wo" "w"] -] +[ + ["he" "h"] + ["wo" "w"] +] -[] +[] h[e]ll[o] w[o]rld h[e]ll[o] world @@ -1905,94 +1918,99 @@ axdefgﬗꭖϡ --concat-- hello world --crypto_sign and crypto_sign_verify-- -valid signature: (true) +valid signature: (true) --encrypt and decrypt-- symmetric key encryption decrypted: hello public key encryption decrypted: hello --print-- -[ - 0 - 1 - 10 - 12 - 100 - 120 - 122 - 1000 - 1000.123 - 10000 - 100000 - 0.1 - 0.01 - 0.001 - 0.0001 - 1e-05 - 1.23456789e-05 - 1.2345e-149 -] -[ - -0 - -1 - -10 - -12 - -100 - -120 - -122 - -1000 - -1000.123 - -10000 - -100000 - -0.1 - -0.01 - -0.001 - -0.0001 - -1e-05 - -1.23456789e-05 - -1.2345e-149 -] +[ + 0 + 1 + 10 + 12 + 100 + 120 + 122 + 1000 + 1000.123 + 10000 + 100000 + 0.1 + 0.01 + 0.001 + 0.0001 + 1e-05 + 1.23456789e-05 + 1.2345e-149 +] +[ + -0 + -1 + -10 + -12 + -100 + -120 + -122 + -1000 + -1000.123 + -10000 + -100000 + -0.1 + -0.01 + -0.001 + -0.0001 + -1e-05 + -1.23456789e-05 + -1.2345e-149 +] .infinity -(true) +(true) -(false) +(false) --total_size-- 10 --mutate-- -[ - 1 - {} - 3 - (and) - 5 - (reduce) - (get) - 8 - 4 - 10 - (values) - 12 - 13 - (assign) - (associate "a" 1 "b" 2) -] -[ - 1 - 2 - (-) - 4 - (associate "alpha" 5 "beta" 6) - (associate - "nest" - (associate - "count" - [7 8 9 (+)] - ) - "end" - [] - ) -] +[ + 1 + {} + 3 + 4 + 5 + 6 + 7 + 8 + (sin) + (call_container) + 11 + 12 + (target) + 14 + (associate + #b "a" + 1 + (>) + (reduce) + ) +] +[ + 1 + 2 + (+) + 4 + (associate "alpha" 5 "beta" 6) + (associate + (-) + (associate + "count" + [7 8 9] + ) + "end" + [10 11 (+)] + ) +] --commonality-- 3 15 @@ -2018,2256 +2036,2189 @@ decrypted: hello 3 1 --intersect-- -[ - 1 - (- 4 2) - {b 4} -] -(seq 2 1) -(parallel 2 (get_entity_comments) 1) -[ - 1 - 2 - 3 - {b 4} - (if - true - 1 - (parallel - (get_entity_comments) - #label-not-1 1 - ) - ) - [5 6] -] -[ - 1 - (associate "b" 4) -] -(replace 4 2 6 1 7) -[ - - ;comment 2 - ;comment 3 - 1 -] -[1 2 3] +[ + 1 + (- 4 2) + {b 4} +] +(seq 2 1) +(parallel 2 (get_entity_comments) 1) +[ + 1 + 2 + 3 + {b 4} + (if + true + 1 + (parallel + (get_entity_comments) + #label-not-1 1 + ) + ) + [5 6] +] +[ + 1 + (associate "b" 4) +] +(replace 4 2 6 1 7) +[ + + ;comment 2 + ;comment 3 + 1 +] +[1 2 3] --union-- -(seq 2 (get_entity_comments) 1 4 (get_entity_comments)) -[ - 1 - (- 4 2) - {a 3 b 4 c 3} -] -(parallel 2 (get_entity_comments) 1 4) -[ - 1 - 2 - 3 - {a 3 b 4 c 3} - (if - true - 1 - (parallel - (get_entity_comments) - #label-not-1 1 - ) - ) - [5 6] -] -[ - 1 - (associate "b" 4 "a" 3 "c" 3) -] -[3 4 2] -[3 2 4 3] -[ - - ;comment 1 - ;comment 2 - ;comment 3 - ;comment 4 - 1 - - ;comment x - 2 - 4 - 3 - 6 - 5 - 8 - 7 - 10 - 9 - 12 - 11 - 14 - 13 -] -[ - [1 2 3] -] - -[ - [1 2 3] -] - -(parallel - [1 2 3] -) +(seq 2 (get_entity_comments) 1 4 (get_entity_comments)) +[ + 1 + (- 4 2) + {a 3 b 4 c 3} +] +(parallel 2 (get_entity_comments) 1 4) +[ + 1 + 2 + 3 + {a 3 b 4 c 3} + (if + true + 1 + (parallel + (get_entity_comments) + #label-not-1 1 + ) + ) + [5 6] +] +[ + 1 + (associate "b" 4 "a" 3 "c" 3) +] +[3 4 2] +[3 2 4 3] +[ + + ;comment 1 + ;comment 2 + ;comment 3 + ;comment 4 + 1 + + ;comment x + 2 + 4 + 3 + 6 + 5 + 8 + 7 + 10 + 9 + 12 + 11 + 14 + 13 +] +[ + [1 2 3] +] + +[ + [1 2 3] +] + +(parallel + [1 2 3] +) --difference-- -(declare - {_ (null)} - (replace - _ - [] - (lambda - [ - a - 2 - c - 4 - d - 6 - q - 8 - e - 10 - f - 12 - g - 14 - ] - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - { - a 2 - c (get - (current_value 1) - "c" - ) - d 6 - e (get - (current_value 1) - "e" - ) - f (get - (current_value 1) - "f" - ) - g 14 - q 8 - } - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - [ - (get - (current_value 1) - 1 - ) - (get - (current_value 1) - 2 - ) - 6 - 8 - (get - (current_value 1) - 4 - ) - (get - (current_value 1) - 5 - ) - 14 - ] - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - { - a 2 - c (get - (current_value 1) - "c" - ) - d 6 - e (get - (current_value 1) - "e" - ) - f (get - (current_value 1) - "f" - ) - g 14 - q 8 - } - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - { - a 2 - g (get - (current_value 1) - "g" - ) - } - ) - ["g"] - (lambda - [ - (get - (current_value 1) - 0 - ) - 4 - ] - ) - ) -) -(declare - {_ (null)} - (replace - _ - [3] - (lambda - [ - (get - (current_value 1) - 0 - ) - 4 - ] - ) - [] - (lambda - (set_type - [ - a - 2 - g - (get - (current_value 1) - 3 - ) - ] - "associate" - ) - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - { - 2 (null) - 5 (null) - 6 (null) - a 1 - } - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - {2 (null) 5 (null) 6 (null)} - ) - ) -) -(declare - {_ (null)} - (replace - _ - [] - (lambda - {2 (null) 5 (null) 6 (null)} - ) - ) -) -(declare - {_ (null)} - (replace - _ - [1] - (lambda - [ - (get - (current_value 1) - 0 - ) - 4 - ] - ) - [] - (lambda - [ - 7 - (get - (current_value 1) - 1 - ) - ] - ) - ) -) -[ - 7 - [1 4] -] -(declare - {_ (null)} - (replace - _ - [1] - (lambda - [ - (get - (current_value 1) - 0 - ) - 4 - ] - ) - [0] - (lambda - (set_type - [7 8] - "+" - ) - ) - ) -) -[ - (+ 7 8) - [1 4] -] -(declare - {_ (null)} - (replace - _ - [1 0] - (lambda - [ - (get - (current_value 1) - 0 - ) - "x" - ] - ) - [1] - (lambda - [ - (get - (current_value 1) - 0 - ) - (get - (current_value 1) - 1 - ) - 4 - ] - ) - [] - (lambda - [ - 7 - (get - (current_value 1) - 1 - ) - ] - ) - ) -) -[ - 7 - [ - ["a" "x"] - 1 - 4 - ] -] +(declare + {_ (null)} + (replace + _ + [] + (lambda + [ + a + 2 + c + 4 + d + 6 + q + 8 + e + 10 + f + 12 + g + 14 + ] + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + { + a 2 + c (get + (current_value 1) + "c" + ) + d 6 + e (get + (current_value 1) + "e" + ) + f (get + (current_value 1) + "f" + ) + g 14 + q 8 + } + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + [ + (get + (current_value 1) + 1 + ) + (get + (current_value 1) + 2 + ) + 6 + 8 + (get + (current_value 1) + 4 + ) + (get + (current_value 1) + 5 + ) + 14 + ] + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + { + a 2 + c (get + (current_value 1) + "c" + ) + d 6 + e (get + (current_value 1) + "e" + ) + f (get + (current_value 1) + "f" + ) + g 14 + q 8 + } + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + { + a 2 + g (get + (current_value 1) + "g" + ) + } + ) + ["g"] + (lambda + [ + (get + (current_value 1) + 0 + ) + 4 + ] + ) + ) +) +(declare + {_ (null)} + (replace + _ + [3] + (lambda + [ + (get + (current_value 1) + 0 + ) + 4 + ] + ) + [] + (lambda + (set_type + [ + a + 2 + g + (get + (current_value 1) + 3 + ) + ] + "associate" + ) + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + { + 2 (null) + 5 (null) + 6 (null) + a 1 + } + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + {2 (null) 5 (null) 6 (null)} + ) + ) +) +(declare + {_ (null)} + (replace + _ + [] + (lambda + {2 (null) 5 (null) 6 (null)} + ) + ) +) +(declare + {_ (null)} + (replace + _ + [1] + (lambda + [ + (get + (current_value 1) + 0 + ) + 4 + ] + ) + [] + (lambda + [ + 7 + (get + (current_value 1) + 1 + ) + ] + ) + ) +) +[ + 7 + [1 4] +] +(declare + {_ (null)} + (replace + _ + [1] + (lambda + [ + (get + (current_value 1) + 0 + ) + 4 + ] + ) + [0] + (lambda + (set_type + [7 8] + "+" + ) + ) + ) +) +[ + (+ 7 8) + [1 4] +] +(declare + {_ (null)} + (replace + _ + [1 0] + (lambda + [ + (get + (current_value 1) + 0 + ) + "x" + ] + ) + [1] + (lambda + [ + (get + (current_value 1) + 0 + ) + (get + (current_value 1) + 1 + ) + 4 + ] + ) + [] + (lambda + [ + 7 + (get + (current_value 1) + 1 + ) + ] + ) + ) +) +[ + 7 + [ + ["a" "x"] + 1 + 4 + ] +] --mix-- -[3.5 5 7.5 10 11.5 13.5] -[ - - ;comment 1 - ;comment 2 - ;comment 3 - ;comment 4 - 1 - 3.5 - 5.5 - 7.5 - 9.5 - 11.5 - 13.5 -] -[ - 1 - 5 - 2.5 - (associate "a" 3 "b" 4) - (lambda - (if - true - 1 - (parallel (get_entity_comments) 1) - ) - ) - [5 6] -] -[ - 1 - 5 - 2.5 - (associate) - (lambda - (if - true - 1 - (seq (get_entity_comments)) - ) - ) - [5 6] -] -[ - (true) - 3.5 - 5.5 - 7.5 - 9.5 - 11.5 - 13.5 -] -[ - 2 - 4 - 6 - 7 - 9 - 11 - 14 - 13 -] -1 +[ + 1 + 4 + 5.5 + 7.5 + 9.5 + 11.5 + 13.5 +] +[ + + ;comment 1 + ;comment 2 + ;comment 3 + ;comment 4 + 1 + 4 + 5.5 + 7.5 + 9.5 + 11.5 + 13.5 +] +[ + 1 + 5 + 3 + 2 + (associate "a" 3 "b" 4) + (lambda + (if + true + 1 + (parallel + (get_entity_comments) + 1 + (lambda + (print + [2 9] + ) + ) + ) + ) + ) + [5 6] +] +[ + 1 + 2.5 + (associate "b" 4) + (lambda + (if + true + 1 + (seq + (get_entity_comments) + (lambda + (print + [9] + ) + ) + 1 + ) + ) + ) + [5 6] +] +[ + 2 + 3.5 + 5.5 + 7.5 + 9.5 + 11.5 + 13.5 +] +[ + (true) + 2 + 4 + 3 + 6 + 5 + 8 + 10 + 9 + 12 + 11 +] 1 +4 2.5 2.5 -abcdexyz -abcoxyz -abcemxyz +abceomxyz +abcmxyz +abcmxyz --mix_labels-- -[ - 1 - #mixtest1 2 - #mixtest2 - (associate "a" 3 "b" 4) - (lambda - (if - #mixtest3 true - 1 - (parallel - (get_entity_comments) - #mixtest4 1 - ) - ) - ) - [5 6] -] +[ + 1 + #mixtest1 2 + #mixtest2 + (associate "a" 3 "b" 4) + (lambda + (if + #mixtest3 true + 1 + (parallel + (get_entity_comments) + #mixtest4 1 + ) + ) + ) + [5 6] +] --total_entity_size-- 79 87 --flatten_entity-- -0.04246645104716629 -QjXT3 -0.6062880615697428 -0.6062880615697428 -0.12674824318312972 -0.12674824318312972 +0.40971200496539806 +iA;@VOV- +0.7136950384635786 +0.7136950384635786 +0.6522822782263927 +0.6522822782263927 flatten restore with seeds test -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a (rand) - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity ")m4+T3") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "DeepRand") - (lambda - (parallel - ##a (rand) - ) - ) - ) - ) - "w!HǰF" - ) - new_entity -) -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a (rand) - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "&)W3BT3") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "DeepRand") - (lambda - (parallel - ##a (rand) - ) - ) - ) - ) - "w!HǰF" - ) - new_entity -) -(declare - {_ (null) new_entity (null)} - (clone_entities _ new_entity) -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a (rand) + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "£=mVOV-") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "DeepRand") + (lambda + (parallel + ##a (rand) + ) + ) + ) + ) + "aE&K\"(X&\0" + ) + new_entity +) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a (rand) + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "M:pVVOV-") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "DeepRand") + (lambda + (parallel + ##a (rand) + ) + ) + ) + ) + "aE&K\"(X&\0" + ) + new_entity +) +(declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) flatten restore without seeds test -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a (rand) - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (create_entities - (append new_entity "DeepRand") - (lambda - (parallel - ##a (rand) - ) - ) - ) - new_entity -) -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a (rand) - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "o/bzxk;1") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "DeepRand") - (lambda - (parallel - ##a (rand) - ) - ) - ) - ) - "{>L|\\ " - ) - new_entity -) -(declare - {_ (null) new_entity (null)} - (clone_entities _ new_entity) -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a (rand) + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (create_entities + (append new_entity "DeepRand") + (lambda + (parallel + ##a (rand) + ) + ) + ) + new_entity +) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a (rand) + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "{'IC") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "DeepRand") + (lambda + (parallel + ##a (rand) + ) + ) + ) + ) + "5z^\rF/VQ" + ) + new_entity +) +(declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) flatten restore with parallel -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a (rand) - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity ")m4+T3") - ||(parallel - (set_entity_rand_seed - (first - (create_entities - (append new_entity "DeepRand") - (lambda - (parallel - ##a (rand) - ) - ) - ) - ) - "w!HǰF" - ) - ) - new_entity -) -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a (rand) - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "&)W3BT3") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "DeepRand") - (lambda - (parallel - ##a (rand) - ) - ) - ) - ) - "w!HǰF" - ) - new_entity -) -(declare - {_ (null) new_entity (null)} - (clone_entities _ new_entity) -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a (rand) + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "£=mVOV-") + ||(parallel + (set_entity_rand_seed + (first + (create_entities + (append new_entity "DeepRand") + (lambda + (parallel + ##a (rand) + ) + ) + ) + ) + "aE&K\"(X&\0" + ) + ) + new_entity +) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a (rand) + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "M:pVVOV-") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "DeepRand") + (lambda + (parallel + ##a (rand) + ) + ) + ) + ) + "aE&K\"(X&\0" + ) + new_entity +) +(declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) --mutate_entity-- -[ - (/) - a - (keep) - 4 - 5 - 6 - 7 - 8 - (keep) - 10 - 11 - 12 - 1 - 14 - (call_sandboxed) -] - -[ - (substr) - (contains_value) - (query_among) - (get) - 5 - 6 - 7 - 8 - 1 - 10 - 11 - 12 - 13 - (store) - (associate) -] - -[ - 1 - 2 - 3 - 4 - (+) - 6 - (*) - (+) - 9 - (-) - (*) - (-) - 13 - 14 - (associate "a" 1 "b") -] +[ + (>) + (first) + 3 + 0.5226269445601921 + 5 + [] + 7 + 8 + (query_not_equals) + 10 + (map) + [] + 13 + (ceil) + (associate "a" (contains_value) "b" (current_index)) +] + +[ + (floor) + 2 + 7.444375373567071 + 4 + (get_value) + 6 + (query_min) + 8 + (lambda) + (filter) + 11 + 12 + 13 + 119.55976171274764 + (associate "a" (query_less_or_equal_to) "b" 2) +] + +[ + 1 + 2 + (+) + 4 + (-) + 6 + 7 + (-) + (*) + (+) + (+) + 12 + (+) + (-) + (associate "a" 1 (+) (+)) + (*) +] --commonality_entities-- 73.3678794503212 --edit_distance_entities-- 19.264241099357605 --intersect_entities-- -(associate "b" 4) +(associate "b" 4) MergeEntityChild2 -(associate "p" 3 "q" 4) +(associate "p" 3 "q" 4) MergeEntityChild1 -(associate "x" 3 "y" 4) -_2710920158 -(associate "E" 3 "F" 4) -_1797215995 -(associate "e" 3 "f" 4) +(associate "x" 3 "y" 4) +_1651806471 +(associate "e" 3 "f" 4) +_3130331116 +(associate "E" 3 "F" 4) --union_entities-- -(associate "b" 4 "a" 3 "c" 3) +(associate "b" 4 "a" 3 "c" 3) MergeEntityChild2 -(associate - "p" - 3 - "q" - 4 - "u" - 5 - "v" - 6 - "w" - 7 -) +(associate + "p" + 3 + "q" + 4 + "u" + 5 + "v" + 6 + "w" + 7 +) MergeEntityChild1 -(associate "x" 3 "y" 4 "z" 5) -_2710920158 -(associate - "E" - 3 - "F" - 4 - "G" - 5 - "H" - 6 -) -_1797215995 -(associate - "e" - 3 - "f" - 4 - "g" - 5 - "h" - 6 -) -(parallel - ##p - ["_525077026" "_525077026" "_4145172689" "_4145172689"] -) -_525077026 -(associate - "E" - 3 - "F" - 4 - "G" - 5 - "H" - 6 -) -_4145172689 -(associate - "e" - 3 - "f" - 4 - "g" - 5 - "h" - 6 -) +(associate "x" 3 "y" 4 "z" 5) +_1651806471 +(associate + "e" + 3 + "f" + 4 + "g" + 5 + "h" + 6 +) +_3130331116 +(associate + "E" + 3 + "F" + 4 + "G" + 5 + "H" + 6 +) +(parallel + ##p + ["_2325275497" "_2325275497" "_2973704165" "_2973704165"] +) +_2973704165 +(associate + "e" + 3 + "f" + 4 + "g" + 5 + "h" + 6 +) +_2325275497 +(associate + "E" + 3 + "F" + 4 + "G" + 5 + "H" + 6 +) --difference_entities-- -(declare - {_ (null) new_entity (null)} - (clone_entities _ new_entity) -) -(declare - {_ (null) new_entity (null)} - (assign - "new_entity" - (first - (create_entities - new_entity - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - (set_type - [ - "c" - 3 - (get - (current_value 1) - 2 - ) - (get - (current_value 1) - 3 - ) - ] - "associate" - ) - ) - ) - ) - ) - { - _ (retrieve_entity_root _) - } - ) - ) - ) - ) - (create_entities - (append new_entity "MergeEntityChild1") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - (set_type - [ - (get - (current_value 1) - 0 - ) - (get - (current_value 1) - 1 - ) - (get - (current_value 1) - 2 - ) - (get - (current_value 1) - 3 - ) - "z" - 5 - ] - "associate" - ) - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "MergeEntityChild1") - ) - } - ) - ) - (create_entities - (append new_entity "MergeEntityChild2") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - (set_type - [ - (get - (current_value 1) - 0 - ) - (get - (current_value 1) - 1 - ) - (get - (current_value 1) - 2 - ) - (get - (current_value 1) - 3 - ) - "u" - 5 - "v" - 6 - "w" - 7 - ] - "associate" - ) - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "MergeEntityChild2") - ) - } - ) - ) - (create_entities - (append new_entity "_3562807220") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - (set_type - [ - (get - (current_value 1) - 0 - ) - (get - (current_value 1) - 1 - ) - (get - (current_value 1) - 2 - ) - (get - (current_value 1) - 3 - ) - "G" - 5 - "H" - 6 - ] - "associate" - ) - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_3562807220") - ) - } - ) - ) - (create_entities - (append new_entity "_1744305324") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - (set_type - [ - (get - (current_value 1) - 0 - ) - (get - (current_value 1) - 1 - ) - (get - (current_value 1) - 2 - ) - (get - (current_value 1) - 3 - ) - ] - "associate" - ) - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_1744305324") - ) - } - ) - ) - new_entity -) -_830877783 -["DiffEntityChild1" "OnlyIn2" "_445026204" "_1497566482"] -(declare - {_ (null) new_entity (null)} - (assign - "new_entity" - (first - (create_entities - new_entity - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - b (get - (current_value 1) - "b" - ) - c 3 - } - ) - ) - ) - ) - { - _ (retrieve_entity_root _) - } - ) - ) - ) - ) - (create_entities - (append new_entity "DiffEntityChild1") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - x (get - (current_value 1) - "x" - ) - y (get - (current_value 1) - "y" - ) - z 5 - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "DiffEntityChild1") - ) - } - ) - ) - (create_entities - (append new_entity "OnlyIn2") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - {o 6} - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "OnlyIn2") - ) - } - ) - ) - (create_entities - (append new_entity "_445026204") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - E (get - (current_value 1) - "E" - ) - F (get - (current_value 1) - "F" - ) - G 5 - H 6 - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_445026204") - ) - } - ) - ) - (create_entities - (append new_entity "_1497566482") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - e (get - (current_value 1) - "e" - ) - f (get - (current_value 1) - "f" - ) - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_1497566482") - ) - } - ) - ) - (clone_entities - (append - _ - ["DiffEntityChild1" "DiffEntityChild2"] - ) - (append - new_entity - ["DiffEntityChild1" "DiffEntityChild2"] - ) - ) - new_entity -) -new_entity: _2654358599 -new_entity root: {b 4 c 3} +(declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) +(declare + {_ (null) new_entity (null)} + (assign + "new_entity" + (first + (create_entities + new_entity + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + (set_type + [ + "c" + 3 + (get + (current_value 1) + 2 + ) + (get + (current_value 1) + 3 + ) + ] + "associate" + ) + ) + ) + ) + ) + { + _ (retrieve_entity_root _) + } + ) + ) + ) + ) + (create_entities + (append new_entity "MergeEntityChild1") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + (set_type + [ + (get + (current_value 1) + 0 + ) + (get + (current_value 1) + 1 + ) + (get + (current_value 1) + 2 + ) + (get + (current_value 1) + 3 + ) + "z" + 5 + ] + "associate" + ) + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "MergeEntityChild1") + ) + } + ) + ) + (create_entities + (append new_entity "MergeEntityChild2") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + (set_type + [ + (get + (current_value 1) + 0 + ) + (get + (current_value 1) + 1 + ) + (get + (current_value 1) + 2 + ) + (get + (current_value 1) + 3 + ) + "u" + 5 + "v" + 6 + "w" + 7 + ] + "associate" + ) + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "MergeEntityChild2") + ) + } + ) + ) + (create_entities + (append new_entity "_2565637960") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + (set_type + [ + (get + (current_value 1) + 0 + ) + (get + (current_value 1) + 1 + ) + (get + (current_value 1) + 2 + ) + (get + (current_value 1) + 3 + ) + "G" + 5 + "H" + 6 + ] + "associate" + ) + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_2565637960") + ) + } + ) + ) + (create_entities + (append new_entity "_407614051") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + (set_type + [ + (get + (current_value 1) + 0 + ) + (get + (current_value 1) + 1 + ) + (get + (current_value 1) + 2 + ) + (get + (current_value 1) + 3 + ) + ] + "associate" + ) + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_407614051") + ) + } + ) + ) + new_entity +) +_3532185687 +["DiffEntityChild1" "OnlyIn2" "_3626604918" "_3823131681"] +(declare + {_ (null) new_entity (null)} + (assign + "new_entity" + (first + (create_entities + new_entity + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + b (get + (current_value 1) + "b" + ) + c 3 + } + ) + ) + ) + ) + { + _ (retrieve_entity_root _) + } + ) + ) + ) + ) + (create_entities + (append new_entity "DiffEntityChild1") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + x (get + (current_value 1) + "x" + ) + y (get + (current_value 1) + "y" + ) + z 5 + } + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "DiffEntityChild1") + ) + } + ) + ) + (create_entities + (append new_entity "OnlyIn2") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + {o 6} + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "OnlyIn2") + ) + } + ) + ) + (create_entities + (append new_entity "_3626604918") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + E (get + (current_value 1) + "E" + ) + F (get + (current_value 1) + "F" + ) + G 5 + H 6 + } + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_3626604918") + ) + } + ) + ) + (create_entities + (append new_entity "_3823131681") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + e (get + (current_value 1) + "e" + ) + f (get + (current_value 1) + "f" + ) + } + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_3823131681") + ) + } + ) + ) + (clone_entities + (append + _ + ["DiffEntityChild1" "DiffEntityChild2"] + ) + (append + new_entity + ["DiffEntityChild1" "DiffEntityChild2"] + ) + ) + new_entity +) +new_entity: _1461236888 +new_entity root: {b 4 c 3} DiffEntityChild1 root: -{x 3 y 4 z 5} -contained_entities new_entity: ["DiffEntityChild1" "OnlyIn2" "_445026204" "_1497566482"] +{x 3 y 4 z 5} +contained_entities new_entity: ["DiffEntityChild1" "OnlyIn2" "_3626604918" "_3823131681"] difference between DiffEntity2 and new_entity: -(declare - {_ (null) new_entity (null)} - (assign - "new_entity" - (first - (create_entities - new_entity - (call - (lambda - (declare - {_ (null)} - (replace _) - ) - ) - { - _ (retrieve_entity_root _) - } - ) - ) - ) - ) - (create_entities - (append new_entity "_445026204") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - E (null) - F (null) - G (get - (current_value 1) - "G" - ) - H (get - (current_value 1) - "H" - ) - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_445026204") - ) - } - ) - ) - (create_entities - (append new_entity "_1497566482") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - {e (null) f (null)} - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_1497566482") - ) - } - ) - ) - (clone_entities - (append _ "DiffEntityChild1") - (append new_entity "DiffEntityChild1") - ) - (clone_entities - (append _ "OnlyIn2") - (append new_entity "OnlyIn2") - ) - new_entity -) -(declare - {_ (null) new_entity (null)} - (assign - "new_entity" - (first - (create_entities - new_entity - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - b (get - (current_value 1) - "b" - ) - c 3 - } - ) - ) - ) - ) - { - _ (retrieve_entity_root _) - } - ) - ) - ) - ) - (create_entities - (append new_entity "OnlyIn2") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - {o 6} - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "OnlyIn2") - ) - } - ) - ) - (create_entities - (append new_entity "_2860796594") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - E (get - (current_value 1) - "E" - ) - F (get - (current_value 1) - "F" - ) - G 5 - H 6 - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_2860796594") - ) - } - ) - ) - (create_entities - (append new_entity "_2612373163") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - e (get - (current_value 1) - "e" - ) - f (get - (current_value 1) - "f" - ) - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_2612373163") - ) - } - ) - ) - (clone_entities - (append _ "DiffEntityChild1") - (append new_entity "DiffEntityChild1") - ) - new_entity -) +(declare + {_ (null) new_entity (null)} + (assign + "new_entity" + (first + (create_entities + new_entity + (call + (lambda + (declare + {_ (null)} + (replace _) + ) + ) + { + _ (retrieve_entity_root _) + } + ) + ) + ) + ) + (create_entities + (append new_entity "_3626604918") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + E (null) + F (null) + G (get + (current_value 1) + "G" + ) + H (get + (current_value 1) + "H" + ) + } + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_3626604918") + ) + } + ) + ) + (create_entities + (append new_entity "_3823131681") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + {e (null) f (null)} + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_3823131681") + ) + } + ) + ) + (clone_entities + (append _ "DiffEntityChild1") + (append new_entity "DiffEntityChild1") + ) + (clone_entities + (append _ "OnlyIn2") + (append new_entity "OnlyIn2") + ) + new_entity +) +(declare + {_ (null) new_entity (null)} + (assign + "new_entity" + (first + (create_entities + new_entity + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + b (get + (current_value 1) + "b" + ) + c 3 + } + ) + ) + ) + ) + { + _ (retrieve_entity_root _) + } + ) + ) + ) + ) + (create_entities + (append new_entity "OnlyIn2") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + {o 6} + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "OnlyIn2") + ) + } + ) + ) + (create_entities + (append new_entity "_1985995361") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + { + E 3 + F 4 + G 5 + H 6 + } + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_1985995361") + ) + } + ) + ) + (create_entities + (append new_entity "_2783372341") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + {e 3 f 4} + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_2783372341") + ) + } + ) + ) + (clone_entities + (append _ "DiffEntityChild1") + (append new_entity "DiffEntityChild1") + ) + new_entity +) new_entity: DiffContainerReconstructed -new_entity root: {b 4 c 3} +new_entity root: {b 4 c 3} DiffEntityChild1 root: -{x 3 y 4 z 6} -contained_entities new_entity: ["OnlyIn2" "_2860796594" "_2612373163" "DiffEntityChild1"] +{x 3 y 4 z 6} +contained_entities new_entity: ["OnlyIn2" "_1985995361" "_2783372341" "DiffEntityChild1"] difference between DiffContainer and DiffEntity2: -(declare - {_ (null) new_entity (null)} - (assign - "new_entity" - (first - (create_entities - new_entity - (call - (lambda - (declare - {_ (null)} - (replace _) - ) - ) - { - _ (retrieve_entity_root _) - } - ) - ) - ) - ) - (create_entities - (append new_entity "_2860796594") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - { - E (null) - F (null) - G (get - (current_value 1) - "G" - ) - H (get - (current_value 1) - "H" - ) - } - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_2860796594") - ) - } - ) - ) - (create_entities - (append new_entity "_2612373163") - (call - (lambda - (declare - {_ (null)} - (replace - _ - [] - (lambda - {e (null) f (null)} - ) - ) - ) - ) - { - _ (retrieve_entity_root - (append _ "_2612373163") - ) - } - ) - ) - (clone_entities - (append _ "OnlyIn2") - (append new_entity "OnlyIn2") - ) - (clone_entities - (append _ "DiffEntityChild1") - (append new_entity "DiffEntityChild1") - ) - new_entity -) +(declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) --mix_entities-- -(associate "b" 4 "a" 3) +(associate "b" 4) MergeEntityChild2 -(associate - "p" - 3 - "q" - 4 - "u" - 5 - "v" - 6 -) +(associate + "p" + 3 + "q" + 4 + "u" + 5 + "v" + 6 + "w" + 7 +) MergeEntityChild1 -(associate "x" 3 "y" 4) -_2710920158 -(associate "E" 3 "F" 4 "H" 6) -_1797215995 -(associate "e" 3 "f" 4 "h" 6) +(associate "x" 3 "y" 4 "z" 5) +_1651806471 +(associate "e" 3 "f" 4 "h" 6) +_3130331116 +(associate "E" 3 "F" 4 "G" 5) --get_entity_comments-- -Full test -This is a suite of unit tests. +Full test +This is a suite of unit tests. This is the second line of the unit test description. this is a fully described entity -{ - ^containervar "a variable accessible to contained entities" - foo "the function foo" - get_api "returns the api details" - publicvar "some public variable" -} -[ - { - x ["the value of x\r\nthe default value of x" 1] - y ["the value of y" 2] - } - "a number representing the sum" -] -{ - description "this is a fully described entity" - labels { - ^containervar {description "a variable accessible to contained entities" parameters (null)} - foo { - description "the function foo" - parameters [ - { - x ["the value of x\r\nthe default value of x" 1] - y ["the value of y" 2] - } - "a number representing the sum" - ] - } - get_api {description "returns the api details" parameters (null)} - publicvar {description "some public variable" parameters (null)} - } -} +{ + ^containervar "a variable accessible to contained entities" + foo "the function foo" + get_api "returns the api details" + publicvar "some public variable" +} +[ + { + x ["the value of x\r\nthe default value of x" 1] + y ["the value of y\r\n" 2] + } + "a number representing the sum" +] +{ + description "this is a fully described entity" + labels { + ^containervar {description "a variable accessible to contained entities" parameters (null)} + foo { + description "the function foo" + parameters [ + { + x ["the value of x\r\nthe default value of x" 1] + y ["the value of y\r\n" 2] + } + "a number representing the sum" + ] + } + get_api {description "returns the api details" parameters (null)} + publicvar {description "some public variable" parameters (null)} + } +} --retrieve_entity_root-- -[ - 1 - 2 - ##three 3 -] -[ - 1 - 2 - #three 3 -] -[ - 1 - 2 - ##three 3 -] +[ + 1 + 2 + ##three 3 +] +[ + 1 + 2 + #three 3 +] +[ + 1 + 2 + ##three 3 +] --assign_entity_roots-- -[4 5 6] +[4 5 6] --accum_entity_roots-- -(null - #a 1 - #b 2 - #c 3 -) -(null - #c 3 -) +(null + #a 1 + #b 2 + #c 3 +) +(null + #c 3 +) --get_entity_rand_seed-- -`oWw -0.6175157570664995 -{hg5@)޳ +3yr>89012345 +0.812564396753873 +adx)5 iD --set_entity_rand_seed-- -0.14708866302817414 -0.14708866302817414 +0.21086495653466275 +0.21086495653466275 deep sets -0.07779057832369474 -0.07779057832369474 +0.6853081112330822 +0.6853081112330822 --get_entity_root_permission-- -(false) +(false) --set_entity_root_permission-- RootTest -1730659256.490269 -(true) +1731075188.87531 +(true) RootTest (null) -(false) +(false) --create_entities-- -["MyLibrary"] +["MyLibrary"] --nested create_entities-- -["Child1" "Child2"] -["MultipleTest1"] +["Child1" "Child2"] +["MultipleTest1"] -["MultipleTest2"] +["MultipleTest2"] --clone_entities-- -["MyNewLibrary"] +["MyNewLibrary"] --move_entities-- -["MyLibrary2"] +["MyLibrary2"] --destroy_entities-- -[ - "MergeEntity1" - "MergeEntity2" - "FlattenTest" - "_1451190156" - "_1989294406" - "_3643253163" - "_2827522608" - "_3380015993" - "_2364738013" - "MutateEntity" - "MutatedEntity" - "MutatedEntity2" - "MutatedEntity3" - "AndedEntities" - "OredEntities" - "ComplexMergeEntity1" - "ComplexMergeEntity2" - "ComplexOredEntities" - "_830877783" - "DiffEntity1" - "DiffEntity2" - "_2654358599" - "DiffContainer" - "DiffContainerReconstructed" - "MixedEntities" - "descriptive_entity" - "SetGetCodeTest" - "AER_test" - "AER_test_2" - "RandTest" - "RootTest" - "MyNewLibrary" - "EntityWithChildren" - "MultipleTest1" - "MultipleTest2" - "MyLibrary2" -] -[ - "MergeEntity1" - "MergeEntity2" - "FlattenTest" - "_1451190156" - "_1989294406" - "_3643253163" - "_2827522608" - "_3380015993" - "_2364738013" - "MutateEntity" - "MutatedEntity" - "MutatedEntity2" - "MutatedEntity3" - "AndedEntities" - "OredEntities" - "ComplexMergeEntity1" - "ComplexMergeEntity2" - "ComplexOredEntities" - "_830877783" - "DiffEntity1" - "DiffEntity2" - "_2654358599" - "DiffContainer" - "DiffContainerReconstructed" - "MixedEntities" - "descriptive_entity" - "SetGetCodeTest" - "AER_test" - "AER_test_2" - "RandTest" - "RootTest" - "MyNewLibrary" - "EntityWithChildren" - "MultipleTest1" - "MultipleTest2" -] -[ - "MergeEntity1" - "MergeEntity2" - "FlattenTest" - "_1451190156" - "_1989294406" - "_3643253163" - "_2827522608" - "_3380015993" - "_2364738013" - "MutateEntity" - "MutatedEntity" - "MutatedEntity2" - "MutatedEntity3" - "AndedEntities" - "OredEntities" - "ComplexMergeEntity1" - "ComplexMergeEntity2" - "ComplexOredEntities" - "_830877783" - "DiffEntity1" - "DiffEntity2" - "_2654358599" - "DiffContainer" - "DiffContainerReconstructed" - "MixedEntities" - "descriptive_entity" - "SetGetCodeTest" - "AER_test" - "AER_test_2" - "RandTest" - "RootTest" - "MyNewLibrary" - "EntityWithChildren" -] +[ + "MergeEntity1" + "MergeEntity2" + "FlattenTest" + "_3220334892" + "_2587601847" + "_570580630" + "_4288357968" + "_3069907149" + "_350559405" + "MutateEntity" + "MutatedEntity" + "MutatedEntity2" + "MutatedEntity3" + "AndedEntities" + "OredEntities" + "ComplexMergeEntity1" + "ComplexMergeEntity2" + "ComplexOredEntities" + "_3532185687" + "DiffEntity1" + "DiffEntity2" + "_1461236888" + "DiffContainer" + "DiffContainerReconstructed" + "MixedEntities" + "descriptive_entity" + "SetGetCodeTest" + "AER_test" + "AER_test_2" + "RandTest" + "RootTest" + "MyNewLibrary" + "EntityWithChildren" + "MultipleTest1" + "MultipleTest2" + "MyLibrary2" +] +[ + "MergeEntity1" + "MergeEntity2" + "FlattenTest" + "_3220334892" + "_2587601847" + "_570580630" + "_4288357968" + "_3069907149" + "_350559405" + "MutateEntity" + "MutatedEntity" + "MutatedEntity2" + "MutatedEntity3" + "AndedEntities" + "OredEntities" + "ComplexMergeEntity1" + "ComplexMergeEntity2" + "ComplexOredEntities" + "_3532185687" + "DiffEntity1" + "DiffEntity2" + "_1461236888" + "DiffContainer" + "DiffContainerReconstructed" + "MixedEntities" + "descriptive_entity" + "SetGetCodeTest" + "AER_test" + "AER_test_2" + "RandTest" + "RootTest" + "MyNewLibrary" + "EntityWithChildren" + "MultipleTest1" + "MultipleTest2" +] +[ + "MergeEntity1" + "MergeEntity2" + "FlattenTest" + "_3220334892" + "_2587601847" + "_570580630" + "_4288357968" + "_3069907149" + "_350559405" + "MutateEntity" + "MutatedEntity" + "MutatedEntity2" + "MutatedEntity3" + "AndedEntities" + "OredEntities" + "ComplexMergeEntity1" + "ComplexMergeEntity2" + "ComplexOredEntities" + "_3532185687" + "DiffEntity1" + "DiffEntity2" + "_1461236888" + "DiffContainer" + "DiffContainerReconstructed" + "MixedEntities" + "descriptive_entity" + "SetGetCodeTest" + "AER_test" + "AER_test_2" + "RandTest" + "RootTest" + "MyNewLibrary" + "EntityWithChildren" +] --load-- -{ - a #a 1 - b #b (true) - c #c 0.1 - d #d 100000000 - hello #hello - (print "hello\n") -} +{ + a #a 1 + b #b (true) + c #c 0.1 + d #d 100000000 + hello #hello + (print "hello\n") +} load from .json: -[ - {a 3 b 4} - {c "c" d (null)} -] +[ + {a 3 b 4} + {c "c" d (null)} +] load from .yaml: -[ - { - a 123 - b "ABC" - c 123.45 - d "true" - } -] +[ + { + a 123 + b "ABC" + c 123.45 + d "true" + } +] --load_entity-- load from .amlg: hello -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - { - a ##a 1 - b ##b (true) - c ##c 0.1 - d ##d 100000000 - hello ##hello - (print "hello\n") - } - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "qE9fDS") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "submoduletest") - (lambda - (parallel - ##a 7 - ##hello - (print "sub hello\n") - ) - ) - ) - ) - "p54֫-P:" - ) - (set_entity_rand_seed - (first - (create_entities - (append new_entity "submoduletest2") - (lambda - (parallel - ##a 8 - ##hello - (print "sub hello 2\n") - ) - ) - ) - ) - "6ʊ:R9 Y" - ) - new_entity -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + { + a ##a 1 + b ##b (true) + c ##c 0.1 + d ##d 100000000 + hello ##hello + (print "hello\n") + } + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "X~wb3") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "submoduletest") + (lambda + (parallel + ##a 7 + ##hello + (print "sub hello\n") + ) + ) + ) + ) + "DA30W^vha&" + ) + (set_entity_rand_seed + (first + (create_entities + (append new_entity "submoduletest2") + (lambda + (parallel + ##a 8 + ##hello + (print "sub hello 2\n") + ) + ) + ) + ) + "= \0Fyf@)" + ) + new_entity +) persistent loads -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a 8 - ##hello - (print "hello\n") - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "++X¶۵6") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "NewModule") - (lambda - (associate "a" 1 "b" 2) - ) - ) - ) - "W[x2S0~," - ) - (set_entity_rand_seed - (first - (create_entities - (append new_entity "psm") - (lambda - (parallel - ##a 5 - ##hello - (print "hello from psm\n") - ) - ) - ) - ) - "h𒂘O" - ) - new_entity -) -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - (parallel - ##a 1 - ##hello - (print "hello\n") - ) - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "++X¶۵6") - (set_entity_rand_seed - (first - (create_entities - (append new_entity "psm") - (lambda - (parallel - ##a 8 - ##hello - (print "hello from psm\n") - ) - ) - ) - ) - "h𒂘O" - ) - new_entity -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a 8 + ##hello + (print "hello\n") + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "1a2.Ww") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "NewModule") + (lambda + (associate "a" 1 "b" 2) + ) + ) + ) + "-O[3yCŒ" + ) + (set_entity_rand_seed + (first + (create_entities + (append new_entity "psm") + (lambda + (parallel + ##a 5 + ##hello + (print "hello from psm\n") + ) + ) + ) + ) + "&$ܴ@n>\"FN" + ) + new_entity +) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + (parallel + ##a 1 + ##hello + (print "hello\n") + ) + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "1a2.Ww") + (set_entity_rand_seed + (first + (create_entities + (append new_entity "psm") + (lambda + (parallel + ##a 8 + ##hello + (print "hello from psm\n") + ) + ) + ) + ) + "&$ܴ@n>\"FN" + ) + new_entity +) Load Root: PersistTreeRoot Load Inter: -["PersistTreeRoot" "PersistTreeInter"] +["PersistTreeRoot" "PersistTreeInter"] Load Leaf: -["PersistTreeRoot" "PersistTreeInter" "PersistTreeLeaf"] +["PersistTreeRoot" "PersistTreeInter" "PersistTreeLeaf"] Root contained: -["PersistTreeInter"] +["PersistTreeInter"] Root b: 2 Inter contained: -["PersistTreeLeaf"] +["PersistTreeLeaf"] Leaf f: 2 Leaf f: 6 --store-- -[1 2 3 4] -(parallel - #".#blah" 1 -) +[1 2 3 4] +(parallel + #".#blah" 1 +) retrieved: 1 loaded from file: -(parallel - #".#blah" 1 -) +(parallel + #".#blah" 1 +) retrieved: 1 --store other file formats--- [This is text!] -(seq - (print "hello") -) - -contained entities in quackers before file: ["!@#$%^&*)(_+=-'][{}.marbles" "buklulu is good.amlg"] - -contained entity in quackers2 loaded back from file: ["buklulu is good.amlg" "!@#$%^&*)(_+=-'][{}.marbles"] - -[ - [6.4 2.8 5.6 2.2 "virginica"] - [4.9 2.5 4.5 1.7 "virg\"inica"] - [(null)] - [(null) (null) (null) (null)] - [4.9 3.1 1.5 0.1 "set\nosa" 3] - [4.4 3.2 1.3 0.2 "setosa"] -] +(seq + (print "hello") +) + +contained entities in quackers before file: ["!@#$%^&*)(_+=-'][{}.marbles" "buklulu is good.amlg"] + +contained entity in quackers2 loaded back from file: ["buklulu is good.amlg" "!@#$%^&*)(_+=-'][{}.marbles"] + +[ + [6.4 2.8 5.6 2.2 "virginica"] + [4.9 2.5 4.5 1.7 "virg\"inica"] + [(null)] + [(null) (null) (null) (null)] + [4.9 3.1 1.5 0.1 "set\nosa" 3] + [4.4 3.2 1.3 0.2 "setosa"] +] --store_entity-- store to .amlg: -2 -2 -Compression difference: (declare - {_ (null) new_entity (null)} - (clone_entities _ new_entity) -) - -Compression difference: (declare - {_ (null) new_entity (null)} - (clone_entities _ new_entity) -) +2 +2 +Compression difference: (declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) + +Compression difference: (declare + {_ (null) new_entity (null)} + (clone_entities _ new_entity) +) store to .json in amlg format -[ - {a 3 b 4} - {c "c" d (null)} -] +[ + {a 3 b 4} + {c "c" d (null)} +] store to .json normally -[ - {a 3 b 4} - {c "c" d (null)} -] +[ + {a 3 b 4} + {c "c" d (null)} +] --contains_entity-- -(true) +(true) -(false) +(false) --contained_entities-- -[ - "Child1" - "Child2" - "Child3" - "Child4" - "Child5" - "Child6" - "Child7" -] +[ + "Child1" + "Child2" + "Child3" + "Child4" + "Child5" + "Child6" + "Child7" +] --query_select-- -["Child1" "Child2" "Child3"] -["Child2" "Child3" "Child4"] -["Child3" "Child4" "Child5" "Child6" "Child7"] -["Child1" "Child5"] -["Child3" "Child4"] -["Child6" "Child7"] -["Child2" "Child3" "Child4" "Child7"] -["Child1" "Child2" "Child3" "Child7"] -["Child4" "Child6"] +["Child1" "Child2" "Child3"] +["Child2" "Child3" "Child4"] +["Child3" "Child4" "Child5" "Child6" "Child7"] +["Child1" "Child5"] +["Child3" "Child4"] +["Child6" "Child7"] +["Child1" "Child2" "Child6" "Child7"] +["Child2" "Child3" "Child5" "Child6"] +["Child4" "Child6"] --query_sample-- -["Child2"] -["Child1" "Child1"] -["Child6"] -["Child2"] +["Child4"] +["Child6" "Child5"] +["Child1"] +["Child6"] --query_weighted_sample-- -["Child2"] -["Child4"] -[ - "Child2" - "Child1" - "Child2" - "Child1" - "Child5" - "Child2" - "Child1" - "Child5" - "Child3" - "Child3" - "Child1" - "Child2" - "Child3" - "Child1" - "Child2" - "Child1" - "Child1" - "Child1" - "Child1" - "Child2" -] -[ - "Child2" - "Child6" - "Child1" - "Child1" - "Child3" - "Child6" - "Child1" - "Child1" - "Child2" - "Child2" - "Child1" - "Child1" - "Child1" - "Child2" - "Child1" - "Child2" - "Child1" - "Child2" - "Child1" - "Child2" -] -[ - "Child2" - "Child2" - "Child2" - "Child2" - "Child2" - "Child2" - "Child2" - "Child4" - "Child2" - "Child2" -] -["Child2"] +["Child1"] +["Child2"] +[ + "Child2" + "Child2" + "Child2" + "Child6" + "Child1" + "Child1" + "Child1" + "Child2" + "Child2" + "Child2" + "Child4" + "Child2" + "Child2" + "Child2" + "Child1" + "Child1" + "Child2" + "Child2" + "Child2" + "Child1" +] +[ + "Child1" + "Child2" + "Child2" + "Child2" + "Child1" + "Child1" + "Child1" + "Child1" + "Child1" + "Child1" + "Child2" + "Child2" + "Child1" + "Child1" + "Child1" + "Child2" + "Child1" + "Child2" + "Child2" + "Child1" +] +[ + "Child2" + "Child2" + "Child2" + "Child2" + "Child5" + "Child2" + "Child2" + "Child2" + "Child5" + "Child2" +] +["Child2" "Child6"] --query_in_entity_list-- -["Child6" "Child7"] +["Child6" "Child7"] --query_not_in_entity_list-- -["Child1" "Child2" "Child3" "Child4" "Child5"] +["Child1" "Child2" "Child3" "Child4" "Child5"] --query_exists-- -["Child5"] -[] -["Child5"] +["Child5"] +[] +["Child5"] --query_not_exists-- -["Child1" "Child2" "Child3" "Child4" "Child6" "Child7"] -["Child5"] +["Child1" "Child2" "Child3" "Child4" "Child6" "Child7"] +["Child5"] --query_equals-- -["Child5"] -["Child5"] +["Child5"] +["Child5"] --query_not_equals-- -["Child1" "Child2" "Child6" "Child7"] -["Child1" "Child2" "Child6" "Child7"] -["Child5"] -["Child1" "Child2" "Child6" "Child7"] +["Child1" "Child2" "Child6" "Child7"] +["Child1" "Child2" "Child6" "Child7"] +["Child5"] +["Child1" "Child2" "Child6" "Child7"] --query_between-- -["Child1" "Child6" "Child7"] -["Child1" "Child6" "Child7"] -["Child2"] +["Child1" "Child6" "Child7"] +["Child1" "Child6" "Child7"] +["Child2"] --query_not_between-- -["Child2" "Child3" "Child4"] -["Child5"] -["Child6"] -cascading global query: ["Child3" "Child4" "Child7"] +["Child2" "Child3" "Child4"] +["Child5"] +["Child6"] +cascading global query: ["Child3" "Child4" "Child7"] --query_among-- -among x = 0, 100: ["Child3" "Child4" "Child7"] -among x = 0, 100: ["Child3" "Child4" "Child7"] -among bar = not crunchy: ["Child6"] -among bar = not crunchy: ["Child6"] +among x = 0, 100: ["Child3" "Child4" "Child7"] +among x = 0, 100: ["Child3" "Child4" "Child7"] +among bar = not crunchy: ["Child6"] +among bar = not crunchy: ["Child6"] --query_not_among-- -not_among x = 0, 100: ["Child1" "Child2" "Child6"] -not_among x = 0, 100: ["Child1" "Child2" "Child6"] -not_among bar = not crunchy: ["Child5"] -not_among bar = not crunchy: [] +not_among x = 0, 100: ["Child1" "Child2" "Child6"] +not_among x = 0, 100: ["Child1" "Child2" "Child6"] +not_among bar = not crunchy: ["Child5"] +not_among bar = not crunchy: [] --query_nearest_generalized_distance-- -cascading query_not_equals: ["Child1" "Child6"] -cascading query_not_in_entity_list: ["Child6" "Child7"] -unweighted query: { - Child1 4 - Child2 1 - Child3 100 - Child6 2 - Child7 10 -} -weighted query: { - Child1 1.8 - Child2 0.45 - Child3 2 - Child6 0.04 - Child7 0.2 -} -weighted query list of lists: [ - ["Child6" "Child7" "Child2" "Child1" "Child4"] - [0.04 0.2 0.45 1.8 2] -] -weighted query list of lists: [ - ["Child2" "Child6" "Child1" "Child7" "Child3"] - [1 2 4 10 100] - [-1 2 4 10 100] -] -weighted query list of lists with multiple values: [ - ["Child2" "Child6" "Child1" "Child7" "Child3"] - [1 2 4 10 100] - [-1 2 4 10 100] - [-1 1 3 0 100] -] -[ - [ - "_2131365383" - "_498755418" - "_842378747" - "_3348897774" - "_2893824972" - "_1567576627" - "_251284800" - "_3380262628" - ] - [ - 8.333333333333327 - 4.545454545454546 - 3.333333333333333 - 3.333333333333333 - 3.333333333333333 - 2.499999999999999 - 2 - 1.9999999999999991 - ] -] +cascading query_not_equals: ["Child1" "Child6"] +cascading query_not_in_entity_list: ["Child6" "Child7"] +unweighted query: { + Child1 4 + Child2 1 + Child4 100 + Child6 2 + Child7 10 +} +weighted query: { + Child1 1.8 + Child2 0.45 + Child3 2 + Child6 0.04 + Child7 0.2 +} +weighted query list of lists: [ + ["Child6" "Child7" "Child2" "Child1" "Child3"] + [0.04 0.2 0.45 1.8 2] +] +weighted query list of lists: [ + ["Child2" "Child6" "Child1" "Child7" "Child4"] + [1 2 4 10 100] + [-1 2 4 10 100] +] +weighted query list of lists with multiple values: [ + ["Child2" "Child6" "Child1" "Child7" "Child3"] + [1 2 4 10 100] + [-1 2 4 10 100] + [-1 1 3 0 100] +] +[ + [ + "_524432977" + "_1793553781" + "_3097960239" + "_2816641722" + "_369871947" + "_2842357671" + "_1688523560" + "_490936350" + ] + [ + 8.333333333333327 + 4.545454545454546 + 3.333333333333333 + 3.333333333333333 + 3.333333333333333 + 2.499999999999999 + 2 + 1.9999999999999991 + ] +] test code and string distances -1: ["Child1" "Child4"] -2: ["Child1" "Child2" "Child4" "Child5"] -3: ["Child1" "Child2" "Child4" "Child5"] -4: ["Child1" "Child2" "Child4" "Child5"] -5: ["Child1" "Child2" "Child6"] +1: ["Child1" "Child4"] +2: ["Child1" "Child2" "Child4" "Child5"] +3: ["Child1" "Child2" "Child4" "Child5"] +4: ["Child1" "Child2" "Child4" "Child5"] +5: ["Child1" "Child2" "Child6"] --query_max-- -["Child1" "Child3" "Child4"] -["Child1" "Child3" "Child4"] +["Child1" "Child3" "Child4"] +["Child1" "Child3" "Child4"] --query_min-- -["Child2" "Child7"] -["Child2" "Child7"] +["Child2" "Child7"] +["Child2" "Child7"] --query_sum-- 203 4.92 @@ -4301,678 +4252,672 @@ test code and string distances 97 199 --query_value_masses-- -{ - "-1" 1 - 0 1 - 1 1 - 3 1 - 100 2 -} - -{ - "-1" 0.45 - 0 0.02 - 1 0.02 - 3 0.45 - 100 0.04 -} - -{crunchy 1 "not crunchy" 1} +{ + -1 1 + 0 1 + 1 1 + 100 2 + 3 1 +} + +{ + -1 0.45 + 0 0.02 + 1 0.02 + 100 0.04 + 3 0.45 +} + +{crunchy 1 "not crunchy" 1} --query_less_or_equal_to-- -["Child1" "Child2" "Child6" "Child7"] -["Child1" "Child2" "Child6" "Child7"] +["Child1" "Child2" "Child6" "Child7"] +["Child1" "Child2" "Child6" "Child7"] --query_greater_or_equal_to-- -["Child3" "Child4"] -["Child3" "Child4"] +["Child3" "Child4"] +["Child3" "Child4"] --query_within_generalized_distance-- -["Child1" "Child2" "Child4" "Child6" "Child7"] -["Child1" "Child2" "Child4" "Child6" "Child7"] +["Child1" "Child2" "Child4" "Child6" "Child7"] +["Child1" "Child2" "Child4" "Child6" "Child7"] --query_nearest_generalized_distance-- -["Child2" "Child4"] -["Child2" "Child4"] -["Child1" "Child2" "Child4" "Child6" "Child7"] -["Child1" "Child2" "Child4" "Child6" "Child7"] -["Child2" "Child4"] -["Child2" "Child4" "Child7"] -["Child2" "Child4" "Child7"] -assoc-based: ["Child2" "Child4" "Child7"] -["Child2" "Child4" "Child6"] +["Child2" "Child4"] +["Child2" "Child4"] +["Child1" "Child2" "Child4" "Child6" "Child7"] +["Child1" "Child2" "Child4" "Child6" "Child7"] +["Child2" "Child4"] +["Child2" "Child4" "Child7"] +["Child2" "Child4" "Child7"] +assoc-based: ["Child2" "Child4" "Child7"] +["Child2" "Child4" "Child6"] --contained_entities caching and permissions-- -(false) +(false) (null) -(parallel - ##^a 3 - ##b (contained_entities) - ##c - (+ x 1) - ##d - (call_entity - "Child5" - "q" - {x x} - ) - ##!e 12 - ##x 4 - ##y 5 -) +(parallel + ##^a 3 + ##b (contained_entities) + ##c + (+ x 1) + ##d + (call_entity + "Child5" + "q" + {x x} + ) + ##!e 12 + ##x 4 + ##y 5 +) 1 0 0 1 -[ - (parallel - ##x 0 - ##y 0 - ) - (parallel - ##x 1 - ##y 0 - ) - (parallel - ##x 0 - ##y 1 - ) -] -[ - (parallel - ##x 0 - ##y 0 - ) - (parallel - ##x 1 - ##y 0 - ) - (parallel - ##x 0 - ##y 1 - ) - (parallel - ##x 0 - ##y 0.5 - ) -] -[ - (parallel - ##x 0 - ##y 0 - ) - (parallel - ##x 0 - ##y 1 - ) -] +[ + (parallel + ##x 0 + ##y 0 + ) + (parallel + ##x 1 + ##y 0 + ) + (parallel + ##x 0 + ##y 1 + ) +] +[ + (parallel + ##x 0 + ##y 0 + ) + (parallel + ##x 1 + ##y 0 + ) + (parallel + ##x 0 + ##y 1 + ) + (parallel + ##x 0 + ##y 0.5 + ) +] +[ + (parallel + ##x 0 + ##y 0 + ) + (parallel + ##x 0 + ##y 1 + ) +] --compute_on_contained_entities-- -{ - Child5 { - q (+ - x - (call_container "^a") - ) - } -} -{ - Child1 7 - Child2 2 - Child4 -200 - Child6 3 - Child7 10 -} -{ - Child1 7 - Child2 2 - Child4 -200 - Child6 3 - Child7 10 -} -{Child2 2 Child4 -200} +{ + Child5 { + q (+ + x + (call_container "^a") + ) + } +} +{ + Child1 7 + Child2 2 + Child4 -200 + Child6 3 + Child7 10 +} +{ + Child1 7 + Child2 2 + Child4 -200 + Child6 3 + Child7 10 +} +{Child2 2 Child4 -200} --compute_entity_convictions-- case convictions: -{ - entity1 1.8849070781661639 - entity2 0.6863118922121982 - entity3 0.8222276770849821 - entity4 1.9468118839925106 - entity5 0.7797040417153973 -} +{ + entity1 1.8849070781661639 + entity2 0.6863118922121982 + entity3 0.8222276770849821 + entity4 1.9468118839925106 + entity5 0.7797040417153973 +} case convictions: -{ - entity1 0.655877894152981 - entity2 4.719518200776451 - entity3 3.1299148442694946 - entity4 0.6588967213280371 - entity5 0.7011374455603876 -} +{ + entity1 0.655877894152981 + entity2 4.719518200776451 + entity3 3.1299148442694946 + entity4 0.6588967213280371 + entity5 0.7011374455603876 +} case convictions unweighted: -{ - entity1 2.2695667753739017 - entity2 0.6731896181878543 - entity3 1.1557765434908727 - entity4 38.384973496395396 - entity5 0.45815851485891435 -} +{ + entity1 2.2695667753739017 + entity2 0.6731896181878543 + entity3 1.1557765434908727 + entity4 38.384973496395396 + entity5 0.45815851485891435 +} case convictions weighted by object (with erroneously long nominal): -{ - TestContainerExec 0.2828909712209332 - vert0 1.2974898602334366 - vert1 1.2974898602334366 - vert2 1.1342260882087178 - vert3 1.2974898602334366 - vert4 73.7945497230898 - vert5 3.880438191446671 -} +{ + TestContainerExec 0.2828909712209332 + vert0 1.2974898602334366 + vert1 1.2974898602334366 + vert2 1.1342260882087178 + vert3 1.2974898602334366 + vert4 73.7945497230898 + vert5 3.880438191446671 +} case convictions x exists before: -{entity3 1.0000000933277426 entity4 0.9999998458521889 entity5 1.0000000608201045} +{entity3 1.0000000933277426 entity4 0.9999998458521889 entity5 1.0000000608201045} case convictions x exists after: -{ - entity3 {x 16} - entity4 {x 8} - entity5 {x 32} -} +{ + entity3 {x 16} + entity4 {x 8} + entity5 {x 32} +} case convictions object = 1: -{ - vert0 0.9999999999999484 - vert1 0.9999999999999976 - vert2 1.0000000000000566 - vert3 0.9999999999999976 -} +{ + vert0 0.9999999999999484 + vert1 0.9999999999999976 + vert2 1.0000000000000566 + vert3 0.9999999999999976 +} case convictions on a subset: -{vert0 0.5 vert3 0} +{vert0 0.5 vert3 0} --compute_entity_group_kl_divergence-- 0.01228960638554566 --compute_entity_distance_contributions-- -{ - TestContainerExec 4.721359549995793 - vert0 0.8284271247461902 - vert1 0.8284271247461902 - vert2 0.8284271247461902 - vert3 0.8284271247461902 - vert4 0.7071067811865476 - vert5 1.17157287525381 -} +{ + TestContainerExec 4.721359549995793 + vert0 0.8284271247461902 + vert1 0.8284271247461902 + vert2 0.8284271247461902 + vert3 0.8284271247461902 + vert4 0.7071067811865476 + vert5 1.17157287525381 +} (these values should match the values of the subset of these keys in the previous assoc): -{vert0 0.8284271247461902 vert1 0.8284271247461902 vert2 0.8284271247461902} -{ - vert0 0.8284271247461902 - vert1 0.8284271247461902 - vert2 0.8284271247461902 - vert3 0.8284271247461902 - vert4 0.7071067811865476 - vert5 1.17157287525381 -} +{vert0 0.8284271247461902 vert1 0.8284271247461902 vert2 0.8284271247461902} +{ + vert0 0.8284271247461902 + vert1 0.8284271247461902 + vert2 0.8284271247461902 + vert3 0.8284271247461902 + vert4 0.7071067811865476 + vert5 1.17157287525381 +} (these values should match the values of the subset of these keys in the previous assoc): -{vert4 0.7071067811865476 vert5 1.17157287525381} +{vert4 0.7071067811865476 vert5 1.17157287525381} --compute_entity_kl_divergences-- -{ - vert0 0.00018681393615961172 - vert1 0.0003526679446349979 - vert2 0.005341750456218763 - vert3 0.00018681393615961172 - vert4 0.006401917906003654 - vert5 0.010670757326457676 -} -(these values should match the values of the subset of these keys in the previous assoc):{vert0 0.00018681393615961172 vert3 0} +{ + vert0 0.00018681393615961172 + vert1 0.0003526679446349979 + vert2 0.005341750456218763 + vert3 0.00018681393615961172 + vert4 0.006401917906003654 + vert5 0.010670757326457676 +} +(these values should match the values of the subset of these keys in the previous assoc):{vert0 0.00018681393615961172 vert3 0} additional conviction calculations: -case conviction:{ - vert0 0.8000570855094574 - vert1 0.7468655552274358 - vert3 6.2015767755691655 - vert5 0.8000570855094727 -} -case conviction:{ - vert0 0.6770361498076789 - vert1 3.8439118699400026 - vert3 1.3354696017896601 - vert5 0.6604923501807921 -} -cyclic feature nearest neighbors: {cyclic1 1 cyclic5 0.5} +case conviction:{ + vert0 0.8000570855094574 + vert1 0.7468655552274358 + vert3 6.2015767755691655 + vert5 0.8000570855094727 +} +case conviction:{ + vert0 0.6770361498076789 + vert1 3.8439118699400026 + vert3 1.3354696017896601 + vert5 0.6604923501807921 +} +cyclic feature nearest neighbors: {cyclic1 1 cyclic5 0.5} cyclic test expected: 155, 200, 190 ... deg values of 0 8 and 12: -190: 0.045454545454545456 (null - ##deg 12 -) -155: 0.1 (null - ##deg 0 -) -200: 0.05555555555555555 (null - ##deg 8 -) +190: 0.045454545454545456 (null + ##deg 12 +) +155: 0.1 (null + ##deg 0 +) +200: 0.05555555555555555 (null + ##deg 8 +) --contains_label-- -(contains_label "label3") +(true) -(contains_label "hhccc") +(false) -(contains_label - ["TestContainerExec" "Child1"] - "y" -) +(true) -(contains_label - ["TestContainerExec" "Child1"] - "qq" -) +(false) --assign_to_entities-- -#a2e (null) -" or " -3 -(true) -5 +#a2e (null) +" or " +3 +(true) +5 (parallel #asgn_test 12) -(true) -4 -(parallel - ##a 2 - ##b 3 - ##c 4 -) -(+ - ##three 12 - 4 -) +(true) +4 +(parallel + ##a 2 + ##b 3 + ##c 4 +) +(+ + ##three 12 + 4 +) --direct_assign_to_entities-- -#a 12 -(true) -#a 7 +#a 12 +(true) +#a 7 --accum_to_entities-- 7 -#i2e2 -[1 2 3 4] +#i2e2 +[1 2 3 4] --retrieve_from_entity-- -" and " -12 -12 -[12 13] -{a 12 b 13} +" and " +12 +12 +[12 13] +{a 12 b 13} --direct_retrieve_from_entity-- -7 -#a 7 +7 +#a 7 --call_entity-- -[ - "Child1" - "Child2" - "Child3" - "Child4" - "Child5" - "Child6" - "Child7" -] -(parallel - ##^a 3 - ##b (contained_entities) - ##c - (+ x 1) - ##d - (call_entity - "Child5" - "q" - {x x} - ) - ##!e 12 - ##x 4 - ##y 5 -) -3 -[ - "Child1" - "Child2" - "Child3" - "Child4" - "Child5" - "Child6" - "Child7" -] -6 +[ + "Child1" + "Child2" + "Child3" + "Child4" + "Child5" + "Child6" + "Child7" +] +(parallel + ##^a 3 + ##b (contained_entities) + ##c + (+ x 1) + ##d + (call_entity + "Child5" + "q" + {x x} + ) + ##!e 12 + ##x 4 + ##y 5 +) +3 +[ + "Child1" + "Child2" + "Child3" + "Child4" + "Child5" + "Child6" + "Child7" +] +6 execution limits tests 87 --call_entity_get_changes-- -4 -6 -[ - (true) - (seq - (create_entities - ["CEGCTest" "Contained"] - (null - #a 4 - #b 6 - ) - ) - (print "4\r\n") - (assign_to_entities - ["CEGCTest" "Contained"] - {a 6 b 10} - ) - (print "6\r\n") - (set_entity_rand_seed - ["CEGCTest" "Contained"] - "bbbb" - (false) - ) - (destroy_entities - ["CEGCTest" "Contained"] - ) - ) -] +4 +6 +[ + (true) + (seq + (create_entities + ["CEGCTest" "Contained"] + (null + #a 4 + #b 6 + ) + ) + (print "4\r\n") + (assign_to_entities + ["CEGCTest" "Contained"] + {a 6 b 10} + ) + (print "6\r\n") + (set_entity_rand_seed + ["CEGCTest" "Contained"] + "bbbb" + (false) + ) + (destroy_entities + ["CEGCTest" "Contained"] + ) + ) +] --call_container-- 8 8 (null) --circular, repeated, and preevaluated references-- -{a 1 b 2} -(associate "a" 1 "b" 2) +{a 1 b 2} +(associate "a" 1 "b" 2) (null) 1 (null) -[ - {a 1} - @(get - (target 2) - 0 - ) - 1 -] -[ - {a 1} - @(get - (target 2) - 0 - ) - 1 -] +[ + {a 1} + @(get + (target 2) + 0 + ) + 1 +] +[ + {a 1} + @(get + (target 2) + 0 + ) + 1 +] 3 -[ - {a 3} - @(get - (target 2) - [0 "a"] - ) -] - -[ - {a 3} - @(get - (target 2) - [0 "a"] - ) -] +[ + {a 3} + @(get + (target 2) + [0 "a"] + ) +] + +[ + {a 3} + @(get + (target 2) + [0 "a"] + ) +] entity cyclic test: -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - ##label_target - [ - {a 3} - @(get - (target 2) - [0 "a"] - ) - ] - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "O\rBxQ\thh^8K") - new_entity -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + ##label_target + [ + {a 3} + @(get + (target 2) + [0 "a"] + ) + ] + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "\\| ;;V;") + new_entity +) 3 -(declare - {create_new_entity (true) new_entity (null)} - (let - { - _ (lambda - ##label_target - [ - {a 3} - @(get - (target 2) - [0 "a"] - ) - ] - ) - } - (if - create_new_entity - (assign - "new_entity" - (first - (create_entities new_entity _) - ) - ) - (assign_entity_roots new_entity _) - ) - ) - (set_entity_rand_seed new_entity "O\rBxQ\thh^8K") - new_entity -) +(declare + {create_new_entity (true) new_entity (null)} + (let + { + _ (lambda + ##label_target + [ + {a 3} + @(get + (target 2) + [0 "a"] + ) + ] + ) + } + (if + create_new_entity + (assign + "new_entity" + (first + (create_entities new_entity _) + ) + ) + (assign_entity_roots new_entity _) + ) + ) + (set_entity_rand_seed new_entity "\\| ;;V;") + new_entity +) cyclic lookup test: -{ - original { - auto_derive_on_train {series_id_features "id"} - } - pointer [ - [@(get (target 4) ["original" "auto_derive_on_train" "series_id_features"])] - ] -} +{ + original { + auto_derive_on_train {series_id_features "id"} + } + pointer [ + [@(get (target 4) ["original" "auto_derive_on_train" "series_id_features"])] + ] +} cyclic lookup test 2: -{ - ".f1_rate_1" { - auto_derive_on_train { - ordered_by_features ["date"] - } - } - ".f3_rate_1" { - auto_derive_on_train { - ordered_by_features [@(get (target 5) [".f1_rate_1" "auto_derive_on_train" "ordered_by_features" 0])] - } - } -} +{ + ".f1_rate_1" { + auto_derive_on_train { + ordered_by_features ["date"] + } + } + ".f3_rate_1" { + auto_derive_on_train { + ordered_by_features [@(get (target 5) [".f1_rate_1" "auto_derive_on_train" "ordered_by_features" 0])] + } + } +} --null equality tests-- -(= (null) (null)): (true) +(= (null) (null)): (true) -(= (+ (null)) (null)): (true) +(= (+ (null)) (null)): (true) -["Entity3"] -["EntityNull" "EntityNaN"] -["EntityNull" "EntityNaN"] -["Entity3" "EntityNull" "EntityNaN"] +["Entity3"] +["EntityNull" "EntityNaN"] +["EntityNull" "EntityNaN"] +["Entity3" "EntityNull" "EntityNaN"] --combo tests-- 4.5 5 -(null - #A 10 - #duped - ["b"] - @(get - (target 2) - 1 - ) -) - -["hello" "!"] -{a1 1.4142135623730951 a2 2 a3 1.4142135623730951} -{a1 1.4142135623730951 a3 1.4142135623730951} -{a3 1.4142135623730951} -{a1 5.0990195135927845 a2 2 a3 5.0990195135927845} -{a1 1 a3 1 a4 0} +(null + #A 10 + #duped + ["b"] + @(get + (target 2) + 1 + ) +) + +["hello" "!"] +{a1 1.4142135623730951 a2 2 a3 1.4142135623730951} +{a1 1.4142135623730951 a3 1.4142135623730951} +{a3 1.4142135623730951} +{a1 5.0990195135927845 a2 2 a3 5.0990195135927845} +{a1 1 a3 1 a4 0} --accuracy tests-- 1036.1581794564518 24.769501899470985 4.3464184709105573e-45 -{point1 1036.1581794564518 point2 978.5569789822398 point3 1036.1581794564518} +{point1 1036.1581794564518 point2 978.5569789822398 point3 1036.1581794564518} distance symmetry tests -[ - [ - "B" - "I" - "D" - "A" - "C" - "F" - "G" - "J" - ] - [ - 0 - 1 - 1 - 1 - 1 - 1 - 1024 - 1024 - ] -] -[ - [ - "B" - "C" - "A" - "I" - "F" - "D" - "J" - "E" - ] - [ - 0 - 1 - 1 - 1 - 1 - 1 - 1024 - 1024 - ] -] +[ + [ + "B" + "I" + "D" + "F" + "C" + "A" + "J" + "E" + ] + [ + 0 + 1 + 1 + 1 + 1 + 1 + 1024 + 1024 + ] +] +[ + [ + "B" + "C" + "F" + "D" + "A" + "I" + "E" + "G" + ] + [ + 0 + 1 + 1 + 1 + 1 + 1 + 1024 + 1024 + ] +] distance contributions -dc: [ - ["vert0" "vert1" "vert2" "vert3"] - [1 1 1 1.4142135623730951] -] -weighted dc: { - vert0 2 - vert1 1 - vert2 1 - vert3 1.4142135623730951 -} +dc: [ + ["vert0" "vert1" "vert2" "vert3"] + [1 1 1 1.4142135623730951] +] +weighted dc: { + vert0 2 + vert1 1 + vert2 1 + vert3 1.4142135623730951 +} removal conviction -kl: { - vert0 0.012498962161828123 - vert1 0.0014999155151563248 - vert2 0.012940692023868397 - vert3 0.012498962161828303 -} -weighted kl: { - vert0 0.043840314666364594 - vert1 0.01215014552815915 - vert2 0.023216985559271874 - vert3 0.00033148949739295053 -} -convictions: { - vert0 0.7888361319935541 - vert1 6.573458882210904 - vert2 0.7619092508719576 - vert3 0.7888361319935426 -} -further parameterized convictions: { - vert0 0.7888361319935541 - vert1 6.573458882210904 - vert2 0.7619092508719576 - vert3 0.7888361319935426 -} -weighted convictions: { - vert0 0.4535718770297335 - vert1 1.6365840035999841 - vert2 0.8564735401170989 - vert3 59.98601454701778 -} +kl: { + vert0 0.012498962161828123 + vert1 0.0014999155151563248 + vert2 0.012940692023868397 + vert3 0.012498962161828303 +} +weighted kl: { + vert0 0.043840314666364594 + vert1 0.01215014552815915 + vert2 0.023216985559271874 + vert3 0.00033148949739295053 +} +convictions: { + vert0 0.7888361319935541 + vert1 6.573458882210904 + vert2 0.7619092508719576 + vert3 0.7888361319935426 +} +further parameterized convictions: { + vert0 0.7888361319935541 + vert1 6.573458882210904 + vert2 0.7619092508719576 + vert3 0.7888361319935426 +} +weighted convictions: { + vert0 0.4535718770297335 + vert1 1.6365840035999841 + vert2 0.8564735401170989 + vert3 59.98601454701778 +} group kl divergence: 0.0014999155151563318 weighted group kl divergence: 0.012150145528158986 addition conviction -kl: { - vert0 0.0118919309314467 - vert1 0.0015341620278852101 - vert2 0.012738870517593676 - vert3 0.01189193093144647 -} -weighted kl: { - vert0 0.04280308290362862 - vert1 0.013070224898692417 - vert2 0.023586134873106707 - vert3 0.0003283237047790495 -} -convictions: { - vert0 0.8000570855094574 - vert1 6.2015767755691655 - vert2 0.7468655552274358 - vert3 0.8000570855094727 -} -further parameterized convictions: { - vert0 0.8000570855094574 - vert1 6.2015767755691655 - vert2 0.7468655552274358 - vert3 0.8000570855094727 -} -weighted convictions: { - vert0 0.466016469887516 - vert1 1.5261360649614566 - vert2 0.8457062465879276 - vert3 60.753888021808535 -} +kl: { + vert0 0.0118919309314467 + vert1 0.0015341620278852101 + vert2 0.012738870517593676 + vert3 0.01189193093144647 +} +weighted kl: { + vert0 0.04280308290362862 + vert1 0.013070224898692417 + vert2 0.023586134873106707 + vert3 0.0003283237047790495 +} +convictions: { + vert0 0.8000570855094574 + vert1 6.2015767755691655 + vert2 0.7468655552274358 + vert3 0.8000570855094727 +} +further parameterized convictions: { + vert0 0.8000570855094574 + vert1 6.2015767755691655 + vert2 0.7468655552274358 + vert3 0.8000570855094727 +} +weighted convictions: { + vert0 0.466016469887516 + vert1 1.5261360649614566 + vert2 0.8457062465879276 + vert3 60.753888021808535 +} group kl divergence: 0.0015341620278852813 weighted group kl divergence: 0.013070224898692494 adding a case -noncyclic KL: { - vert0 0.01467982549299679 - vert1 0.0027281364373075885 - vert2 0.0027281364373075885 - vert3 0.016383251387214498 - vert4 0.0051662807478393205 -} +noncyclic KL: { + vert0 0.01467982549299679 + vert1 0.0027281364373075885 + vert2 0.0027281364373075885 + vert3 0.016383251387214498 + vert4 0.0051662807478393205 +} noncyclic group kl divergence: 0.005166280747839411 -cyclic KL: { - vert0 0.06449882851689671 - vert1 0.0020695242435298626 - vert2 0.0020695242435298626 - vert3 0.03622271709266012 - vert4 0.06081391029364311 -} -cyclic conviction: { - vert0 0.5137287240708814 - vert1 16.01087833672136 - vert2 16.01087833672136 - vert3 0.9147547047144656 - vert4 0.5448572656824459 -} +cyclic KL: { + vert0 0.06449882851689671 + vert1 0.0020695242435298626 + vert2 0.0020695242435298626 + vert3 0.03622271709266012 + vert4 0.06081391029364311 +} +cyclic conviction: { + vert0 0.5137287240708814 + vert1 16.01087833672136 + vert2 16.01087833672136 + vert3 0.9147547047144656 + vert4 0.5448572656824459 +} cyclic group kl divergence: 0.06081391029364306 surprisal transforms -probabilities: [ - ["vert0" "vert1" "vert2" "vert3"] - [2.7535180455541748e-05 2.7535180455541748e-05 5.043471233780792e-07 9.237449443012879e-09] -] - -weighted probabilities: [ - ["vert0" "vert2" "vert3" "vert1"] - [5.506960272483319e-05 5.043471233780792e-07 9.237449443012879e-09 0] -] - -surprisal contribution: {testvert 9.797630298091489} -weighted surprisal contribution: {testvert 9.797630298091489} +probabilities: [ + ["vert0" "vert1" "vert2" "vert3"] + [2.7535180455541748e-05 2.7535180455541748e-05 5.043471233780792e-07 9.237449443012879e-09] +] + +weighted probabilities: [ + ["vert0" "vert2" "vert3" "vert1"] + [5.506960272483319e-05 5.043471233780792e-07 9.237449443012879e-09 0] +] + +surprisal contribution: {testvert 9.797630298091489} +weighted surprisal contribution: {testvert 9.797630298091489} --concurrency tests-- hello hello @@ -4983,60 +4928,60 @@ hello mod : 1 max : 10 min : 1 -and : (true) +and : (true) -or : (true) +or : (true) -xor : (true) +xor : (true) -= : (false) += : (false) -!= : (false) +!= : (false) -< : (false) +< : (false) -<= : (true) +<= : (true) -> : (false) +> : (false) ->= : (false) +>= : (false) -~ : (true) +~ : (true) -list : [1 1 1 2] +list : [1 1 1 2] -associate : { - a 1 - b 1 - c 1 - d 2 -} +associate : { + a 1 + b 1 + c 1 + d 2 +} -assoc : { - a 1 - b 1 - c 1 - d 2 -} +assoc : { + a 1 + b 1 + c 1 + d 2 +} -map list : [2 4 6 8] +map list : [2 4 6 8] -map assoc : { - a 2 - b 4 - c 6 - d 8 -} +map assoc : { + a 2 + b 4 + c 6 + d 8 +} -filter list : [3 4] +filter list : [3 4] -filter assoc : {10 1} +filter assoc : {10 1} -filter assoc 2 : {10 1 20 2} +filter assoc 2 : {10 1 20 2} Expecting 1000: 1000 --concurrent entity writes-- -concurrent entity writes successful: (true) +concurrent entity writes successful: (true) --clean-up test files-- rmdir /s /q amlg_code\test_output @@ -5044,4 +4989,4 @@ rmdir /s /q amlg_code\persistent_tree_test_root del /s /q amlg_code\persist_module_test\psm.mdam del /s /q amlg_code\persist_module_test.mdam --total execution time-- -1.7082650661468506 +2.271027088165283 diff --git a/src/Amalgam/string/StringInternPool.h b/src/Amalgam/string/StringInternPool.h index 4e02454e..07fc3c5c 100644 --- a/src/Amalgam/string/StringInternPool.h +++ b/src/Amalgam/string/StringInternPool.h @@ -91,7 +91,7 @@ class StringInternPool //makes a new reference to the string specified, returning the ID inline StringID CreateStringReference(const std::string &str) { - if(str == "") + if(str.size() == 0) return emptyStringId; #if defined(MULTITHREAD_SUPPORT) || defined(MULTITHREAD_INTERFACE) diff --git a/src/Amalgam/string/StringManipulation.cpp b/src/Amalgam/string/StringManipulation.cpp index 4798890e..46d3be2c 100644 --- a/src/Amalgam/string/StringManipulation.cpp +++ b/src/Amalgam/string/StringManipulation.cpp @@ -125,7 +125,7 @@ std::vector StringManipulation::SplitArgString(std::string &arg_str return args; } -std::vector StringManipulation::Split(std::string &s, char delim) +std::vector StringManipulation::Split(const std::string &s, char delim) { std::vector ret; std::stringstream ss { s }; diff --git a/src/Amalgam/string/StringManipulation.h b/src/Amalgam/string/StringManipulation.h index b6baa666..597c580a 100644 --- a/src/Amalgam/string/StringManipulation.h +++ b/src/Amalgam/string/StringManipulation.h @@ -17,7 +17,7 @@ namespace StringManipulation std::string RemoveFirstToken(std::string &str); //splits a string by given delimiter - std::vector Split(std::string &s, char delim = ' '); + std::vector Split(const std::string &s, char delim = ' '); //separates the argument string and returns an appropriate vector of strings //if greedy is true, the returned vector contains the full list of arguments and arg_string is unmodified