Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
refaktor committed Mar 27, 2024
2 parents 649b6d1 + ca386ec commit 5f1d4d9
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/xmlgen/try1.rye
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

private {

prn\depth: fn { t d } { prn produce d "" { + " " } , prn t }
is-not: fn { a b } { a = b |not }
; enter-console "asdasd"

proc: fnc { val blk depth current } current-ctx {
sleep 1000
for-all blk { :bk
switch type? tok: peek bk {
xword { print "" , prn\depth tok depth , proc val next bk inc depth tok } ; todo -- maybe make it recursive so you know current word
exword { print tok , depth: depth - 1 , tok .to-word = to-word current \not \if { print "Error" } , return 1 }
block { with val tok \type? .is-not 'function \if { .prn } }
string { prn\depth join { "<!-- " tok " -->" } depth }
}
}
}
fnc { val blk } current-ctx { proc val blk 0 'no }
} :xmlgen

xml-template: {

<header>
<author> ( name ) </author>
</header
<data>
<name code="asda"> ( .fullname ) </name>
"Surname next"
<surname> ( -> "surname" ) </surname>
</data>
}

do { fullname: fn1 { -> "name" :n , -> "surname" :s , n + " " + s } }
do { input "Enter author's name:" :name , does { } }

xmlgen dict { "name" "Jim" "surname" "Metelko" } xml-template

0 comments on commit 5f1d4d9

Please sign in to comment.