Received: by 10.50.41.134 with SMTP id f6mr8485153igl.0.1334696335529; Tue, 17 Apr 2012 13:58:55 -0700 (PDT) X-BeenThere: lepl@googlegroups.com Received: by 10.50.188.136 with SMTP id ga8ls4793936igc.0.canary; Tue, 17 Apr 2012 13:58:54 -0700 (PDT) Received: by 10.50.217.193 with SMTP id pa1mr8354576igc.1.1334696334838; Tue, 17 Apr 2012 13:58:54 -0700 (PDT) Received: by 10.50.213.40 with SMTP id np8msigc; Sat, 14 Apr 2012 18:02:58 -0700 (PDT) Received: by 10.50.156.134 with SMTP id we6mr1960113igb.3.1334451778169; Sat, 14 Apr 2012 18:02:58 -0700 (PDT) Received: by 10.50.156.134 with SMTP id we6mr1960112igb.3.1334451778158; Sat, 14 Apr 2012 18:02:58 -0700 (PDT) Return-Path: Received: from smtp.webfaction.com (mail6.webfaction.com. [74.55.86.74]) by gmr-mx.google.com with ESMTP id wf3si1336144igb.3.2012.04.14.18.02.57; Sat, 14 Apr 2012 18:02:58 -0700 (PDT) Received-SPF: neutral (google.com: 74.55.86.74 is neither permitted nor denied by best guess record for domain of and...@acooke.org) client-ip=74.55.86.74; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 74.55.86.74 is neither permitted nor denied by best guess record for domain of and...@acooke.org) smtp.mail=and...@acooke.org Received: from acooke.org (190-21-131-144.baf.movistar.cl [190.21.131.144]) by smtp.webfaction.com (Postfix) with ESMTP id 9CB72209E9FB for ; Sat, 14 Apr 2012 20:02:57 -0500 (CDT) Received: by acooke.org (Postfix, from userid 1000) id 81F96605CF; Sat, 14 Apr 2012 22:02:55 -0300 (CLST) Date: Sat, 14 Apr 2012 22:02:55 -0300 From: andrew cooke To: lepl@googlegroups.com Subject: Re: [LEPL] Output or serialize ASTs to XML, JSON? Message-ID: <20120415010255.GA21250@acooke.org> References: <26718421.754.1334444638699.JavaMail.geo-discussion-forums@pbcr5> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26718421.754.1334444638699.JavaMail.geo-discussion-forums@pbcr5> User-Agent: Mutt/1.5.21 (2010-09-15) 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. >