PHPackages                             dfar143/cheope\_ppg\_ns - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dfar143/cheope\_ppg\_ns

ActiveLibrary

dfar143/cheope\_ppg\_ns
=======================

It generates generic parser written in php

02PHP

Since Feb 27Pushed 2mo agoCompare

[ Source](https://github.com/dfar143/Cheope_ppg_ns)[ Packagist](https://packagist.org/packages/dfar143/cheope_ppg_ns)[ RSS](/packages/dfar143-cheope-ppg-ns/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Cheope\_ppg\_ns
===============

[](#cheope_ppg_ns)

Php generic parser generator with namespaces
============================================

[](#php-generic-parser-generator-with-namespaces)

BACKTRACKING PARSER GENERATOR FOR PHP.

The parser generator is in the 'grammar\_rule\_gen' directory. The main module is 'parser\_gen\_exec.php'.

Usage: php parser\_gen\_exec.php |prjName| -l |logFileName|

where |prjName| is the project name and must match the |prjName|.xml grammars definition file.

Example: php parser\_gen\_exec.php example\_1 -l log.txt or (the -l flag is optional) php parser\_gen\_exec.php example\_1

The module can be called from a browser too: the default log file name is 'log.txt'. In this case, to specify the project name, you must edit the 'grammar\_rules\_gen\_def.php' file and set the PRJ\_NAME constant to the right project name.

The grammar definition file allows to write any number of grammars in the 'grammar\_rules' section. Each grammar must have a 'grammar\_rule' main section with a 'name' not null attribute. The main section contains 3 sub-sections: 'tokens\_def' that contains tokens regular expressions definitions ('token' tags); 'tokens\_attributes' that contains tokens attributes definitions ('Attr' tags); 'productions' that contains all the productions for the grammar ('production' tags).

A generic production has a very simple sintax; it is composed by not terminals (in uppercase), terminals (in lowercase), the equal (=) symbol that divides the left and the right side of the production and the logical OR symbol (|). The terminal 'epsilon' is the always true terminal. The terminal 'ws' is used to specify the white space and his exact definition must be included (with his regular expression) in the tokens definition section. The code for not terminal SPACE is automatically generated and the associated production (implicitly present) is SPACE = ws | epsilon. Not terminal SPACE can be freely used in the others productions. The right side is typically composed by successions of terminals and not terminals divided by logical ORs symbols; each succession is a logical AND succession.

Each token is defined by a 'token' xml tag that have two mandatory attributes: 'type' and 'val'. The precedence of the tokens definitions is important. See 'example\_1.xml' for an example of a grammar definition file.

Attributes are optionally, but the section 'tokens\_attributes' must be present. See directory 'Ric\_sql' and files 'ric\_sql\_def.php' and 'Ric\_sql\_parser\_grammar\_rules.php' for an example of using them.

The php module generates two others modules that are : |prjName|\_def.php and |prjName|\_parser\_grammar\_rules.php. The first contains constants, lex rules objects instances definitions and grammar rules objects instances definitions. The second contains the parser recursive engine. The results of the execution are added at each call, so to create a new parser you have to flush the old files. These files must then be copied in the destination directory. As an example of destination directory you can use the 'parser\_example' directory. This one contains the others parser files. The parser generic engine is in the 'Parser.php' file and contains the main php Parser class. This class has ,as entry point, the public method 'exec' that tries all the grammars and returns true if the text to be parsed satisfied at least one. It fills the '$results' array with the execution status for each grammar. See 'Parser.php' file comments.

In the 'Parser\_example' directory there is the 'parser\_exec.php' module that calls the parser engine.

Usage: php parser\_exec.php |textToBeParsedFileName|

where |textToBeParsedFileName| is the file that contains the text to be parsed.

Example: php parser\_exec.php example.txt

The 'parser\_exec.php' module acts like a validator and returns 'Ok.' if succedes or the current error if not. Furthermore, if it is called by a browser, it displays the symbol table.

The applications 'php\_arrays' and 'ric\_sql' are under development.

This application has been developed with PHP version 5.5.7, but I suppose , it can run with many others previous, since no particulary advanced techniques has been used,except class construct.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance61

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/198409991d2c28a734e660373e1661a26adbeaed285bfcabeec149c4781d5156?d=identicon)[danielfar](/maintainers/danielfar)

---

Top Contributors

[![dfar143](https://avatars.githubusercontent.com/u/7255424?v=4)](https://github.com/dfar143 "dfar143 (51 commits)")

---

Tags

parser-engineparser-generatorphp-parser

### Embed Badge

![Health badge](/badges/dfar143-cheope-ppg-ns/health.svg)

```
[![Health](https://phpackages.com/badges/dfar143-cheope-ppg-ns/health.svg)](https://phpackages.com/packages/dfar143-cheope-ppg-ns)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
