;; ============================================== ;; Script: rebol-dom.r ;; downloaded from: www.REBOL.org ;; on: 19-Mar-2024 ;; at: 8:25:19.646269 UTC ;; owner: inetw3dm [script library member who can ;; update this script] ;; ============================================== ;; =================================================== ;; email address(es) have been munged to protect ;; them from spam harvesters. ;; If you were logged on the email addresses would not ;; be munged ;; =================================================== REBOL [ File: %rebol-dom.r Date: 05-01-2021 Title: "Dialect Object Model" Emai: inetw3.dm(a)gmail.com author: daniel murrill version: 1.0 Purpose: { Use an exstensible, Rebol user-mode, Markup function to parse DSL's that will return an easy to follow tagged key value Dialect Object Model. It will allow different DSL's or programming languages to work with, or together through a Central Processing interpreter. Yes Rebol/Core. A demo example of a HTML DSL is parsed by the Dialect Object Model to return valid HTML, then processed by the %Mdlparser wich in return creates UI VID code. All scripting takes place in the DOM and then passed as VID code to Rebol/View. So instead of writing parse rules for DSL's, you work with your DSL as a DOM and immediatley began to write code for it as if it's is programming.} ] Notes: { All code and data should be in the Sequence data type. In Rebol, the way to send, recieve, or save your code/data is by way of MOLD(). In the DOM, code/data and Var are never loaded outside of the DOM or node-list. When parsing takes place, it loads as a sequence of strings. They should be READ() or streamed in or out. Limited executions. The Var methods must use Return.() if you want to return values. Only the returning Key values are loaded. This defualt behavoir can easily be changed. Once a Var is created, its variable, node-name, and elements are strings, unless you set the sequence as a series, wich should not be loaded. So in the interpreter, key-values, variables and node-elements have no #value, and no context. Because it's not code, nor data turned into code. It's all Domain specific data in an exstensible Dialect Object Model.} library: [ author: daniel murrill level: 'advanced platform: 'all type: [Dialects Markup] domain: [html vid css json js array] tested-under: 'windows support: none license: none see-also: %Mdlparser.r version: 1.0 ] ;Demonstration data: Copy&Paste.... You must replace all "%----" with ".@", due to obfuscation. ;Download or use the last updated copy from the history page. my-dialect: [ rebol-DOM: [{DSL-type="html/block" type="text/html"}] lua-tbl = {[first] = "fred", [last] = "cougar"} #this-issue [{color: "purple" bgcolor: "orange"}] var anObj = {`100: 'a', `2: 'b', `7: 'c', }; body: [{background-color="blue" text "white"} ] p: [ {"color":"#0000ff", "bgcolor":"yellow", "width" : "399", "height" : "100" "font-styles": "big" } This is an example of an Dialect Oject Model b: [ {id="my-p1" color = "Chocolate" bgcolor = "yellow"} that can be written to look like json' html' javascript arrays' css' i: [ {color = "green"} VID' or plain old rebol ] ] if you like. ] hr: [{color="red" bgcolor="yellow"}] div: [ {width="399" bgcolor="orange"} b: [ {color: "purple" bgcolor: "orange"} Maybe it would be easier to write i: [ {id="my-p1" color: "green"} MakeDoc.r code but the purpose of this rebol DOM is'] ] ] p: [ {width "399" height= 200 style="color: red; bgcolor: brown; border: 2x2;" } b: [ {color="red"} to read or load as many well known dialects of coding styles as possible and write all of it as a single or seperate legible rebol series that's quickly manipulated' transcoded as html' and viewed as a VID. ] ] ] node-list: to hash! [] .style: [] equal?: := DOM: DSL: html: window: end-tag: "" data-node: parent-node: slf*: node: key: *key: *value: k: v: none .body: .hr: .p: .b: .i: .tr: .ul: .li: .area: .table: .td: .button: .input: .div: .font: .span: count: 0 array-obj!: node-obj: node-element: *variable: *node-name: node-name: *name: use-methods: attr-name: attr-value: none check: func [select-this][return pick parse trim strip-chars-from form select-this none " " 1] *get: func[this][ attempt [this]] affix: func [code][*get insert code [clear ] | code] reappend: func [with this-data][append with to-block mold rejoin this-data] rescind: func [variable][var form variable] imply: func [with][do load strip-obj-chars-from mold self: with inferred] insert-this: func [put-this at-here][do head insert here: find copy key at-here put-this] void: does [data-node: node-element: none slf*: "" count: 0] as-data-node*: func [data-node][to block! data-node] as-series*: func [series with-chars][to block! strip-obj-chars-from form series with-chars] as-sequence*: func [series with-this][ to block! strip-obj-chars-from strip-obj-chars-from form series with-this none ] clear-node-list: does [foreach [var node] node-list [ attempt [set to-set-word var none]]clear node-list] use*=*to-set-values: does [=: func [value][any [value]]] use-attr-as-methods: func [maybe [logic!]][ if no != maybe [ strip-obj-chars-from node-element [{" } {" .} ".." "."]] replace node-element " " " ." use-methods: off ] elemt-chars: none strip-chars-from: func [node-name elemt-chars][ foreach char elemt-chars: any [elemt-chars ["<" ">" "{" "}" "(" ")" {"} "/" "." "[" "]" "," ":" ";" "," "=" "`"] ][ replace/all node-name char " " ] ] obj-chars: +char: none strip-obj-chars-from: func [node-name obj-chars][ attempt [replace replace node-element "={" {="} ";}" {;"}] attempt [trim form node-name if equal? #"^"" node-name/1 [remove node-name] foreach [-char +char] obj-chars: any [obj-chars [#"^/" " " " " " " {" , "} {" } {", "} {" } "," " " {" "} {" } {" : "} {: "} {":"} {: "} {":} {:} { " } "" {"[["} {"[[" "} "{" "[" "}" "]" {""} {"} { "} "" " : " ": " ":" " " { =} {=} {=} " " "'" "" "#" "" "<" "" ">" "" "`" "" "_" " "] ][ replace/all node-name -char +char ]] ] document.getnodename: func [request][document. getnodename request] document.: func [request-as][ DOM: head DOM use*=*to-set-values any [ all [data-node node-name: check node-element: data-node/1] all [insert data-node: [] node-element: request-as node-name: check data-node/1 ]] any [all [equal? tag! type? node-element strip-obj-chars-from node-element ["{" "" "[" "" "}" "" "]" ""]] node-element] either count >= 1 [me: parse slf* ":" var replace node-element node-name any [ attempt [first to-block me] slf*]] [var node-element] me: parse slf* join ":" count .style: :array-obj! attempt [replace node-element first parse node-element " :" last to-block me] return node-element count: 0 ] .return-tag-node: func [node-name][DOM: head DOM node: either equal? word! type? node-name [ either any [attempt [empty? node-element] equal? none node-element] [select node-list form node-name][node-name]][node-name] any [ all [equal? node none print rejoin [{node-name: (} node-name ") not in node-list."]] equal? tag! type? node-element: node attempt [node-element: data-node: build-tag to-block strip-obj-chars-from form node none] set 'node-element node]node-name: check node-element return probe node-element ] getnodename: func [node-name][ DOM: head DOM =: :equal? slf*: data-node: [] node-element: none either block! = type? node-name[.return-tag-node node-name][ node-name: to block! strip-chars-from form node-name none count: any [attempt [count: pick find node-name integer! 1]1] nodename: to-word join "." array-obj!: node-name/1 any [attempt [repeat ? count [data-node: first DOM: next node: find DOM nodename]] all [print rejoin [{node-name: (} node-name/1 "." count ") not found."]count: 0] ] any [switch count [0 [slf*: join node-name/1 " "]] slf*: join node-name/1 count] ] if " " = data-node [data-node: form first DOM: next DOM] return either tag! = type? data-node/1 [node-element: data-node/1][node-element: data-node] ] getElementByTagName: func [Tag-Name selection [block!]][ dom: head dom repeat this count: first selection [ node-element: first data-node: first dom: next find dom to-word join "." Tag-Name] if all [equal? true use-methods not find node-element " ."][use-attr-as-methods yes] use-methods: off slf*: join Tag-name count ] setnodename: func [old-name new-name][ any [equal? this-name: check old-name check node-element getnodename old-name] any [equal? none not find node-element new-name try [ replace node-element to string! this-name new-name replace data-node to-tag join "/" this-name to-tag join "/" new-name] ] ] getattribute: func [attr-name][ attr-value: none print any [all [attr-value: array-obj!(attr-name) [attr-name " " attr-value] ]["attribute: " attr-name " not found"] ] ] setattribute: func [attr-name new-attr][ *key: *value: none .style: array-obj!: |: func [key] do compose/deep [body-of (to-get-word variable)] any [ all [.style((attr-name)) *value: *key `= (new-attr)] | [reappend [" " new-attr{="undefined"}]] print ["Must get a parent-node with this attribute: " attr-name]] obj-chars: [=[`=]]();get-attributes node-element attempt [set-attributes] ] setattributevalue: func [attr-name attr-value][ *key: *value: none .style: array-obj!: |: func [key] do compose/deep [body-of (to-get-word variable)] any [ all [.style((attr-name)) if *value [`= (attr-value)]] | [reappend [" " attr-name{="}attr-value{"}]] print ["Must get a parent-node with this attribute: " attr-name] ]obj-chars: [=[`=]]() ;get-attributes node-element attempt [set-attributes] ] look-deep-for: func [this from-this-parent][ foreach in-child-tag-node from-this-parent [ if all [tag! = type? child: in-child-tag-node find/any child this][ insert data-node: [] node node-element: child slf*: rejoin [slf* ":" *name: first parse node-element " "]] if block! = type? node: in-child-tag-node [look-deep-for this in-child-tag-node] ] ] getElementById: func [my-id][in-child-node: none count: 1 id: copy join "id*" slf*: form my-id =: :equal? foreach in-parent-node dom [ if block! = type? node: in-parent-node [look-deep-for id in-parent-node ]] ] querySelecter: func [css-Selecter][in-child-node: none count: 1 id: rejoin [slf*: css-Selecter "*"] =: :equal? foreach in-parent-node dom [ if block! = type? node: in-parent-node [look-deep-for id in-parent-node ]] ] .innerHTML: func [with-html][ some-children: copy/part next data-node find/last data-node tag! either equal? tag! type? node-element [ any [all [empty? with-html some-children] replace data-node some-children with-html] ][print "The node-element has no innerHTML"] ] var: func [var-data][node-element: variable: "" .style: none any [ attempt [variable: first parse node-element: var-data "=:, "] attempt [all [equal? datatype! type? do last load var-data variable: pick var-data 1 type: length? var-data strip-obj-chars-from insert node-element: join [] do load reform [ "to" var-data/(type) mold reform [var-data/2]] do reform [mold/only [#1: ] ] "'"]] attempt [if equal? block! type? var-data [variable: first node-element: var-data]] attempt [variable: var-data node-element: ""] ] use*=*to-set-values node-name: variable: to-string variable obj-chars: [] replace node-element node-name nodename: first parse form node-name form count either empty? node-element [any [find node-list variable append node-list reduce [variable node-element: any [attempt [do :variable] node-element]]]] [any [find node-list node-name append node-list reduce [form variable node-element]]] set to-word variable array-obj!: func [key] compose/deep copy get-array-obj! any [find variable "." set to-word trim/all reform [variable "."] :array-obj!] use-methods: off *variable: none if equal? word! type? var-data [clear node-element] () ] get-array-obj!: [ node-element: select node-list variable: (form variable) |: &.: :array-obj! strip-obj-chars-from node-element ["={" {="} ";}" {;"}] attempt [all [inline: find/any node-element { style=*"} replace node-element inline replace/all replace replace inline {"} "{" {"} "}" " " ": "]] if all [not find form node-element "1:" tag! != type? node-element][ all [equal? (length? parse form node-element ":= ,") 1 node-element: join {#1: } node-element ]] all [attempt [find struc reduce ['const to-word form key] const]] any [ if empty? form key [strip-obj-chars-from node-element ["={" {="} ";}" {;"}] array-obj!: replace body-of :array-obj! select body-of :array-obj! [variable:] variable |: array-obj!: func[key] array-obj! return any [ if equal? tag! type? node-element [node-element] attempt [find/tail copy head node-element first parse node-element " ,"] next node-element]*key: key: *value: value: none ] if all [*key: first to-block key not find node-element rejoin [" " *key " "] equal? integer! type? *key][ values: any [attempt [parse head node-element "<=;,`#: []>"] load strip-obj-chars-from mold node-element none] keys: length? replace/all values [""][] if odd? length? values [remove values] any [equal? 1 *key *key: *key + *key - 1] *value: any [*value: select values *key: pick values *key *value ] if *value [print ["*key:" *key " *value: " *value: *value ]] node-name: keys: none ] if equal? path! type? key[] if equal? refinement! type? key[attempt [do replace/all form key "." "/."]] if find ["url!" "email!" "tag!" "refinement!"] mold type? key [ attempt [key: to-string parse replace/all to-string key "." "/." "/"] strip-obj-chars-from key [":" ":." "@" ": " ".." "."] replace/all from-method: parse key ".:" [""] [] foreach key from-method [any [attempt [| to-block key] | mold key]] ] any [ attempt [*value: load select/case parse strip-obj-chars-from copy node-element none none *key: trim trim head tail form key] attempt [*value: select/case load strip-obj-chars-from mold to-block node-element none *key: key]] attempt [do head any [append insert next copy key [node-element join] "" insert next load key 'node-element]] attempt [do load key] attempt [*get-methods key] attempt [do *get-expressions key none] if not find node-element key [*key: value: none obj-chars]] ] new: func [previuos-node][as-variable: form copy variable with-element: do reform [previuos-node {""}] any [ if find node-list double-variables: any [ reduce [as-variable as-variable] reduce [as-variable ""] ][replace node-list double-variables [] var reform [join as-variable ":" load with-element] do reform [variable {""}]] if *variable [attempt [var rejoin [*variable ": " with-element] do reform [*variable {""}]]] all [replace node-list [""] rejoin [as-variable ": " with-element] do reform [as-variable {""}]]] ] proto-type: func [as-object new-name][ old-name: check as-object append :as-object parent-url!: to-string reduce [new-name "::" new-name] var append replace replace node: copy head as-object old-name new-name parent-url! " " to-string reduce [" parent::" old-name]() ] *!: func [new-var][use*=*to-set-values either find node-list this: any [ reduce [variable variable] reduce [variable to-word variable]] [replace node-list this [] count: 0 var var-data: reform [new-var last this] ][strip-obj-chars-from node-element reduce [variable new-var " " " "] slf*: rejoin [ form new-var ":" node-name: new-var] data-node: none document. node-element] ] .: func [value /local *val][either equal? block! type? *value [*val: copy *value any [ if equal? integer! type? *key: first to-block value [ any [equal? 1 *key *key: *key + *key - 1] attempt [do [value: select *value *key: pick *value *key *value: to-block value]]] attempt [*value: first next *value: find *value value] attempt [*value: head *value *value: next find *value value] attempt [*value: *val load value]] ][any [attempt [do compose/deep reduce [*value [(load value)]]]*value]] ] some: func [next-key][ either obj-chars [translate next-key][ foreach try-this next-key [ any [find-with: all [equal? block! type? try-this go-to: *key] find-with: *key: *value: none] any [all [equal? *value none | try-this find node-element *key: any [try-this form try-this] function! != type? *key print ["*key: " *key " *value: " *value: form *value ]] any [all [find-with key: first back find next-key reduce [ go-to try-this] find [url! email! tag! refinement!] to word! type? go-to | key key: *value do try-this]]] key: any [key *key try-this]] ()] ] translate: func [transitive][intransitive: [] any [all [ equal? [] obj-chars/2 clear intransitive ]insert clear intransitive [|]] all [obj-chars strip-obj-chars-from transitive obj-chars] foreach next-key transitive [ any [ if equal? '. next-key [next-key: []] all [equal? word! type? next-key '`= != next-key append intransitive reduce ['| form next-key]] all [equal? block! type? next-key attempt [append intransitive do compose/deep [ (load form strip-obj-chars-from next-key obj-chars)]]] append intransitive next-key]] replace/all intransitive [`= |] [`=] attempt [ | append intransitive [return. 0]] probe strip-obj-chars-from intransitive reduce [|[] [] '| [] [return. 0] []] obj-chars: none() ] into-any: :strip-obj-chars-from *negate: :negate negate: func [seq][any [attempt [*negate seq] into-any seq reduce [*variable 'get]()]] delegate: func [seq with [email!] define action][ this: to-word skip form with 2 any [ all [equal? word! type? seq do reform [seq {""}] negate action set this :| set to-word join '. this does [| (action)] any [into-any (attempt [back back find action [get[]]]) reduce ['get *variable: to-word variable] | insert action compose [(*variable: to-word variable) []]] ] all [equal? tag! type? seq var to-word skip form with 2 affix [|[reappend [variable " " mold/only action]]]] all [do reform [action {""}] negate seq set this :| set to-word join '. this does [| (seq)] any [into-any (attempt [back back find seq [get[]]]) reduce ['get *variable: to-word variable] | insert seq compose [(*variable: to-word variable) []]] ]] ] const: does [*key: *value: none] *word: [replace replace node-element *value *value: join "'`" form as-sequence* *value ["@" ""]"'`'`" "'`" nil] str: string: does [replace node-element *value *value: mold mold form *value nil] char: does [replace node-element *value *value: any [attempt[to char! form *value] *value: "unset!"] nil] int: does [replace node-element *value *value: any [attempt[to integer! *value] *value: "unset!"] nil] nil: does [replace node-element [nil] {"unset!"}] of: func [this][ either equal? type? block! this [first attempt [do this]][attempt [do this]]] destruct: func [*value][load find/match *value "'`"] struc: [] `=: func[attr-value][ if equal? block! type? *key [ any [ all [equal? integer! type? first *key *key: to issue! to string! reduce [*key ":"]] attempt [*key: load *key/1] *key: (all [equal? set-word! type? *key *key]) *key: to word! form *key] ]any [ all [find struc reduce ['const to-word form *key] const] attempt [if *key [replace with: find/last node-element *key *value *value: form do load form attr-value]] all [key replace node-element form *value form *value: attr-value] all [*value replace node-element *value *value: attr-value] attempt [*value: select node-element *key: load key] ]all [not empty? struc do attempt [first back find struc load *key]] node-element: head node-element ] return.: func [value][ any [ attempt [*value: to-block value foreach a *value [if not equal? word! type? a [do *value: a ]]] attempt [*value: do form reduce load value] ] ] rel-xprsn: to-hash [ " " " " "*va" "-va" " ." "_$" "." " #" { = "} {:== "} {: "} ":::" " *" " set '" "};" {%>"} "] [" "]|[" "}}" "},}" "}," {%>"} "," " " ": " " 1 `= " ":::" {: "} {- "} {- ."} " = " " `= " " {" " .{" " ${" { build-markup "<%} "* " "[] " "()" {("")} "==" " =" "function " "function '" "_$" " ." "var " "var reform " "-va" "*va" "= ." "= " ": ." ": " " #log" ".log" "&" "" ] *get-expressions: func[this expressions][ attempt [ find this: mold this "return 0" strip-obj-chars-from this [{."} {"-} "1." "1-" "2." "2-" "3." "3-" "4." "4-" "5." "5-" "6." "6-" "7." "7-" "8." "8-" "9." "9-" "0." "0-" "\." "~escp"] strip-obj-chars-from this expressions: any [expressions rel-xprsn] strip-obj-chars-from this [{"-} {."} "1-" "1." "2-" "2." "3-" "3." "4-" "4." "5-" "5." "6-" "6." "7-" "7." "8-" "8." "9-" "9." "0-" "0." "~escp" "."] all [ ;| is exspressive, using Do won't eval sequence methods but is simpler and faster. any [attempt [| reduce . this] do this] ]] ] *get-methods: func[this][ attempt [ this: mold this if not find this: next find this "." "return 0" [ | this: do strip-obj-chars-from head this [ "[" "" "]" "" "." "@" {"} "" "ame@" "ame join form '" "ent@" "ent. " "&" { join " " } "=" "`="]] ] ] markup-DOM: func [DSL][ use-methods: string-is-data: no =: :equal? either block! = this-type?: type? DSL [ DOM: copy/deep DSL: load replace/all replace/all mold DSL "__" " " {=""} {="undefined"} any [ find DSL [rebol-DOM: [{DSL-type="html/block" type="text/html"}]] insert DSL [rebol-DOM: [{DSL-type="html/block" type="text/html"}]]] get-data: func [data][ find-end-tag: find data get-word! either find-end-tag [ replace data first find-end-tag to-tag mold to-refinement first find-end-tag ][ insert tail data to-tag join "/" any [*name *node-name]*name: none ] repeat in-data data [ if set-word! = type? in-data [*node-name: copy form in-data replace data in-data node-name: to-word join "." *node-name ] if string! = type? in-data [ foreach key-value [{:*"}{:*:*}{=*"}{=*=}] [either find/any in-data key-value[ strip-obj-chars-from in-data none insert in-data next reform [node-name " "] child: build-tag to-block in-data foreach [a b][{=" } "={" {" "} "*}" "*" {"}][replace/all child a b] replace data in-data child][]] ] if block! = type? in-data [ get-next in-data ] ] ] get-next: func [in-data][ repeat data in-data [ if set-word! = type? data [*name: copy form data replace in-data data node-name: to-word join "." *name ] if string! = type? data [ foreach key-value [{:*"}{:*:*}{=*"}{=*=}][either find/any data key-value[ created-data: copy data strip-obj-chars-from created-data none insert created-data reduce [node-name " "] child: build-tag to-block remove created-data foreach [a b][{=" } "={" {" "} "*}" "*" {"}][replace/all child a b] replace in-data data child][]] ] if block! = type? data [get-data data set to-word *node-name data] ] find-end-tag: find in-data get-word! either find-end-tag[ replace in-data first find-end-tag to-tag mold to-refinement first find-end-tag ][ insert tail in-data to-tag join "/" any [*node-name *name] *node-name: none ] ] repeat with-this-data DSL [ if issue! = type? with-this-data [ node-name: to-word join "." *name: form with-this-data ] if set-word! = type? with-this-data [ replace DSL with-this-data node-name: to-word join "." *name: form with-this-data ] if word! = type? with-this-data [ either '= = with-this-data [string-is-data: yes replace DSL with-this-data "" ][ *name: form with-this-data replace DSL with-this-data node-name: to-word join "." with-this-data] replace DSL reduce [node-name node-name] node-name ] if string! = type? with-this-data [ either string-is-data [ replace DSL with-this-data rejoin [node-name " " with-this-data] ][ foreach key-value [{:*"}{:*:*}{=*"}{=*=}][either find/any with-this-data key-value[ created-data: copy with-this-data strip-obj-chars-from created-data none insert created-data reduce [node-name " "] child: build-tag to-block remove created-data foreach [a b][{=" } "={" {" "} "*}" "*" {"}][replace/all child a b] replace DSL with-this-data child][]] ] string-is-data: no ] if block! = type? with-this-data [ get-data with-this-data ] if get-word! = type? with-this-data [ replace DSL with-this-data to-tag mold to-refinement *name ] ] replace/all dsl "" [] DOM: copy DSL ][ view center-face layout [ backcolor black space 8 across h3 yellow "Need a Dialect Object Model as type! block" return text gray "Your DSL type is: " text red bold form :this-type? return text gray "Some DOM functions will not work properly"] ] ] format-this: func [node-element with-these-chars][ foreach [-char +char] with-these-chars [ replace/all node-element -char +char] do last with-these-chars ] as-js-object!: [ { #} "" {="} {: "} "={" ": {" {""} {"} {" } {", } {", "} {","} [if equal? tag! type? node-element [replace node-element " " ": {"] replace/all node-element { "} {: "} replace/all node-element "::" ":" replace/all node-element " : " ": " if equal? tag! type? node-element [append node-element "}"] ] ] .as-js-object: does [format-this node-element as-js-object!] return-html-dsl: does [ html: copy form any [find head DOM "
" foreach n-name [ ".body " ".hr " ".p " ".b " ".i " ".? " ".tr " ".table " ".td " ".button " ".input " ".div " ".ul " ".li " ".font " ".span " ".img " ".a " ".strong " " ." ".hr " "lua-tbl " ][replace/all html n-name " " ] append replace/all html "" ]hi[] ;Maybe the Var is a parameter in a block. param: [hi] ;And some relative expressions returning the parameters value, by index. |[param.1] do |[param/1][] &.(param/1 _) *value: param/1 .[] *value: first |[] ;Or maybe change the type! using simple Rebol code. replace |[] *value to *value "bats" ;A *demo* Let function that's local to the in scope Variable node-element. let: func [make-scope-with][obj-chars: none make-scope-with: load make-scope-with append |[] reduce [" " to-set-word make-scope-with/1 any [ all [equal? get-word! type? last make-scope-with to first |[] trim strip-obj-chars-from mold/only next make-scope-with ["=" ":" ": :" "" "`" "" "1 " ""]] trim strip-obj-chars-from mold/only next make-scope-with ["=" ":" ": :" "" "`" "" "1 " ""]] ]remove find |[] [" "] ] ;If the value is type! get-word!, it's value type is set to its' paren-node first key-value type! let [me = :hello] hi[me] ;find the key and return any value with set type! find-any hi[] "me" ;You can also use Structures with Sequences. ;Just think, your molded data can remain molded ;and have types. ;This will be hard coded for Delegate methods and ;as a user option for Sequences. struc: [ int width *word height ] delegate} [collect value-of] alter selection ['skipped _] replace selection ['text _] _ Keys-value: {
} fifo.. foreach value-of select=(keys-value).{collect value-of} ;Let's try to use lex + syntax analysis by coding our ;own token/key and function sequence to execute it. ;Sounds hard, but thats just fancy lingo for something ;Rebol finds easy to do many different ways. ;Here's one way to do it. ;To surpress the intransitive block value, remove the probe() word from Translate() ;Use obj-chars: [], but let's make it use Rule index selections. eq?: [ ;This is the eq? rule. it's lex/token is :=, it's syntax, [| *key `=] := [`=] ] obj-chars: reduce [eq?/1 eq?/2] my-p1[] some [ color := purple (|[2]) [print "wow"] id := 'i-robot ]|[] eq?/1: 'as obj-chars: reduce [eq?/1 eq?/2