comparison parser_old.rhope @ 40:789a146a48e1

Started adding support for naked values in user defined objects
author Mike Pavone <pavone@retrodev.com>
date Fri, 09 Oct 2009 01:01:26 -0400
parents 640f541e9116
children aabda74c7a88
comparison
equal deleted inserted replaced
39:3d92bc1352c2 40:789a146a48e1
664 New@Blueprint Field[name,type:out] 664 New@Blueprint Field[name,type:out]
665 { 665 {
666 out <- [[Build["Blueprint Field"]]Name <<[name]]Type <<[type] 666 out <- [[Build["Blueprint Field"]]Name <<[name]]Type <<[type]
667 } 667 }
668 668
669 Process Blueprint Field[list,field,delim:out] 669 Process Blueprint Field[list,field,params:out]
670 { 670 {
671 parts <- [field]Split[delim] 671 ,name <- [field]Get DString[[params]List Begin >>]
672 If[[[parts]Length] > [1]] 672 {
673 { 673 type info <- Parse List[~,params,()]
674 out <- [list]Append[New@Blueprint Field[[parts]Index[1], [parts]Index[0]]] 674 type <- [type info]Index[0]
675 }{ 675 {
676 out <- [list]Append[New@Blueprint Field[[parts]Index[0], "Any Type"]] 676 If[[Type Of[~]] = ["Named Pipe Node"]]
677 {
678 before variant <- Type Instance[[type]Name >>]
679 }{
680 before variant <- [type]Params <<[ Map[[type]Params >>, "Remove Named Pipe Node"] ]
681 }
682 variant <- [type info]Index[1]
683 {
684 ,warn <- If[[Type Of[~]] = ["Named Pipe Node"]]
685 {
686 fieldtype,warn <- [before variant]Set Variant[[variant]Name >>]
687 }
688 Val[warn]
689 {
690 Print[[[["Warning: Invalid variant for type "]Append[[before variant]Name >>]]Append[" on field "]]Append[name]]
691 fieldtype <- Val[before variant]
692 }
693 }{
694 fieldtype <- Val[before variant]
695 }
696 }{
697 fieldtype <- Type Instance["Any Type"]
698 }
699 out <- [list]Append[New@Blueprint Field[name, fieldtype]]
700 } {} {} {
701 out <- [list]Append[New@Blueprint Field[name, Type Instance["Any Type"]]]
677 } 702 }
678 } 703 }
679 704
680 Block Comment[string,begin comment,end comment,block count:out] 705 Block Comment[string,begin comment,end comment,block count:out]
681 { 706 {
777 name lines <- 0 802 name lines <- 0
778 ,body <- [~]Get Comment DString[ [params]Block End >>, params] 803 ,body <- [~]Get Comment DString[ [params]Block End >>, params]
779 { 804 {
780 body lines <- [body]Split["\n"] 805 body lines <- [body]Split["\n"]
781 more lines <- [[[body lines]Length] - [1]] + [name lines] 806 more lines <- [[[body lines]Length] - [1]] + [name lines]
782 fields <- Fold[["Process Blueprint Field"]Set Input[2, [params]Blueprint Type Delim >>], 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], New@List[], Filter[Map[body lines, ["Trim"]Set Input[1,"\n\r\t "]], "Filter Empty"]]
783 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]] ]
784 out <- Null[~, params, new tree, [lines] + [more lines]] 809 out <- Null[~, params, new tree, [lines] + [more lines]]
785 } {} { 810 } {} {
786 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]] ]
787 } 812 }