Browse files

added a readme

  • Loading branch information...
1 parent 2e8ea6d commit 2f2bc2c51d3717b705de3792bc3ddcb669a0e18e @robertop committed Feb 18, 2012
Showing with 102 additions and 1 deletion.
  1. +101 −0
  2. +1 −1 premake4.lua
@@ -0,0 +1,101 @@
+PHP Easy LanguagE Toolkit (pelet)
+pelet is a PHP parser library written in C++. This is library does not produce an
+appplication, it is meant to be integrated into programs that need to inspect PHP
+source code (source code editors / IDEs targeting PHP). As an example, an editor may
+use pelet to figure out the classes that were declared in a particular source code
+file. pelet was born out of the [MVC Editor](
+The pelet project aims to conform to the PHP syntax to its fullest. Currently, pelet
+can parse source code written for PHP version 5.3 (closures, namespaces).
+pelet is licensed under the MIT license, meaning that it can be used for Open Source
+and commercial applications. See LICENSE file for details.
+- The library can be compiled and run on Windows and Linux. It will most likely be
+possbile to compile and run this library can run on MAC, however it has not been
+- ICU library is required (ver. 4.2+)
+Optional: These are only needed if you want to make changes to the library (most
+users will not need to do so):
+- Bison
+- re2c
+pelet uses premake as its build system. This enables users to create Makefiles or
+various IDE solutions (MS Visual Studio, CodeBlocks, CodeLite). Before attempting
+to build, please download the ICU 4.2 source from the [ICU]
+Using Make (On Linux)
+git clone /home/user/pelet
+cd /home/user/pelet
+cp /home/user/Downloads/icu4c-4_2_1-src.tgz lib/
+./premake4 icu
+./premake4 prep
+./premake4 gmake
+cd build/gmake
+make config=release
+"./premake4 gmake"
+MSW instructions (Visual Studio Solution)
+git clone C:\Users\user\pelet
+cd C:\Users\user\pelet
+copy C:\Users\user\Downloads\icu4c-4_2_1-src.tgz lib\
+<manually extract and compile the ICU library (Debug & Relase) using the VS solution that ICU
+premake4.exe prep
+premake4.exe vs2008
+Now you can open the pelet solution file under build/vs2008 and build the solution.
+Sample Usage
+pelet is a simple library to use; you create a class that conforms to one or more
+"observer" interfaces. Then you create a parser and give it the file you want to
+parse as well as the observers. The parser will then call the observer methods
+when it enounters an artifact.
+ // create a class to "observe" for artifacts
+ class SampleObserver : public pelet::ClassObserverClass {
+ virtual void ClassFound(const UnicodeString& className,
+ const UnicodeString& signature, const UnicodeString& comment) {
+ // your code to handle new classes goes here
+ }
+ };
+ // ...
+ // and in your main use it
+ SampleObserver observer;
+ pelet::ParserClass parser;
+ parser.SetClassObserver(&observer);
+ pelet::LintResultsClass results;
+ const char *file = // ....;
+ bool parsed = parser.ScanFile(file, results);
+ if (parsed) {
+ // no syntax errors
+ }
+ else {
+ // file contained syntax errors
+ }
+See sample.cpp file for a full-fledged, running example.
+- Build environment: Allow options to use a pre-exisiting installation of the
+ICU library.
+- PHP 5.4 support (array dereferencing, traits)
+- Namespaces: While are captured by the parser, they are not visible to the caller.
2 premake4.lua
@@ -100,7 +100,7 @@ solution "pelet"
project "pelet"
language "C++"
kind "SharedLib"
- files { "src/*", "include/**", "*.lua", "src/**.re", "src/**.y" }
+ files { "src/*", "include/**", "*.lua", "src/**.re", "src/**.y", "" }
includedirs { "include/" }
links { "tests" }

0 comments on commit 2f2bc2c

Please sign in to comment.