YAML = YAML Ain't Markup Language [http://www.yaml.org/] YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. Parsers exist for Perl, Python, and Ruby. I have not been able to find any activity for dealing with YAML with tcl (08 Oct 2002). [escargo] ---- Example from [http://www.xml.com/lpt/a/2002/07/24/yaml.html]: the informal data structure PRIVMSG newUri ^http://.* PRIVMSG deleteUri ^delete.* PRIVMSG randomUri ^random.* looks in YAML like --- - - PRIVMSG - newUri - '^http://.*' - - PRIVMSG - deleteUri - ^delete.* - - PRIVMSG - randomUri - ^random.* "Python fans will be happy to note that it uses whitespace as a block delimiter. It also steals ideas from MIME, HTML, XML and SOAP, including aliasing, application-specific types, and a namespace mechanism which is part Java package naming and part XML URI-based namespace naming. But perhaps the biggest influence on YAML is Perl -- which I, as a Python devotee, had to learn not to hold against it! -- especially in the way YAML conceptualizes data structures and types, which it distinguishes into scalars, like integers and strings, and collections, like hashes and arrays." ---- A sample mounting is follwoing (by KATO Kanryu) set data { --- - name: Mark McGwire years: 65 avg: 0.278 - name: Sammy Sosa years: 63 avg: 0.288 } proc parse_context {lines} { #puts $lines set depth 0 set result {} for [] {[llength $lines] > 0} {set lines [lreplace $lines 0 0]} { set line [lindex $lines 0] puts "| $line" if {$line eq ""} continue # - list # key: value regexp -- {( *)(-?)([\w ]*:)? *(.*)} $line match space hyphen key value # puts "$space|$hyphen|$key|$value" # exit set indent [string length $space] if {$indent < $depth} break set depth $indent if {$value eq ""} { set lines [lreplace $lines 0 0] set ret [parse_context $lines] lassign $ret subs lines if {$hyphen eq "-"} { # puts "list context!" lappend result $subs } elseif {$key ne ""} { regexp -- {(.*):} $key match key # puts "Mapping Context!" lappend result $key $subs } else { puts "error!!!" # exit } } if {$hyphen eq "-" && $value ne ""} { # puts "Sequence of Scalar!" # puts "\[$value\]" lappend result $value # exit } if {$key ne "" && $value ne ""} { regexp -- {(.*):} $key match key # puts "Mapping Scalar!" regexp -- {(.*):} $key match key # puts " key: $key" # puts "value: $value" lappend result $key $value # exit } } set lines [linsert $lines 0 nop] return [list $result $lines] } set lines [split $data "\n"] for [] [llength $lines] {set lines [lreplace $lines 0 0]} { set line [lindex $lines 0] # stream begins "---" if {$line eq "---"} { set first 0 # puts "beginning of YAML Stream..." set lines [lreplace $lines 0 0] break } } set ret [parse_context $lines] lassign $ret result lines puts $result exit --- outputs following | - | name: Mark McGwire | hr: 65 | avg: 0.278 | - | - | name: Sammy Sosa | hr: 63 | avg: 0.288 | {name {Mark McGwire} years 65 avg 0.278} {name {Sammy Sosa} years 63 avg 0.288} !!!!!! %|[Category Acronym]|[Category Data Serialization Format]|% !!!!!!