hi,
at first i was a bit confused by this, because lepl doesn't really enforce any
kind of ast - you can construct whatever you want.
but then i remembered that many of the examples use the List class (and in
older versions used the Node class). so i am guessing you're referring to
that?
if so, then it extends an ordinary python list (the [....] thing) so i expect
the standard json libraries could handle it. however, you will lose the type
(the class name) which is often important.
so i guess (eventually!) what you are asking is: if you're constructing an ast
using List subclasses, how can you convert that into xml in a way that keeps
the class name?
which is a good question (and the short answer is that there is nothing
already available).
i've just tried playing around with some ideas, but it depends very much what
your ast looks like.
so could you reply with an example of an ast and the kind of xml you'd like,
and i can reply with something more helpful?
the reason i can't give a general reply is because often asts contain lists of
values, and i don't see a single obvious way to stick lists of things in xml
(you can use attributes or text or surround them with elements, but i don't
know what would be best, or what attribute or element name you'd want, without
something to guide me).
andrew
ps if json would work then you could perhaps use pytyp
http://www.acooke.org/pytyp/pytyp.s11n.json.html but i get the impression you
would prefer xml and working out how to use pytyp is itself a fair amount of
effort...
On Sat, Apr 14, 2012 at 04:03:58PM -0700, KPrichard wrote:
> I am curious if LEPL has direct support for serializing ASTs into a
> corresponding textual representation, such as XML. If not, how would one
> go about producing same.
> I'd like to run a series of XPath queries against the ASTs. e.g. to query
> a repository of source code for usage patterns, best or forbidden
> practices, and the like.
> I prefer something like XPath over node inspection in python, because it
> has simple, tree-aware relational query capabilities.
> Great project, by the way.
> Regards,
> KPrichard
> --
> You received this message because you are subscribed to the Google Groups "lepl" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/lepl/-/aqRLl_tkFcYJ.
> To post to this group, send email to lepl@googlegroups.com.
> To unsubscribe from this group, send email to lepl+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/lepl?hl=en.