-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved support for xword and exword (xml like tags, dec, to-word, x…
…mlgen example
- Loading branch information
Showing
4 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters