Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Output or serialize ASTs to XML, JSON?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
KPrichard  
View profile  
 More options Apr 14 2012, 7:03 pm
From: KPrichard <kprich...@gmail.com>
Date: Sat, 14 Apr 2012 16:03:58 -0700 (PDT)
Local: Sat, Apr 14 2012 7:03 pm
Subject: Output or serialize ASTs to XML, JSON?

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andrew cooke  
View profile  
 More options Apr 14 2012, 9:02 pm
From: andrew cooke <and...@acooke.org>
Date: Sat, 14 Apr 2012 22:02:55 -0300
Local: Sat, Apr 14 2012 9:02 pm
Subject: Re: [LEPL] Output or serialize ASTs to XML, JSON?

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...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andrew cooke  
View profile  
 More options Apr 17 2012, 5:01 pm
From: andrew cooke <and...@acooke.org>
Date: Tue, 17 Apr 2012 14:01:22 -0700 (PDT)
Local: Tues, Apr 17 2012 5:01 pm
Subject: Re: [LEPL] Output or serialize ASTs to XML, JSON?

my apologies - i sent this reply at the weekend, but google filtered it
(from me - i own this group!) and my spam filter then filtered google's
email to me about spam (yay!) so i didn't see anything until today.  andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »