Re: XML support in E
Mark Miller <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Jan 16, 2010 at 5:19 PM, Kevin Reid <[email protected]> wrote: > > That does seem like something I might have written, but I don't recall > where I might have done so. I did write a guard called Termish, but it > was just an incidental example of using trinary-define; what it did > was match recursive trees of ["tagname", subterms...]. > http://www.eros-os.org/pipermail/e-lang/2005-August/010942.html > > Now that I see it, I'm rather sure that is what I was remembering. But it inspired a good solution: def AntiTerm { to coerce(specimen, optEjector) { if (specimen.getOptData() =~ data :notNull) { return data } def term`@{tag :String}(@{args :List[AntiTerm]}*)` exit optEjector := specimen if (tag == ".tuple.") { return args } if (tag == ".bag.") { def result := [].asMap().diverge() for arg in args { if (arg =~ [`.attr.`, key, value]) { result[key] := value } else { return [tag] + args } } return result.snapshot() } return [tag] + args } } ? term`{[1,2]:[3,4], foo:oo(bar)}` :AntiTerm # value: [[1, 2] => [3, 4], ["foo"] => ["oo", ["bar"]]] -- Text by me above is hereby placed in the public domain Cheers, --MarkM _______________________________________________ e-lang mailing list [email protected] http://www.eros-os.org/mailman/listinfo/e-lang