diff --git a/src/Amalgam/Parser.cpp b/src/Amalgam/Parser.cpp index 58c4b86b..57251238 100644 --- a/src/Amalgam/Parser.cpp +++ b/src/Amalgam/Parser.cpp @@ -783,19 +783,25 @@ void Parser::AppendAssocKeyValuePair(UnparseData &upd, StringInternPool::StringI upd.result.push_back(' '); } - auto key_str = string_intern_pool.GetStringFromID(key_sid); - - //surround in quotes only if needed - if(key_sid != string_intern_pool.NOT_A_STRING_ID - && HasCharactersBeyondIdentifier(key_str)) + if(key_sid == string_intern_pool.NOT_A_STRING_ID) { - upd.result.push_back('"'); - upd.result.append(Backslashify(key_str)); - upd.result.push_back('"'); + upd.result.append("(null)"); } else { - upd.result.append(key_str); + auto key_str = string_intern_pool.GetStringFromID(key_sid); + + //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); + } } //space between key and value diff --git a/src/Amalgam/amlg_code/full_test.amlg b/src/Amalgam/amlg_code/full_test.amlg index 4147c856..b2012552 100644 --- a/src/Amalgam/amlg_code/full_test.amlg +++ b/src/Amalgam/amlg_code/full_test.amlg @@ -1186,6 +1186,7 @@ (print "--assoc--\n") (print (assoc b 2 c 3)) + (print (assoc (null) 3)) (print "--get_type--\n") (print (get_type (lambda (+ 3 4)))) diff --git a/src/Amalgam/out.txt b/src/Amalgam/out.txt index 02d3c9f5..d54ae650 100644 --- a/src/Amalgam/out.txt +++ b/src/Amalgam/out.txt @@ -235,11 +235,11 @@ notakeyword (print "hello") [(null) (null) .infinity -.infinity] -{a 1 b 2 c ["alpha" "beta" "gamma"]} +{a 1 c ["alpha" "beta" "gamma"] b 2} { a 1 - b 2 c ["alpha" "beta" "gamma"] + b 2 } --if-- @@ -629,18 +629,18 @@ a [1 2 3 4 5 6] [] { + a 1 b 2 c 3 d 4 - e 5 f 6 } -{c 3 f 6} +{b 2 c 3} { + a 1 + b 2 c 3 d 4 - e 5 - f 6 } { a 1 @@ -680,18 +680,18 @@ c [1 2 3 4 5 6] [] { + a 1 b 2 c 3 d 4 - e 5 f 6 } -{c 3 f 6} +{b 2 c 3} { + a 1 + b 2 c 3 d 4 - e 5 - f 6 } { a 1 @@ -1042,7 +1042,7 @@ abcdef [1 3] [9 5] --indices-- -["a" "b" "4" "c"] +["4" "a" "c" "b"] [ 0 1 @@ -1054,7 +1054,7 @@ abcdef 7 ] --values-- -["d" 1 2 3] +["d" 1 3 2] [ "a" 1 @@ -1075,7 +1075,7 @@ abcdef 4 "d" ] -["d" 1 2 0 3] +[0 1 3 "d" 2] [ 1 2 @@ -1272,7 +1272,7 @@ current_index: 2 8 ] accum_string "abcdef" - argv ["C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] + argv ["C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] bar (declare {x 6} (+ x 2) @@ -1285,10 +1285,10 @@ current_index: 2 A {B 2} B 2 } - interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" raaa 2 rwww 1 - start_time 1723317264.324925 + start_time 1723482329.220018 www 1 x 12 zz 10 @@ -1315,7 +1315,7 @@ current_index: 2 8 ] accum_string "abcdef" - argv ["C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] + argv ["C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] bar (declare {x 6} (+ x 2) @@ -1328,10 +1328,10 @@ current_index: 2 A {B 2} B 2 } - interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" raaa 2 rwww 1 - start_time 1723317264.324925 + start_time 1723482329.220018 www 1 x 12 zz 10 @@ -1357,7 +1357,7 @@ current_index: 2 8 ] accum_string "abcdef" - argv ["C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] + argv ["C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg"] bar (declare {x 6} (+ x 2) @@ -1370,10 +1370,10 @@ current_index: 2 A {B 2} B 2 } - interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" raaa 2 rwww 1 - start_time 1723317264.324925 + start_time 1723482329.220018 www 1 x 12 zz 10 @@ -1517,11 +1517,11 @@ infinity test c or d: ["c" "c" "c" "d"] infinity test c or d: ["d" @(get (target 2) 0) "c" @(get (target 2) 2)] -{a 28 b 47 c 25} +{a 28 b 45 c 27} {a 24 b 52 c 24} -["7" "2" "4"] +["3" "4" "1"] --get_rand_seed-- N9“˸U¯OaVÆT zÿ @@ -1559,6 +1559,7 @@ N9 } --assoc-- {b 2 c 3} +{(null) 3} --get_type-- (+) --get_type_string-- @@ -1618,15 +1619,15 @@ string ] 21: [{"a":3,"b":4},{"d":null,"c":"c"}] 22: [{"a":3,"b":4},{"c":"c","d":null}] -23: a: 1 -b: 2 -d: 4 -e: +23: e: - a - b - - .inf +a: 1 +d: 4 c: 3 +b: 2 24: a: 1 b: 2 @@ -1639,7 +1640,7 @@ e: - .inf 25: {a 1} -current date-time in epoch: 2024-08-10-15.14.24.4291220 +current date-time in epoch: 2024-08-12-13.05.29.4702700 2020-06-07 00:22:59 1391230800 1391230800 @@ -2179,16 +2180,6 @@ decrypted: hello {_ (null)} (replace _ - ["g"] - (lambda - [ - (get - (current_value 1) - 0 - ) - 4 - ] - ) [] (lambda { @@ -2199,6 +2190,16 @@ decrypted: hello ) } ) + ["g"] + (lambda + [ + (get + (current_value 1) + 0 + ) + 4 + ] + ) ) ) (declare @@ -2817,26 +2818,26 @@ _2169689611 ##p ["_3990396532" "_3990396532" "_3330773578" "_3330773578"] ) -_3330773578 +_3990396532 (associate - "e" + "E" 3 - "f" + "F" 4 - "g" + "G" 5 - "h" + "H" 6 ) -_3990396532 +_3330773578 (associate - "E" + "e" 3 - "F" + "f" 4 - "G" + "g" 5 - "H" + "h" 6 ) --difference_entities-- @@ -3167,8 +3168,14 @@ _432807187 [] (lambda { - E 3 - F 4 + E (get + (current_value 1) + "E" + ) + F (get + (current_value 1) + "F" + ) G 5 H 6 } @@ -3193,7 +3200,16 @@ _432807187 _ [] (lambda - {e 3 f 4} + { + e (get + (current_value 1) + "e" + ) + f (get + (current_value 1) + "f" + ) + } ) ) ) @@ -3225,7 +3241,89 @@ contained_entities new_entity: ["DiffEntityChild1" "OnlyIn2" "_350925375" "_2742 difference between DiffEntity2 and new_entity: (declare {_ (null) new_entity (null)} - (clone_entities _ new_entity) + (assign + "new_entity" + (first + (create_entities + new_entity + (call + (lambda + (declare + {_ (null)} + (replace _) + ) + ) + { + _ (retrieve_entity_root _) + } + ) + ) + ) + ) + (create_entities + (append new_entity "_350925375") + (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 _ "_350925375") + ) + } + ) + ) + (create_entities + (append new_entity "_2742810479") + (call + (lambda + (declare + {_ (null)} + (replace + _ + [] + (lambda + {e (null) f (null)} + ) + ) + ) + ) + { + _ (retrieve_entity_root + (append _ "_2742810479") + ) + } + ) + ) + (clone_entities + (append _ "DiffEntityChild1") + (append new_entity "DiffEntityChild1") + ) + (clone_entities + (append _ "OnlyIn2") + (append new_entity "OnlyIn2") + ) + new_entity ) (declare {_ (null) new_entity (null)} @@ -3434,7 +3532,7 @@ deep sets --set_entity_root_permission-- RootTest -1723317264.843211 +1723482329.726863 (true) RootTest @@ -4276,12 +4374,12 @@ cyclic test expected: 155, 200, 190 ... deg values of 0 8 and 12: 200: 0.05555555555555555 (null ##deg 8 ) -155: 0.1 (null - ##deg 0 -) 190: 0.045454545454545456 (null ##deg 12 ) +155: 0.1 (null + ##deg 0 +) --contains_label-- (true) @@ -4778,4 +4876,4 @@ concurrent entity writes successful: (true) --clean-up test files-- --total execution time-- -3.2294390201568604 +1.412693977355957