2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-12-11 11:10:58 +00:00
< meta name = "generator" content = "ZealOS V1.07" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
2021-10-08 07:06:11 +01:00
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
2021-07-03 05:07:57 +01:00
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-03 05:07:57 +01:00
< a name = "l1" > < / a > < span class = cF0 > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_INVALID < / span > < span class = cFE > 0< / span > < span class = cF0 >
< a name = "l2" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_STRING < / span > < span class = cFE > 1< / span > < span class = cF0 >
< a name = "l3" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_INTEGER < / span > < span class = cFE > 2< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l4" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_FLOAT < / span > < span class = cFE > 3< / span > < span class = cF0 >
< a name = "l5" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_ARRAY < / span > < span class = cFE > 4< / span > < span class = cF0 >
< a name = "l6" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_BOOL < / span > < span class = cFE > 5< / span > < span class = cF0 >
< a name = "l7" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_OBJ < / span > < span class = cFE > 6< / span > < span class = cF0 >
< a name = "l8" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSONT_NULL < / span > < span class = cFE > 7< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l9" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l10" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > JSON_HASHTABLE_SIZE < / span > < span class = cFE > 1024< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l11" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l12" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > HTT_JSON < / span > < span class = cFE > 0x00100< / span > < span class = cF0 > < / span > < span class = cF2 > //identical to HTT_DICT_WORD< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l13" > < / a >
< a name = "l14" > < / a > < / span > < span class = cF1 > class< / span > < span class = cF0 > CJSONDataEntry:< / span > < span class = cF9 > CQueue< / span > < span class = cF0 >
< a name = "l15" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l16" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > type;
2021-07-03 05:07:57 +01:00
< a name = "l17" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l18" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > int_data;
< a name = "l19" > < / a > < / span > < span class = cF1 > F64< / span > < span class = cF0 > float_data;
< a name = "l20" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *string_data;
< a name = "l21" > < / a > < / span > < span class = cF1 > Bool< / span > < span class = cF0 > bool_data;
< a name = "l22" > < / a > CJSONDataEntry *list_data;
< a name = "l23" > < / a > < / span > < span class = cF9 > CHashTable< / span > < span class = cF0 > *hash_table;
2021-07-03 05:07:57 +01:00
< a name = "l24" > < / a > };
< a name = "l25" > < / a >
< a name = "l26" > < / a > < / span > < span class = cF1 > class< / span > < span class = cF0 > CJSONDataHash:< / span > < span class = cF9 > CHash< / span > < span class = cF0 >
< a name = "l27" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l28" > < / a > CJSONDataEntry *data;
2021-07-03 05:07:57 +01:00
< a name = "l29" > < / a > };
< a name = "l30" > < / a >
< a name = "l31" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > **JSONGetKeys(< / span > < span class = cF9 > CHashTable< / span > < span class = cF0 > *table)
< a name = "l32" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l33" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i, count = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l34" > < / a > < / span > < span class = cF9 > CHash< / span > < span class = cF0 > *temp_hash;
< a name = "l35" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > **keys;
< a name = "l36" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > key_index = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l37" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l38" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < = table-> mask; i++) < / span > < span class = cF2 > //mask is table length 0-based< / span > < span class = cF0 >
< a name = "l39" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_hash = table-> body[i]) < / span > < span class = cF2 > //if temp_hash exists< / span > < span class = cF0 >
< a name = "l40" > < / a > count++;
2021-07-03 05:07:57 +01:00
< a name = "l41" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l42" > < / a > keys = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF1 > U8< / span > < span class = cF0 > *< / span > < span class = cF7 > )< / span > < span class = cF0 > * count); < / span > < span class = cF2 > // alloc string list< / span > < span class = cF0 >
< a name = "l43" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < = table-> mask; i++)
< a name = "l44" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_hash = table-> body[i])
< a name = "l45" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l46" > < / a > keys[key_index] = < / span > < span class = cF5 > StrNew< / span > < span class = cF0 > (temp_hash-> str);< / span > < span class = cF2 > //add key string to list< / span > < span class = cF0 >
< a name = "l47" > < / a > key_index++;
< a name = "l48" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l49" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l50" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > keys;
2021-07-03 05:07:57 +01:00
< a name = "l51" > < / a > }
< a name = "l52" > < / a >
< a name = "l53" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > JSONIndentLine(< / span > < span class = cF9 > I64< / span > < span class = cF0 > indent)
< a name = "l54" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l55" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
< a name = "l56" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > for (i = 0; i < indent; i++) {" " ;}< / span > < span class = cF0 >
< a name = "l57" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (i = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; i < indent; i++) < / span > < span class = cF7 > {< / span > < span class = cF6 > " < / span > < span class = cF0 > < / span > < span class = cF6 > " < / span > < span class = cF0 > ;< / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l58" > < / a >
< a name = "l59" > < / a > }
< a name = "l60" > < / a >
< a name = "l61" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > JSONDataRep(CJSONDataEntry *data, < / span > < span class = cF9 > I64< / span > < span class = cF0 > indent=< / span > < span class = cFE > 0< / span > < span class = cF0 > )
< a name = "l62" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l63" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > **keys;< / span > < span class = cF2 > // = JSONGetKeys(data-> hash_table);< / span > < span class = cF0 >
< a name = "l64" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > index;
< a name = "l65" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > count;< / span > < span class = cF2 > // = MSize(keys) / sizeof(U8*);< / span > < span class = cF0 >
< a name = "l66" > < / a > CJSONDataEntry *entry;< / span > < span class = cF2 > // = data-> list_data-> next;//one after head.< / span > < span class = cF0 >
< a name = "l67" > < / a > CJSONDataHash *temp_hash;
2021-07-03 05:07:57 +01:00
< a name = "l68" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l69" > < / a > JSONIndentLine(indent);
2021-07-03 05:07:57 +01:00
< a name = "l70" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l71" > < / a > < / span > < span class = cF1 > switch< / span > < span class = cF0 > (data-> type)
< a name = "l72" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l73" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_INVALID:
< a name = "l74" > < / a > < / span > < span class = cF6 > " Invalid JSON.\n" < / span > < span class = cF0 > ;
< a name = "l75" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l76" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l77" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_STRING:
< a name = "l78" > < / a > < / span > < span class = cF6 > " %s\n" < / span > < span class = cF0 > , data-> string_data;
< a name = "l79" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l80" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l81" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_INTEGER:
< a name = "l82" > < / a > < / span > < span class = cF6 > " %d\n" < / span > < span class = cF0 > , data-> int_data;
< a name = "l83" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l84" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l85" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_FLOAT:
< a name = "l86" > < / a > < / span > < span class = cF6 > " %.9f\n" < / span > < span class = cF0 > , data-> float_data;
< a name = "l87" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l88" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l89" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_BOOL:
< a name = "l90" > < / a > < / span > < span class = cF6 > " %Z\n" < / span > < span class = cF0 > , data-> bool_data, < / span > < span class = cF6 > " ST_FALSE_TRUE" < / span > < span class = cF0 > ;
< a name = "l91" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l92" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l93" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_NULL:
< a name = "l94" > < / a > < / span > < span class = cF6 > " Null.\n" < / span > < span class = cF0 > ;
< a name = "l95" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l96" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l97" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_ARRAY:
< a name = "l98" > < / a > < / span > < span class = cF6 > " Array:\n" < / span > < span class = cF0 > ;
< a name = "l99" > < / a > JSONIndentLine(indent);
< a name = "l100" > < / a > < / span > < span class = cF6 > " [\n" < / span > < span class = cF0 > ;
< a name = "l101" > < / a > entry = data-> list_data-> next;< / span > < span class = cF2 > //one after head.< / span > < span class = cF0 >
< a name = "l102" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (entry != data-> list_data)< / span > < span class = cF2 > //head ignored, stop on head.< / span > < span class = cF0 >
< a name = "l103" > < / a > {
< a name = "l104" > < / a > JSONDataRep(entry, indent + < / span > < span class = cFE > 1< / span > < span class = cF0 > ); < / span > < span class = cF2 > // recursive Rep on the list entry< / span > < span class = cF0 >
< a name = "l105" > < / a > entry = entry-> next;
< a name = "l106" > < / a > }
< a name = "l107" > < / a > JSONIndentLine(indent);
< a name = "l108" > < / a > < / span > < span class = cF6 > " ]\n" < / span > < span class = cF0 > ;
< a name = "l109" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l110" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l111" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > JSONT_OBJ:
< a name = "l112" > < / a > < / span > < span class = cF6 > " Object.\n" < / span > < span class = cF0 > ;
< a name = "l113" > < / a > JSONIndentLine(indent);
< a name = "l114" > < / a > < / span > < span class = cF6 > " {\n" < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l115" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l116" > < / a > keys = JSONGetKeys(data-> hash_table);
< a name = "l117" > < / a > count = < / span > < span class = cF5 > MSize< / span > < span class = cF0 > (keys) / < / span > < span class = cF1 > sizeof< / span > < span class = cF0 > (< / span > < span class = cF1 > U8< / span > < span class = cF0 > *);
2021-07-03 05:07:57 +01:00
< a name = "l118" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l119" > < / a > < / span > < span class = cF1 > for< / span > < span class = cF0 > (index = < / span > < span class = cFE > 0< / span > < span class = cF0 > ; index < count; index++)
< a name = "l120" > < / a > {
< a name = "l121" > < / a > JSONIndentLine(indent);
< a name = "l122" > < / a > < / span > < span class = cF6 > " Key: %s\n" < / span > < span class = cF0 > , keys[index];
< a name = "l123" > < / a > temp_hash = < / span > < span class = cF5 > HashFind< / span > < span class = cF0 > (keys[index], data-> hash_table, HTT_JSON);
< a name = "l124" > < / a > JSONDataRep(temp_hash-> data, indent + < / span > < span class = cFE > 1< / span > < span class = cF0 > );
< a name = "l125" > < / a > }
< a name = "l126" > < / a > JSONIndentLine(indent);
< a name = "l127" > < / a > < / span > < span class = cF6 > " }\n" < / span > < span class = cF0 > ;
< a name = "l128" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
< a name = "l129" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l130" > < / a > }
< a name = "l131" > < / a >
< a name = "l132" > < / a > CJSONDataEntry *JSONParse(< / span > < span class = cF9 > CCompCtrl< / span > < span class = cF0 > *cc)
< a name = "l133" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l134" > < / a > CJSONDataEntry *result = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CJSONDataEntry< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l135" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > tk, last_tk;
< a name = "l136" > < / a > < / span > < span class = cF1 > Bool< / span > < span class = cF0 > is_done = < / span > < span class = cF3 > FALSE< / span > < span class = cF0 > ;
< a name = "l137" > < / a > CJSONDataEntry *temp_entry;< / span > < span class = cF2 > // = JSONParse(cc);< / span > < span class = cF0 >
< a name = "l138" > < / a > CJSONDataHash *temp_hash = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CJSONDataHash< / span > < span class = cF7 > )< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l139" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l140" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (tk = < / span > < span class = cF5 > Lex< / span > < span class = cF7 > (< / span > < span class = cF0 > cc< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l141" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l142" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > ClassRep(cc);< / span > < span class = cF0 >
< a name = "l143" > < / a > < / span > < span class = cF1 > switch< / span > < span class = cF0 > (tk)
< a name = "l144" > < / a > {
2021-07-03 05:07:57 +01:00
< a name = "l145" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l146" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF6 > '}'< / span > < span class = cF0 > :
< a name = "l147" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected Value, got '}'." < / span > < span class = cF0 > );
< a name = "l148" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF3 > TK_STR< / span > < span class = cF0 > :
< a name = "l149" > < / a > result-> type = JSONT_STRING;
< a name = "l150" > < / a > result-> string_data = < / span > < span class = cF5 > StrNew< / span > < span class = cF0 > (cc-> cur_str);
2021-07-03 05:07:57 +01:00
< a name = "l151" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l152" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l153" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l154" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l155" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF3 > TK_I64< / span > < span class = cF0 > : < / span > < span class = cF2 > //todo, LexExcept on 0x or 0b vals.< / span > < span class = cF0 >
< a name = "l156" > < / a > result-> type = JSONT_INTEGER;
< a name = "l157" > < / a > result-> int_data = cc-> cur_i64;
2021-07-03 05:07:57 +01:00
< a name = "l158" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l159" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > LexPush(cc);< / span > < span class = cF0 >
< a name = "l160" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > " got hex val, token string is %s\n" ,cc-> cur_str;< / span > < span class = cF0 >
< a name = "l161" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > ClassRep(cc);< / span > < span class = cF0 >
< a name = "l162" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > Break;< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l163" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l164" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l165" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l166" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l167" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF3 > TK_F64< / span > < span class = cF0 > :
< a name = "l168" > < / a > result-> type = JSONT_FLOAT;
< a name = "l169" > < / a > result-> float_data = cc-> cur_f64;
2021-07-03 05:07:57 +01:00
< a name = "l170" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l171" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l172" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l173" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l174" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF3 > TK_IDENT< / span > < span class = cF0 > :
< a name = "l175" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!< / span > < span class = cF5 > StrCompare< / span > < span class = cF7 > (< / span > < span class = cF0 > cc-> cur_str, < / span > < span class = cF6 > " true" < / span > < span class = cF7 > )< / span > < span class = cF0 > ||
< a name = "l176" > < / a > !< / span > < span class = cF5 > StrCompare< / span > < span class = cF7 > (< / span > < span class = cF0 > cc-> cur_str, < / span > < span class = cF6 > " false" < / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l177" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l178" > < / a > result-> type = JSONT_BOOL;
2021-07-03 05:07:57 +01:00
< a name = "l179" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l180" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!< / span > < span class = cF5 > StrCompare< / span > < span class = cF7 > (< / span > < span class = cF0 > cc-> cur_str, < / span > < span class = cF6 > " true" < / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l181" > < / a > result-> bool_data = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l182" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!< / span > < span class = cF5 > StrCompare< / span > < span class = cF7 > (< / span > < span class = cF0 > cc-> cur_str, < / span > < span class = cF6 > " false" < / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l183" > < / a > result-> bool_data = < / span > < span class = cF3 > FALSE< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l184" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l185" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l186" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l187" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!< / span > < span class = cF5 > StrCompare< / span > < span class = cF7 > (< / span > < span class = cF0 > cc-> cur_str, < / span > < span class = cF6 > " null" < / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l188" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l189" > < / a > result-> type = JSONT_NULL;
2021-07-03 05:07:57 +01:00
< a name = "l190" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l191" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l192" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l193" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l194" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l195" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l196" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l197" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF6 > '['< / span > < span class = cF0 > :
< a name = "l198" > < / a > result-> type = JSONT_ARRAY;
< a name = "l199" > < / a > result-> list_data = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CJSONDataEntry< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l200" > < / a > < / span > < span class = cF5 > QueueInit< / span > < span class = cF0 > (result-> list_data);
2021-07-03 05:07:57 +01:00
< a name = "l201" > < / a >
< a name = "l202" > < / a > lex_listitem:
< a name = "l203" > < / a > < / span > < span class = cF2 > /*< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l204" > < / a > < / span > < span class = cF2 > CCompCtrl* temp_cc = NULL;< / span > < span class = cF0 >
< a name = "l205" > < / a > < / span > < span class = cF2 > MemCopy(temp_cc, cc, CompCtrlSize(cc));< / span > < span class = cF0 >
< a name = "l206" > < / a > < / span > < span class = cF2 > tk = Lex(temp_cc);< / span > < span class = cF0 >
< a name = "l207" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > CompCtrlDel(temp_cc);< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l208" > < / a > < / span > < span class = cF2 > */< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l209" > < / a > last_tk = tk;
< a name = "l210" > < / a > < / span > < span class = cF5 > LexPush< / span > < span class = cF0 > (cc);
< a name = "l211" > < / a > tk = < / span > < span class = cF5 > Lex< / span > < span class = cF0 > (cc);
2021-07-03 05:07:57 +01:00
< a name = "l212" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l213" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (last_tk == < / span > < span class = cF6 > ','< / span > < span class = cF0 > & & tk == < / span > < span class = cF6 > ']'< / span > < span class = cF0 > )
< a name = "l214" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected List value, got ']'" < / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l215" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l216" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk == < / span > < span class = cF6 > ']'< / span > < span class = cF0 > )
< a name = "l217" > < / a > < / span > < span class = cF1 > goto< / span > < span class = cF0 > lex_listdone;
2021-07-03 05:07:57 +01:00
< a name = "l218" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l219" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk == < / span > < span class = cF6 > ','< / span > < span class = cF0 > )
< a name = "l220" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected List Value, got comma." < / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l221" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l222" > < / a > < / span > < span class = cF5 > LexPopRestore< / span > < span class = cF0 > (cc);
< a name = "l223" > < / a > temp_entry = JSONParse(cc);
< a name = "l224" > < / a > < / span > < span class = cF5 > QueueInsert< / span > < span class = cF0 > (temp_entry, result-> list_data-> last);
2021-07-03 05:07:57 +01:00
< a name = "l225" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l226" > < / a > tk = < / span > < span class = cF5 > Lex< / span > < span class = cF0 > (cc);
< a name = "l227" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk == < / span > < span class = cF6 > ','< / span > < span class = cF0 > )
< a name = "l228" > < / a > < / span > < span class = cF1 > goto< / span > < span class = cF0 > lex_listitem;
2021-07-03 05:07:57 +01:00
< a name = "l229" > < / a >
< a name = "l230" > < / a > lex_listdone:
< a name = "l231" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l232" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > LexPopNoRestore(cc);< / span > < span class = cF0 >
< a name = "l233" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l234" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l235" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l236" > < / a > < / span > < span class = cF1 > case< / span > < span class = cF0 > < / span > < span class = cF6 > '{'< / span > < span class = cF0 > :
< a name = "l237" > < / a > result-> type = JSONT_OBJ;
< a name = "l238" > < / a > result-> hash_table = < / span > < span class = cF5 > HashTableNew< / span > < span class = cF0 > (JSON_HASHTABLE_SIZE);
2021-07-03 05:07:57 +01:00
< a name = "l239" > < / a >
< a name = "l240" > < / a > lex_objkey:
2021-07-04 23:11:34 +01:00
< a name = "l241" > < / a > < / span > < span class = cF2 > //lex next. expect TK_STR. Make a temp_hash.< / span > < span class = cF0 >
< a name = "l242" > < / a > last_tk = tk;
< a name = "l243" > < / a > tk = < / span > < span class = cF5 > Lex< / span > < span class = cF0 > (cc);
2021-07-03 05:07:57 +01:00
< a name = "l244" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l245" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (last_tk == < / span > < span class = cF6 > ','< / span > < span class = cF0 > & & tk == < / span > < span class = cF6 > '}'< / span > < span class = cF0 > )
< a name = "l246" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected Key after comma." < / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l247" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l248" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk == < / span > < span class = cF6 > '}'< / span > < span class = cF0 > )
< a name = "l249" > < / a > < / span > < span class = cF1 > goto< / span > < span class = cF0 > lex_objdone;
2021-07-03 05:07:57 +01:00
< a name = "l250" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l251" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk != < / span > < span class = cF3 > TK_STR< / span > < span class = cF0 > )
< a name = "l252" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected Key String." < / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l253" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l254" > < / a > temp_hash = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CJSONDataHash< / span > < span class = cF7 > )< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l255" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l256" > < / a > < / span > < span class = cF2 > //set hash type and StrNew with cc-> cur_str into hash str.< / span > < span class = cF0 >
< a name = "l257" > < / a > temp_hash-> type = HTT_JSON;
< a name = "l258" > < / a > temp_hash-> str = < / span > < span class = cF5 > StrNew< / span > < span class = cF0 > (cc-> cur_str);
2021-07-03 05:07:57 +01:00
< a name = "l259" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l260" > < / a > < / span > < span class = cF2 > //lex next. expect ':'. < / span > < span class = cF0 >
< a name = "l261" > < / a > tk = < / span > < span class = cF5 > Lex< / span > < span class = cF0 > (cc);
< a name = "l262" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk != < / span > < span class = cF6 > ':'< / span > < span class = cF0 > )
< a name = "l263" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected ':' after Key String." < / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l264" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l265" > < / a > < / span > < span class = cF2 > //now expect JSONDataEntry-able value next.< / span > < span class = cF0 >
< a name = "l266" > < / a > < / span > < span class = cF2 > //Recursive JSONParse into hash data member.< / span > < span class = cF0 >
< a name = "l267" > < / a > temp_hash-> data = JSONParse(cc);
2021-07-03 05:07:57 +01:00
< a name = "l268" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l269" > < / a > < / span > < span class = cF2 > //JSONParse leaves off on the last token. e.g. int, tk will< / span > < span class = cF0 >
< a name = "l270" > < / a > < / span > < span class = cF2 > //still be TK_I64.< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l271" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l272" > < / a > < / span > < span class = cF2 > //add hash to result hash_table.< / span > < span class = cF0 >
< a name = "l273" > < / a > < / span > < span class = cF5 > HashAdd< / span > < span class = cF0 > (temp_hash, result-> hash_table);
< a name = "l274" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > " Debugging.\nHash added with str:%s.\n" ,temp_hash-> str;< / span > < span class = cF0 >
< a name = "l275" > < / a > < / span > < span class = cF2 > //< / span > < span class = cF0 > < / span > < span class = cF2 > ClassRep(temp_hash-> data);< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l276" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l277" > < / a > < / span > < span class = cF2 > //lex next. expect ',' or '}'.< / span > < span class = cF0 >
< a name = "l278" > < / a > tk = < / span > < span class = cF5 > Lex< / span > < span class = cF0 > (cc);
< a name = "l279" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk != < / span > < span class = cF6 > ','< / span > < span class = cF0 > & & tk != < / span > < span class = cF6 > '}'< / span > < span class = cF0 > )
< a name = "l280" > < / a > < / span > < span class = cF5 > LexExcept< / span > < span class = cF0 > (cc, < / span > < span class = cF6 > " Expected ',' or '}' after Object Value." < / span > < span class = cF0 > );
< a name = "l281" > < / a > < / span > < span class = cF2 > //if ',' ... Terry's parsing code would imply labels and gotos.< / span > < span class = cF0 >
< a name = "l282" > < / a > < / span > < span class = cF2 > //i wonder if there's a better, less BASIC way.< / span > < span class = cF0 >
< a name = "l283" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (tk == < / span > < span class = cF6 > ','< / span > < span class = cF0 > )
< a name = "l284" > < / a > < / span > < span class = cF1 > goto< / span > < span class = cF0 > lex_objkey;
2021-07-03 05:07:57 +01:00
< a name = "l285" > < / a > lex_objdone:
< a name = "l286" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l287" > < / a > is_done = < / span > < span class = cF3 > TRUE< / span > < span class = cF0 > ;
< a name = "l288" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
< a name = "l289" > < / a > }
2021-07-03 05:07:57 +01:00
< a name = "l290" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l291" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (is_done)
< a name = "l292" > < / a > < / span > < span class = cF1 > break< / span > < span class = cF0 > ;
< a name = "l293" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l294" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l295" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > result;
2021-07-03 05:07:57 +01:00
< a name = "l296" > < / a > }
< a name = "l297" > < / a >
< a name = "l298" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > Test(< / span > < span class = cF1 > U8< / span > < span class = cF0 > *filename)
< a name = "l299" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l300" > < / a > < / span > < span class = cF9 > CCompCtrl< / span > < span class = cF0 > *cc = < / span > < span class = cF5 > CompCtrlNew< / span > < span class = cF0 > (< / span > < span class = cF5 > MStrPrint< / span > < span class = cF7 > (< / span > < span class = cF6 > " #include \" %s\" " < / span > < span class = cF0 > , filename< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l301" > < / a > CJSONDataEntry *result = JSONParse(cc);
2021-07-03 05:07:57 +01:00
< a name = "l302" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l303" > < / a > JSONDataRep(result);
2021-07-03 05:07:57 +01:00
< a name = "l304" > < / a > }
< a name = "l305" > < / a >
< a name = "l306" > < / a > < / span > < span class = cF5 > Cd< / span > < span class = cF0 > (< / span > < span class = cF3 > __DIR__< / span > < span class = cF0 > );
< a name = "l307" > < / a > Test(< / span > < span class = cF6 > " JSON1.TXT" < / span > < span class = cF0 > );< / span > < / pre > < / body >
< / html >