Mercurial > repos > rhope
diff parser_old.rhope @ 37:640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 05 Oct 2009 23:12:43 -0400 |
parents | 495dddadd058 |
children | 789a146a48e1 |
line wrap: on
line diff
--- a/parser_old.rhope Sat Oct 03 03:18:15 2009 -0400 +++ b/parser_old.rhope Mon Oct 05 23:12:43 2009 -0400 @@ -135,11 +135,13 @@ Line Number Trees Uses Stores + Input Types + Output Types } -New@Parse Worker[name,inputs,outputs,line:out] +New@Parse Worker[name,inputs,outputs,intypes,outtypes,line:out] { - out <- [[[[[[Build["Parse Worker"]]Name <<[name]]Inputs <<[inputs]]Outputs <<[outputs]]Line Number <<[line]]Trees <<[New@List[]]]Uses Stores <<[New@List[]] + 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] } Blueprint Worker Node @@ -300,7 +302,7 @@ { [[parse worker]Outputs >>]Find[assignment] { - ,output index <- [worker]Add Output[assignment, ~] + ,output index <- [worker]Add Typed Output[assignment, ~, [[parse worker]Output Types >>]Index[~]] { Print[ [[[[[[["Wire: " @@ -479,7 +481,7 @@ { [[parse worker]Inputs >>]Find[[node]Name >>] { - after add <- [worker]Add Input[[node]Name >>, ~] {} + after add <- [worker]Add Typed Input[[node]Name >>, ~, [[parse worker]Input Types>>]Index[~]] {} { Print[["Added input, node:"]Append[~]] assign refs <- Fold[[["Assignment Save Reference"]Set Input[3, parse worker]]Set Input[4, ~], refs, [node]Assignments >>] @@ -908,21 +910,8 @@ } } -Blueprint Type Literal -{ - Name - Params -} - -Type Literal[name:out] +Parse Params@Type Instance[literal,params,string:out,after] { - Print["Type Literal"] - out <- [[Build["Type Literal"]]Name <<[name]]Params <<[()] -} - -Parse Params@Type Literal[literal,params,string:out,after] -{ - Print[["Parse Params: "]Append[ [string]Slice[10] ]] plist,after <- Parse List[string,params,()] out <- [literal]Params <<[plist] } @@ -950,7 +939,7 @@ before <- Trim[raw before, "\r\n\t "] If[[delim] = [[params]List Begin >>]] { - value,after <- [Type Literal[before]]Parse Params[params,afterdelim] + value,after <- [Type Instance[before]]Parse Params[params,afterdelim] }{ Val[afterdelim] { @@ -1144,11 +1133,82 @@ } } +Remove Named Pipe Node[element:out] +{ + If[[Type Of[element]] = ["Named Pipe Node"]] + { + out <- [element]Name >> + }{ + If[[Type Of[element]] = ["Type Instance"]] + { + out <- [element]Params <<[ Map[[element]Params >>, "Remove Named Pipe Node"] ] + }{ + out <- element + } + } +} + +Parse Param List[text,paramlist,typelist,params:out params,out types] +{ + delims <- [[()]Append[[params]List Begin >>]]Append[[params]List Delim >>] + after,param name <-[text]Get DString[delims] {} + { + nextlist <- [paramlist]Append[Trim[~, "\r\n\t "]] + next types <- [typelist]Append[paramtype] + }{ + If[[~] = [[params]List Begin >>]] + { + type info,after type <- Parse List[after,params,()] + type <- [type info]Index[0] + { + If[[Type Of[~]] = ["Named Pipe Node"]] + { + before variant <- Type Instance[[type]Name >>] + }{ + before variant <- <- [type]Params <<[ Map[[type]Params >>, "Remove Named Pipe Node"] ] + } + variant <- [type info]Index[1] + { + ,warn <- If[[Type Of[~]] = ["Named Pipe Node"]] + { + paramtype,warn <- [before variant]Set Variant[[variant]Name >>] + } + Val[warn] + { + Print[[[["Warning: Invalid variant for type "]Append[[before variant]Name >>]]Append[" on input "]]Append[param name]] + paramtype <- Val[before variant] + } + }{ + paramtype <- Val[before variant] + } + }{ + paramtype <- Type Instance["Any Type"] + } + [after type]Get DString[","] + { + out params,out types <- Parse Param List[~,nextlist,next types,params] + } {} {} { + out params <- Val[nextlist] + out types <- Val[next types] + } + }{ + paramtype <- Type Instance["Any Type"] + out params,out types <- Parse Param List[after,nextlist,next types,params] + } + + }{ + paramtype <- Type Instance["Any Type"] + out params <- Val[nextlist] + out types <- Val[next types] + } +} + Worker Name[string,params,tree,lines:out] { ,whitespace name <- [string]Get Comment DString[[params]Arg Begin >>, params] { worker name <- Trim[whitespace name, "\n\r\t "] + Print[["Parsing worker: "]Append[worker name]] in out <- [params]In Out Delim >> arg end <- [params]Arg End >> delims <- [[New@List[]]Append[in out]]Append[arg end] @@ -1162,17 +1222,25 @@ { after arglist <- [after]Get Comment DString[arg end, params] {} { - output string <- Trim[~,"\n\r\t "] + outputs,output types <- Parse Param List[~, (), (), params] + { Print["got outputs"] } + { Print["got output types"] } } }{ after arglist <- Val[after] - output string <- "" + outputs <- () + output types <- () } - inputs <- Map[[arglist]Split[[params]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]] - outputs <- Map[[output string]Split[[params]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]] + inputs,input types <- Parse Param List[arglist, (), (), params] + { Print["got inputs"] } + { Print["got input types"] } + + //inputs <- Map[[arglist]Split[[params]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]] + //outputs <- Map[[output string]Split[[params]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]] - New@Parse Worker[worker name, inputs, outputs, 0] + New@Parse Worker[worker name, inputs, outputs, input types, output types, 0] { + Print["Got parse worker"] body text, modifiers <- [after arglist]Get Comment DString[[params]Block Begin >>, params] modified <- Process Modifiers[~, params, modifiers] expression trees, after body <- Worker Body[body text, params, New@List[]]