Mercurial > repos > rhope
comparison parser_old.rhope @ 48:a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 02 Mar 2010 00:18:49 -0500 |
parents | aabda74c7a88 |
children | 3e20ed8959c4 |
comparison
equal
deleted
inserted
replaced
47:6202b866d72c | 48:a24eb366195c |
---|---|
65 ]Import <<["Import"] | 65 ]Import <<["Import"] |
66 ]Blueprint <<["Blueprint"] | 66 ]Blueprint <<["Blueprint"] |
67 ]Global Separator <<["::"] | 67 ]Global Separator <<["::"] |
68 ]Hex Escape <<["x"] | 68 ]Hex Escape <<["x"] |
69 ]Uses <<["uses"] | 69 ]Uses <<["uses"] |
70 ]Escape Map <<[[[[New@Dictionary[]]Set["n","\n"]]Set["r","\r"]]Set["t","\t"]] | 70 ]Escape Map <<[[[[Dictionary[]]Set["n","\n"]]Set["r","\r"]]Set["t","\t"]] |
71 } | 71 } |
72 | 72 |
73 Blueprint Output Reference | 73 Blueprint Output Reference |
74 { | 74 { |
75 Index | 75 Index |
83 | 83 |
84 Add Pipe Reference[refs,name,reference:out] | 84 Add Pipe Reference[refs,name,reference:out] |
85 { | 85 { |
86 reflist <- [refs]Index[name] {} | 86 reflist <- [refs]Index[name] {} |
87 { | 87 { |
88 reflist <- New@List[] | 88 reflist <- () |
89 } | 89 } |
90 out <- [refs]Set[name, [reflist]Append[reference]] | 90 out <- [refs]Set[name, [reflist]Append[reference]] |
91 } | 91 } |
92 | 92 |
93 Assignment Save Reference[refs,assignment,output num,parse worker,index:out] | 93 Assignment Save Reference[refs,assignment,output num,parse worker,index:out] |
109 } | 109 } |
110 | 110 |
111 New@Parse Program[:out] | 111 New@Parse Program[:out] |
112 { | 112 { |
113 out <- [[[Build["Parse Program"] | 113 out <- [[[Build["Parse Program"] |
114 ]Workers <<[New@Dictionary[]] | 114 ]Workers <<[Dictionary[]] |
115 ]Imports <<[New@Dictionary[]] | 115 ]Imports <<[[Dictionary[]]Set["kernel.rhope", Yes]] |
116 ]Blueprints <<[New@Dictionary[]] | 116 ]Blueprints <<[Dictionary[]] |
117 } | 117 } |
118 | 118 |
119 Blueprint Blueprint Definition | 119 Blueprint Blueprint Definition |
120 { | 120 { |
121 Name | 121 Name |
139 Output Types | 139 Output Types |
140 } | 140 } |
141 | 141 |
142 New@Parse Worker[name,inputs,outputs,intypes,outtypes,line:out] | 142 New@Parse Worker[name,inputs,outputs,intypes,outtypes,line:out] |
143 { | 143 { |
144 out <- [[[[[[[[Build["Parse Worker"]]Name <<[name]]Inputs <<[inputs]]Outputs <<[outputs]]Line Number <<[line]]Trees <<[New@List[]]]Uses Stores <<[New@List[]]]Input Types <<[intypes]]Output Types <<[outtypes] | 144 out <- [[[[[[[[Build["Parse Worker"]]Name <<[name]]Inputs <<[inputs]]Outputs <<[outputs]]Line Number <<[line]]Trees <<[()]]Uses Stores <<[()]]Input Types <<[intypes]]Output Types <<[outtypes] |
145 } | 145 } |
146 | 146 |
147 Blueprint Worker Node | 147 Blueprint Worker Node |
148 { | 148 { |
149 Name | 149 Name |
153 Index | 153 Index |
154 } | 154 } |
155 | 155 |
156 New@Worker Node[name,params:out] | 156 New@Worker Node[name,params:out] |
157 { | 157 { |
158 out <- [[[[Build["Worker Node"]]Name <<[name]]Params <<[params]]Assignments <<[New@List[]]]Blocks <<[New@List[]] | 158 out <- [[[[Build["Worker Node"]]Name <<[name]]Params <<[params]]Assignments <<[()]]Blocks <<[()] |
159 } | 159 } |
160 | 160 |
161 Add List Helper[inlist,worker,program,key,parse worker,refs:out list,out worker,out refs] | 161 Add List Helper[inlist,worker,program,key,parse worker,refs:out list,out worker,out refs] |
162 { | 162 { |
163 ,nextworker,nextrefs <- [[inlist]Index[key]]Add to Worker[worker, program, parse worker, refs] | 163 ,nextworker,nextrefs <- [[inlist]Index[key]]Add to Worker[worker, program, parse worker, refs] |
415 has block <- Yes | 415 has block <- Yes |
416 } | 416 } |
417 | 417 |
418 New@Field Node[name,params,set:out] | 418 New@Field Node[name,params,set:out] |
419 { | 419 { |
420 out <- [[[[[Build["Field Node"]]Name <<[name]]Assignments <<[New@List[]]]Blocks <<[New@List[]]]Set? <<[set]]Params <<[params] | 420 out <- [[[[[Build["Field Node"]]Name <<[name]]Assignments <<[()]]Blocks <<[()]]Set? <<[set]]Params <<[params] |
421 } | 421 } |
422 | 422 |
423 Add to Worker@Field Node[node,worker,program,parse worker,refs:out node,out worker,out refs] | 423 Add to Worker@Field Node[node,worker,program,parse worker,refs:out node,out worker,out refs] |
424 { | 424 { |
425 If[[node]Set? >>] | 425 If[[node]Set? >>] |
472 } | 472 } |
473 } | 473 } |
474 | 474 |
475 New@Named Pipe Node[name:out] | 475 New@Named Pipe Node[name:out] |
476 { | 476 { |
477 out <- [[[Build["Named Pipe Node"]]Name <<[name]]Assignments <<[New@List[]]]Blocks <<[New@List[]] | 477 out <- [[[Build["Named Pipe Node"]]Name <<[name]]Assignments <<[()]]Blocks <<[()] |
478 } | 478 } |
479 | 479 |
480 Add to Worker@Named Pipe Node[node,worker,program,parse worker,refs:out node,out worker,out refs] | 480 Add to Worker@Named Pipe Node[node,worker,program,parse worker,refs:out node,out worker,out refs] |
481 { | 481 { |
482 [[parse worker]Inputs >>]Find[[node]Name >>] | 482 [[parse worker]Inputs >>]Find[[node]Name >>] |
549 Index | 549 Index |
550 } | 550 } |
551 | 551 |
552 New@Global Node[store,name:out] | 552 New@Global Node[store,name:out] |
553 { | 553 { |
554 out <- [[[[Build["Global Node"]]Store <<[store]]Name <<[name]]Assignments <<[New@List[]]]Blocks <<[New@List[]] | 554 out <- [[[[Build["Global Node"]]Store <<[store]]Name <<[name]]Assignments <<[()]]Blocks <<[()] |
555 } | 555 } |
556 | 556 |
557 Add to Worker@Global Node[node,worker,unused,parse worker,refs:out node,out worker,refs] | 557 Add to Worker@Global Node[node,worker,unused,parse worker,refs:out node,out worker,refs] |
558 { | 558 { |
559 out worker <- [worker]Add Global Get[[node]Store >>, [node]Name >>] {} | 559 out worker <- [worker]Add Global Get[[node]Store >>, [node]Name >>] {} |
587 out <- Yes | 587 out <- Yes |
588 } | 588 } |
589 | 589 |
590 New@Literal Node[value:out] | 590 New@Literal Node[value:out] |
591 { | 591 { |
592 out <- [[[Build["Literal Node"]]Value <<[value]]Assignments <<[New@List[]]]Blocks <<[New@List[]] | 592 out <- [[[Build["Literal Node"]]Value <<[value]]Assignments <<[()]]Blocks <<[()] |
593 } | 593 } |
594 | 594 |
595 Add to Worker@Literal Node[node,worker,unused,parse worker,refs:out node,out worker,out refs] | 595 Add to Worker@Literal Node[node,worker,unused,parse worker,refs:out node,out worker,out refs] |
596 { | 596 { |
597 out worker <- [worker]Add Constant[[node]Value >>] {} | 597 out worker <- [worker]Add Constant[[node]Value >>] {} |
704 | 704 |
705 Block Comment[string,begin comment,end comment,block count:out] | 705 Block Comment[string,begin comment,end comment,block count:out] |
706 { | 706 { |
707 If[[block count] > [0]] | 707 If[[block count] > [0]] |
708 { | 708 { |
709 after, before <- [string]Get DString[[[New@List[]]Append[begin comment]]Append[end comment]] {} {} | 709 after, before <- [string]Get DString[[[()]Append[begin comment]]Append[end comment]] {} {} |
710 { | 710 { |
711 If[[~] = [begin comment]] | 711 If[[~] = [begin comment]] |
712 { | 712 { |
713 out <- Block Comment[after, begin comment, end comment, [block count]+[1]] | 713 out <- Block Comment[after, begin comment, end comment, [block count]+[1]] |
714 }{ | 714 }{ |
802 name lines <- 0 | 802 name lines <- 0 |
803 ,body <- [~]Get Comment DString[ [params]Block End >>, params] | 803 ,body <- [~]Get Comment DString[ [params]Block End >>, params] |
804 { | 804 { |
805 body lines <- [body]Split["\n"] | 805 body lines <- [body]Split["\n"] |
806 more lines <- [[[body lines]Length] - [1]] + [name lines] | 806 more lines <- [[[body lines]Length] - [1]] + [name lines] |
807 fields <- Fold[["Process Blueprint Field"]Set Input[2, params], New@List[], Filter[Map[body lines, ["Trim"]Set Input[1,"\n\r\t "]], "Filter Empty"]] | 807 fields <- Fold[["Process Blueprint Field"]Set Input[2, params], (), Filter[Map[body lines, ["Trim"]Set Input[1,"\n\r\t "]], "Filter Empty"]] |
808 new tree <- [tree]Blueprints << [ [[tree]Blueprints >>]Set[name, New@Blueprint Definition[name, fields]] ] | 808 new tree <- [tree]Blueprints << [ [[tree]Blueprints >>]Set[name, New@Blueprint Definition[name, fields]] ] |
809 out <- Null[~, params, new tree, [lines] + [more lines]] | 809 out <- Null[~, params, new tree, [lines] + [more lines]] |
810 } {} { | 810 } {} { |
811 out <- [tree]Errors <<[ [[tree]Errors >>]Append[New@Parse Error["Error",[["Blueprint is missing an block close symbol \""]Append[[params]Block End >>]]Append["\""], lines]] ] | 811 out <- [tree]Errors <<[ [[tree]Errors >>]Append[New@Parse Error["Error",[["Blueprint is missing an block close symbol \""]Append[[params]Block End >>]]Append["\""], lines]] ] |
812 } | 812 } |
835 { | 835 { |
836 check block <- Comment Left Trim[string, "\n\r\t ", params] | 836 check block <- Comment Left Trim[string, "\n\r\t ", params] |
837 If[[check block]Starts With[[params]Block Begin >>]] | 837 If[[check block]Starts With[[params]Block Begin >>]] |
838 { | 838 { |
839 ,begin block <- [check block]Slice[[[params]Block Begin >>]Length] | 839 ,begin block <- [check block]Slice[[[params]Block Begin >>]Length] |
840 trees, after block <- Worker Body[begin block, params, New@List[]] | 840 trees, after block <- Worker Body[begin block, params, ()] |
841 blocks, after <- Get Expression Blocks[after block, params, [blocks]Append[trees]] | 841 blocks, after <- Get Expression Blocks[after block, params, [blocks]Append[trees]] |
842 }{ | 842 }{ |
843 If[[check block]Starts With[[params]Empty Block >>]] | 843 If[[check block]Starts With[[params]Empty Block >>]] |
844 { | 844 { |
845 blocks <- blocks | 845 blocks <- blocks |
867 } | 867 } |
868 } | 868 } |
869 | 869 |
870 Parse String[string,params,current:value,after] | 870 Parse String[string,params,current:value,after] |
871 { | 871 { |
872 delims <- [[New@List[]]Append[[params]String End >>]]Append[[params]String Escape >>] | 872 delims <- [[()]Append[[params]String End >>]]Append[[params]String Escape >>] |
873 afters, before, delim <- [string]Get Comment DString[delims, params] | 873 afters, before, delim <- [string]Get Comment DString[delims, params] |
874 { | 874 { |
875 If[[delim] = [[params]String End >>]] | 875 If[[delim] = [[params]String End >>]] |
876 { | 876 { |
877 value <- [current]Append[before] | 877 value <- [current]Append[before] |
950 value,after <- Parse String[string begin, params, ""] | 950 value,after <- Parse String[string begin, params, ""] |
951 }{ | 951 }{ |
952 If[[name]Starts With[[params]List Begin >>]] | 952 If[[name]Starts With[[params]List Begin >>]] |
953 { | 953 { |
954 ,list start <- [name]Slice[[[params]List Begin >>]Length] | 954 ,list start <- [name]Slice[[[params]List Begin >>]Length] |
955 value,after <- Parse List[list start, params, New@List[]] | 955 value,after <- Parse List[list start, params, ()] |
956 }{ | 956 }{ |
957 If[[[name]Slice[1]]In["-0123456789"]] | 957 If[[[name]Slice[1]]In["-0123456789"]] |
958 { | 958 { |
959 value,after <- Parse Number[name, params] | 959 value,after <- Parse Number[name, params] |
960 }{ | 960 }{ |
1053 expression <- Worker or Field[name, more args, params] | 1053 expression <- Worker or Field[name, more args, params] |
1054 } | 1054 } |
1055 | 1055 |
1056 Postfix or Infix[string,params:expression,after] | 1056 Postfix or Infix[string,params:expression,after] |
1057 { | 1057 { |
1058 args, after args <- Parse Arguments[string, params, New@List[]] | 1058 args, after args <- Parse Arguments[string, params, ()] |
1059 delims <- [[[[[("\n")]Append[[params]Arg Begin >>]]Append[[params]Empty Block >>]]Append[[params]Block Begin >>]]Append[[params]Arg End >>]]Append[[params]List Delim >>] | 1059 delims <- [[[[[("\n")]Append[[params]Arg Begin >>]]Append[[params]Empty Block >>]]Append[[params]Block Begin >>]]Append[[params]Arg End >>]]Append[[params]List Delim >>] |
1060 aftere,before,delim <- [after args]Get Comment DString[delims, params] | 1060 aftere,before,delim <- [after args]Get Comment DString[delims, params] |
1061 { | 1061 { |
1062 If[[delim] = [[params]Arg Begin >>]] | 1062 If[[delim] = [[params]Arg Begin >>]] |
1063 { | 1063 { |
1091 If[[maybe name]Contains[[params]List Delim >>]] | 1091 If[[maybe name]Contains[[params]List Delim >>]] |
1092 { | 1092 { |
1093 after expression <- [after literal]Append[[delim]Append[after]] | 1093 after expression <- [after literal]Append[[delim]Append[after]] |
1094 expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params] | 1094 expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params] |
1095 }{ | 1095 }{ |
1096 expression, after expression <- Prefix[after, params, maybe name, New@List[]] | 1096 expression, after expression <- Prefix[after, params, maybe name, ()] |
1097 } | 1097 } |
1098 } | 1098 } |
1099 }{ | 1099 }{ |
1100 If[[delim] = [[params]Assign >>]] | 1100 If[[delim] = [[params]Assign >>]] |
1101 { | 1101 { |
1123 expression, after expression <- Named Pipe or Literal[trimmed, params] | 1123 expression, after expression <- Named Pipe or Literal[trimmed, params] |
1124 } | 1124 } |
1125 } | 1125 } |
1126 //Any expression can be followed by one or more blocks mapping the inputs of other expressions | 1126 //Any expression can be followed by one or more blocks mapping the inputs of other expressions |
1127 //to the outputs of the current one | 1127 //to the outputs of the current one |
1128 blocks,after blocks <- Get Expression Blocks[after expression, params, New@List[]] | 1128 blocks,after blocks <- Get Expression Blocks[after expression, params, ()] |
1129 final expression <- [expression]Blocks <<[blocks] | 1129 final expression <- [expression]Blocks <<[blocks] |
1130 } | 1130 } |
1131 } | 1131 } |
1132 | 1132 |
1133 Worker Body[string,params,trees:trees,after end] | 1133 Worker Body[string,params,trees:trees,after end] |
1234 { | 1234 { |
1235 worker name <- Trim[whitespace name, "\n\r\t "] | 1235 worker name <- Trim[whitespace name, "\n\r\t "] |
1236 Print[["Parsing worker: "]Append[worker name]] | 1236 Print[["Parsing worker: "]Append[worker name]] |
1237 in out <- [params]In Out Delim >> | 1237 in out <- [params]In Out Delim >> |
1238 arg end <- [params]Arg End >> | 1238 arg end <- [params]Arg End >> |
1239 delims <- [[New@List[]]Append[in out]]Append[arg end] | 1239 delims <- [[()]Append[in out]]Append[arg end] |
1240 after <- [~]Get Comment DString[delims, params] {} | 1240 after <- [~]Get Comment DString[delims, params] {} |
1241 { | 1241 { |
1242 arglist <- Trim[~,"\r\n\t "] | 1242 arglist <- Trim[~,"\r\n\t "] |
1243 }{ | 1243 }{ |
1244 //check if there is an in/out separator | 1244 //check if there is an in/out separator |
1266 New@Parse Worker[worker name, inputs, outputs, input types, output types, 0] | 1266 New@Parse Worker[worker name, inputs, outputs, input types, output types, 0] |
1267 { | 1267 { |
1268 Print["Got parse worker"] | 1268 Print["Got parse worker"] |
1269 body text, modifiers <- [after arglist]Get Comment DString[[params]Block Begin >>, params] | 1269 body text, modifiers <- [after arglist]Get Comment DString[[params]Block Begin >>, params] |
1270 modified <- Process Modifiers[~, params, modifiers] | 1270 modified <- Process Modifiers[~, params, modifiers] |
1271 expression trees, after body <- Worker Body[body text, params, New@List[]] | 1271 expression trees, after body <- Worker Body[body text, params, ()] |
1272 worker <- [modified]Trees <<[expression trees] | 1272 worker <- [modified]Trees <<[expression trees] |
1273 new worker dict <- [[tree]Workers >>]Set[worker name, worker] | 1273 new worker dict <- [[tree]Workers >>]Set[worker name, worker] |
1274 out <- Null[after body, params, [tree]Workers <<[new worker dict], 0] | 1274 out <- Null[after body, params, [tree]Workers <<[new worker dict], 0] |
1275 } | 1275 } |
1276 } | 1276 } |
1316 | 1316 |
1317 Add Workers Compile[prog, worker, name:out] | 1317 Add Workers Compile[prog, worker, name:out] |
1318 { | 1318 { |
1319 Print[["Add Workers Compile: "]Append[name]] | 1319 Print[["Add Workers Compile: "]Append[name]] |
1320 { | 1320 { |
1321 trees, nworker, refs <- Add List to Worker[[worker]Trees >>, [NWorker["rhope"]]Uses[[worker]Uses Stores >>], prog, worker, New@Dictionary[]] | 1321 trees, nworker, refs <- Add List to Worker[[worker]Trees >>, [NWorker["rhope"]]Uses[[worker]Uses Stores >>], prog, worker, Dictionary[]] |
1322 final nworker <- Fold[[["Add Wires Helper"]Set Input[3, worker]]Set Input[4, refs], nworker, trees] | 1322 final nworker <- Fold[[["Add Wires Helper"]Set Input[3, worker]]Set Input[4, refs], nworker, trees] |
1323 out <- [prog]Bind Worker[name, final nworker] | 1323 out <- [prog]Bind Worker[name, final nworker] |
1324 } | 1324 } |
1325 } | 1325 } |
1326 | 1326 |
1327 Add Wires Helper[worker,node,unused,parse worker,assignments:out] | 1327 Add Wires Helper[worker,node,unused,parse worker,assignments:out] |
1328 { | 1328 { |
1329 Print["Add Wires Helper"] | 1329 Print["Add Wires Helper"] |
1330 { | 1330 { |
1331 out <- [node]Add Wires[worker, New@List[], parse worker, assignments] | 1331 out <- [node]Add Wires[worker, (), parse worker, assignments] |
1332 { Print["Add Wires Helper Done"] } | 1332 { Print["Add Wires Helper Done"] } |
1333 } | 1333 } |
1334 } | 1334 } |
1335 | 1335 |
1336 Add Contents[parse worker,name,program:out,key] | 1336 Add Contents[parse worker,name,program:out,key] |
1337 { | 1337 { |
1338 Print[["Add Contents: "]Append[name]] | 1338 Print[["Add Contents: "]Append[name]] |
1339 worker <- [[program]Find Worker[name]]Uses[[parse worker]Uses Stores >>] | 1339 worker <- [[program]Find Worker[name]]Uses[[parse worker]Uses Stores >>] |
1340 trees, contents worker, refs <- Add List to Worker[[parse worker]Trees >>, worker, program, parse worker, New@Dictionary[]] | 1340 trees, contents worker, refs <- Add List to Worker[[parse worker]Trees >>, worker, program, parse worker, Dictionary[]] |
1341 Fold[[["Add Wires Helper"]Set Input[3, parse worker]]Set Input[4, refs], contents worker, trees] | 1341 Fold[[["Add Wires Helper"]Set Input[3, parse worker]]Set Input[4, refs], contents worker, trees] |
1342 out <- [parse worker]Trees <<[trees] | 1342 out <- [parse worker]Trees <<[trees] |
1343 key <- name | 1343 key <- name |
1344 } | 1344 } |
1345 | 1345 |
1378 } | 1378 } |
1379 | 1379 |
1380 Tree to Program[parse tree:out] | 1380 Tree to Program[parse tree:out] |
1381 { | 1381 { |
1382 Print["Tree to Program"] | 1382 Print["Tree to Program"] |
1383 out <- _Tree to Program[parse tree, [New@Program[]]Add Builtins] | 1383 out <- _Tree to Program[parse tree, [Program[]]Add Builtins] |
1384 { Print["done"] } | 1384 { Print["done"] } |
1385 } | 1385 } |
1386 | 1386 |
1387 Tree to Program Native[parse tree:out] | 1387 Tree to Program Native[parse tree:out] |
1388 { | 1388 { |
1389 registered <- Fold["Register Workers Compile", Fold["Add Blueprint Compile", [NProgram[]]Register Builtins, [parse tree]Blueprints >>], [parse tree]Workers >>] | 1389 registered <- Fold["Register Workers Compile", [Fold["Add Blueprint Compile", NProgram[], [parse tree]Blueprints >>]]Register Builtins, [parse tree]Workers >>] |
1390 out <- Fold["Add Workers Compile", registered, [parse tree]Workers >>] | 1390 out <- Fold["Add Workers Compile", registered, [parse tree]Workers >>] |
1391 { Print["Transformed AST to dataflow graph "] } | 1391 { Print["Transformed AST to dataflow graph "] } |
1392 } | 1392 } |
1393 | 1393 |
1394 Needs Imports[needs import,not imported?,name:out] | 1394 Needs Imports[needs import,not imported?,name:out] |
1409 out <- [after import]Imports <<[ [[after import]Imports >>]Set[file name, No] ] | 1409 out <- [after import]Imports <<[ [[after import]Imports >>]Set[file name, No] ] |
1410 } | 1410 } |
1411 | 1411 |
1412 Process Imports[parse tree,params:out] | 1412 Process Imports[parse tree,params:out] |
1413 { | 1413 { |
1414 needs import <- Fold["Needs Imports", New@List[], [parse tree]Imports >>] | 1414 needs import <- Fold["Needs Imports", (), [parse tree]Imports >>] |
1415 If[[[needs import]Length] > [0]] | 1415 If[[[needs import]Length] > [0]] |
1416 { | 1416 { |
1417 import tree <- Fold[["Do Import"]Set Input[3, params], parse tree, needs import] | 1417 import tree <- Fold[["Do Import"]Set Input[3, params], parse tree, needs import] |
1418 out <- Process Imports[import tree, params] | 1418 out <- Process Imports[import tree, params] |
1419 }{ | 1419 }{ |
1474 Init Used Stores[import tree, stores] | 1474 Init Used Stores[import tree, stores] |
1475 { _REPL[params, _Tree to Program[import tree, prog], ~] } | 1475 { _REPL[params, _Tree to Program[import tree, prog], ~] } |
1476 } | 1476 } |
1477 }{ | 1477 }{ |
1478 Print["Expression"] | 1478 Print["Expression"] |
1479 trees <- Worker Body[[line]Append["}"], params, New@List[]] | 1479 trees <- Worker Body[[line]Append["}"], params, ()] |
1480 { Print["Parse done"] } | 1480 { Print["Parse done"] } |
1481 tree <- [New@Worker Node["Val", [New@List[]]Append[[trees]Index[0]]]]Assignments <<[("__out")] | 1481 tree <- [New@Worker Node["Val", [()]Append[[trees]Index[0]]]]Assignments <<[("__out")] |
1482 { Print["Constructed new tree"] } | 1482 { Print["Constructed new tree"] } |
1483 this stores <- [[tree]Gather Stores[params, New@Dictionary[]]]Keys | 1483 this stores <- [[tree]Gather Stores[params, Dictionary[]]]Keys |
1484 { Print["Got stores"] } | 1484 { Print["Got stores"] } |
1485 next stores <- Fold["_Init Used Store", stores, this stores] | 1485 next stores <- Fold["_Init Used Store", stores, this stores] |
1486 { | 1486 { |
1487 Print["Initialized stores"] | 1487 Print["Initialized stores"] |
1488 pworker <- [[New@Parse Worker["__Eval", New@List[], ("__out"), 0]]Trees <<[[New@List[]]Append[tree]]]Uses Stores <<[this stores] | 1488 pworker <- [[New@Parse Worker["__Eval", (), ("__out"), 0]]Trees <<[[()]Append[tree]]]Uses Stores <<[this stores] |
1489 { Print["Constructed parse worker"] } | 1489 { Print["Constructed parse worker"] } |
1490 } | 1490 } |
1491 [[prog]Find Worker["__Eval"]]Clear | 1491 [[prog]Find Worker["__Eval"]]Clear |
1492 { | 1492 { |
1493 Print["Cleared worker"] | 1493 Print["Cleared worker"] |
1494 Add Contents[pworker, "__Eval", prog] | 1494 Add Contents[pworker, "__Eval", prog] |
1495 { | 1495 { |
1496 Print["Added Contents"] | 1496 Print["Added Contents"] |
1497 Pretty Print[[[[prog]Find Worker["__Eval"]]Do[New@List[]]]Index[0], ""] | 1497 Pretty Print[[[[prog]Find Worker["__Eval"]]Do[()]]Index[0], ""] |
1498 { | 1498 { |
1499 Print["Finished executeion"] | 1499 Print["Finished executeion"] |
1500 _REPL[params, prog, next stores] } } } | 1500 _REPL[params, prog, next stores] } } } |
1501 } | 1501 } |
1502 } | 1502 } |
1504 | 1504 |
1505 REPL[params] | 1505 REPL[params] |
1506 { | 1506 { |
1507 Print["Rhope Alpha 2\nCopyright 2008 by Michael Pavone\nEntering interactive mode\n"] | 1507 Print["Rhope Alpha 2\nCopyright 2008 by Michael Pavone\nEntering interactive mode\n"] |
1508 prog <- Tree to Program[Null["Val[in:out]\n{\n out <- in\n}\n__Eval[:__out]\n{\n}\n", params, New@Parse Program[], 0]] | 1508 prog <- Tree to Program[Null["Val[in:out]\n{\n out <- in\n}\n__Eval[:__out]\n{\n}\n", params, New@Parse Program[], 0]] |
1509 _REPL[params, prog, New@Dictionary[]] | 1509 _REPL[params, prog, Dictionary[]] |
1510 } | 1510 } |
1511 | 1511 |
1512 Add If Store[stores,name,params:out] | 1512 Add If Store[stores,name,params:out] |
1513 { | 1513 { |
1514 If[[name]Contains[[params]Global Separator >>]] | 1514 If[[name]Contains[[params]Global Separator >>]] |