Qui, 2008-10-02 às 12:55 +0100, Tim Bunce escreveu: > Like applying XPath to an XML DOM, only more general and taken > further. > By "more general and taken further" I'm thinking of the same kind of > evoltion from simple regular expressions in perl5 to grammars in perl6. > An XPath query is like a perl5 regular expression.
During YAPC::EU::2007 (yeah... some time ago...) we had this discussion motivated by the need to have something easier to transform parse trees... In that case, we were thinking about programming-language-translators that would take the parse tree of one language, make some modifications in the tree before emitting the other language (i.e.: turning specific language dialects, for instance some uses of map and grep in perl5, to a language that doesn't support map and grep, then turning that into a different p5 construct that could be effectively translated to the target language). One thing we realized at that time is that XPath is good enough, even if it seems to be adressing XML specifically, it has the concept of "dimension" that can be extended to represent arbitrary aspects of objects. When we then take XQuery into account, we might have all the tools to build an coherent tree-oriented Rule system. xgrammar Foo { xtoken bar { 'some XPath expression' <subtoken> { make 'some XQuery expression' } } xtoken subtoken { 'some other Xpath expression' { make 'yet another xquery expression' } } } Of course we still need to think how to compose different xpath expressions and how to make captures of it, but maybe XQuery already solves that problem... daniel