Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » PHP Parser(Using org.eclipse.php.internal to parse PHP files for static analysis)
PHP Parser [message #652205] Thu, 03 February 2011 05:18 Go to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: February 2011
Junior Member
Hi,
I'm trying to develop a program for static analysis of PHP scripts. I want to use eclipse internal classes for parsing the file and generating the AST. But I can't find any sort of documentation regarding org.eclipse.php.internal or similar namespaces. For example, I'm trying the following for getting the program constructs:

import org.eclipse.php.internal.core.*;
import org.eclipse.php.internal.core.ast.nodes.AST;
import org.eclipse.php.internal.core.ast.nodes.Program;
...
Reader reader = new FileReader("test.php");
AST a = new AST(reader, PHPVersion.PHP5, true, true);
Program p = new Program(a);

But it simply does nothing. I need a sort of documentation, and article etc about how to use the pdt classes. Any idea?
Alternatively, do you know any other documented Php parser/ast generator in java?

Thanks in advance.
Re: PHP Parser [message #652218 is a reply to message #652205] Thu, 03 February 2011 07:28 Go to previous messageGo to next message
Roy Ganor is currently offline Roy GanorFriend
Messages: 149
Registered: July 2009
Senior Member
Here is a detailed document about exactly the same information:

http://www.eclipse.org/pdt/articles/ast/PHP_AST.html

Will be happy to hear about your analysis it may be relevant to this project as well?

Roy
Re: PHP Parser [message #652384 is a reply to message #652218] Thu, 03 February 2011 17:32 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: February 2011
Junior Member
Thanks Roy,
Though I'd already read that article, I couldn't really use it since some of things there seems to be deprecated. But your reply encouraged me to reconsider it, again and this time it magically worked(Maybe because I have downloaded some additional JARs).
I'm still at the beginning phase but I will try to develop it as soon as I can. I will publish a link in this forum as soon as it is finished.

Ali.
Re: PHP Parser [message #985645 is a reply to message #652384] Thu, 15 November 2012 15:17 Go to previous message
Saale Man is currently offline Saale ManFriend
Messages: 3
Registered: November 2012
Junior Member
Hi,

I am trying to write a program that parses a PHP file and detects all sql queries in that file. I am a beginner and I am not sure, where is the right point to start with Embarrassed . I also read the article linked by Roy and some examples were running well in my eclipse, but not all examples and i couldn't got the AST View plug-in running in my eclipse 3.6. I doubt if the AST is enough to solve my problem.

Does anyone know if it is possible to get all sql queries from the AST or should I go another way to get the sql queries?

Thanks in advance.


sorry for spelling errors! I'm just learning English Smile
Previous Topic:Zen php debugger
Next Topic:Include Path does auto complete include() function?
Goto Forum:
  


Current Time: Thu Apr 25 08:04:13 GMT 2024

Powered by FUDForum. Page generated in 0.03578 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top