iceframework / zephir-parser
The Zephir Parser delivered as a C extension for the PHP language.
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: >=4.7.5 <6.0.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The Zephir Parser delivered as a C extension for the PHP language.
Supported PHP versions: 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5
Get Started
Build Requirements
Prerequisite packages are:
- OS: Linux || Solaris || FreeBSD || macOS || Windows
- Compiler:
g++>= 4.4 ||clang++>= 3.x ||vc++>= 11 re2c>= 0.13.6
To build extension from the source you will need the PHP development headers. If PHP was manually installed, these should be available by default. Otherwise, you will need to fetch them from a repository.
PECL
pecl install zephir_parser
Windows
To install Zephir Parser on Windows:
- Download Zephir Parser for Windows
- Extract the DLL file and copy it to your PHP extensions directory
- Edit your
php.inifile and add this line:[Zephir Parser] extension=php_zephir_parser.dll
Linux
On a Linux/Unix-based platform you can easily compile and install the extension from sources.
For Linux/Unix-based based systems you'll need also:
Ubuntu
sudo apt-get install php7.0-dev gcc make re2c autoconf automake
Suse
sudo zypper install php7.0-devel gcc make re2c autoconf automake
CentOS/Fedora/RHEL
sudo yum install php-devel gcc make re2c autoconf automake
General Compilation
Follow these instructions to generate a binary extension for your platform:
git clone git://github.com/zephir-lang/php-zephir-parser.git
cd php-zephir-parser
phpize
./configure
make
sudo make install
If you have multiple/specific PHP versions installed, you may be able to specify for which installation you'd like to
build by using the --with-php-config option during configuration. For example:
git clone git://github.com/zephir-lang/php-zephir-parser.git
cd php-zephir-parser
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
make
sudo make install
Add the extension to your php.ini:
[Zephir Parser] extension=zephir_parser.so
Usage
$program = <<<EOF namespace Acme; class Greeting { public static function sayHello() -> void { echo "Hello, World!"; } } EOF; $retval = zephir_parse_file($program, '(eval code)'); var_dump($retval);
Grammar
The Zephir grammar is available in EBNF notation at docs/grammar.ebnf.
It covers all production rules from parser/zephir.lemon and token definitions
from parser/scanner.re, including yield, require_once, mixed type,
nested property-access assignments, and all-caps (CONSTANT) name variants
introduced for issue #39 support.
To visualize the grammar as a railroad diagram, copy the contents of
docs/grammar.ebnf and paste them into the bottlecaps.de Railroad Diagram Generator
(Edit Grammar tab → View Diagram tab).
Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]
Backers
Support us with a monthly donation and help us continue our activities. [Become a backer]