> There's no language-level support for such use. The arrow is just
> a special-cased comma -- it doesn't create pairs or anything like
> that. (I'm not sure how your example gets parsed as it should,
> either.)
It's easy in a language that's a piquant blend of lisp, awk, and grep.
proc input {type name value args} {
eval [list tag input type $type name $name value $value] $args
}
And of course...
proc tag {tag args} {
lappend list $tag
foreach {name value} $args {
if {"$name" == "-flag"} {
lappend list [string toupper $value]
} else {
lappend list [string toupper $name]=[quote_string $value]
}
}
return <[join $list " "]>
}
And to be complete (sorry for the double negative in the first line):
proc quote_string {string} {
if ![string match "*[^a-zA-Z0-9.-]*"] {
return $string
}
if ![string match "*'*" $string] {
return '$string'
}
if ![string match "*\"*" $string] {
return "\"$string\""
}
regsub -all "'" $string "\\'" string
return '$string'
}