Juanjo Conti wrote: > Hi all! I am wondering if I can use PLY to make some "abstract" > parcing. What's this? I want to parse source code from different > programming languages (programming language independence) and I just > wanna use especific parts of the source code.
The general term for this is data-flow analysis. Compilers use it a lot to optimize the code they generate. Parsing (eg with PLY) would only be a first (simple) step in such an analysis. > a = val_from_touch() > b = 1 > c = a + 3 > some_stuff() > print c > > Especification: > > Source: "X = val_from_touch()" > Sinc: "print Y" Why is b not a sinc? What happened with the output and side-effects of some_stuff()? What happens when you get loops? Is a storage place also a sinc? (eg replace "c = a + 3" with "c = c + a") > As a result from the program I wanna that it could tell that a value > from the source reached a sinc. You need to be a lot more specific before you can implement anything like this. When "reaches" a value a sinc?, ie a = val_from_touch() b = c c = a print b ? > Does something like this exists? Can be done? I don't know, depends on your precise definition of "reach". Most compilers are not really interested in the relation between input and output. Maybe there are other disciplines in data-flow analysis that do care about such properties. It can be done of course, but you need to make a much more precise definition. For example, for every Python statement, define what input "reaches" output. Then define how input "reaches" output for several statements together. Do that for every language you intend to support. Then make a computer program. Sincerely, Albert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ply-hack" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/ply-hack?hl=en -~----------~----~----~----~------~----~------~--~---
