mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2025-01-21 21:01:15 +01:00
Move parser to Parser\Php5
Old name still exists.
This commit is contained in:
parent
5d1e3be7d4
commit
51ec2a25fe
@ -1,22 +1,20 @@
|
|||||||
What do all those files mean?
|
What do all those files mean?
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
* `zend_language_parser.phpy`: PHP grammer written in a pseudo language
|
* `php5.y`: PHP 5 grammer written in a pseudo language
|
||||||
* `analyze.php`: Analyzes the `.phpy`-grammer and outputs some info about it
|
* `analyze.php`: Analyzes the grammer and outputs some info about it
|
||||||
* `rebuildParser.php`: Preprocesses the `.phpy`-grammar and builds the parser using `kmyacc`
|
* `rebuildParser.php`: Preprocesses the grammar and builds the parser using `kmyacc`
|
||||||
* `kmyacc.php.parser`: A `kmyacc` parser prototype file for PHP
|
* `kmyacc.php.parser`: A `kmyacc` parser prototype file for PHP
|
||||||
|
|
||||||
.phpy pseudo language
|
.phpy pseudo language
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
The `.phpy` file is a normal grammer in `kmyacc` (`yacc`) style, with some transformations
|
The `.y` file is a normal grammer in `kmyacc` (`yacc`) style, with some transformations
|
||||||
applied to it:
|
applied to it:
|
||||||
|
|
||||||
* Nodes are created using the syntax `Name[..., ...]`. This is transformed into
|
* Nodes are created using the syntax `Name[..., ...]`. This is transformed into
|
||||||
`new Name(..., ..., attributes())`
|
`new Name(..., ..., attributes())`
|
||||||
* Some function-like constructs are resolved (see `rebuildParser.php` for a list)
|
* Some function-like constructs are resolved (see `rebuildParser.php` for a list)
|
||||||
* Associative arrays are written as `[key: value, ...]`, which is transformed to
|
|
||||||
`array('key' => value, ...)`
|
|
||||||
|
|
||||||
Building the parser
|
Building the parser
|
||||||
===================
|
===================
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
const GRAMMAR_FILE = './zend_language_parser.phpy';
|
const GRAMMAR_FILE = './php5.y';
|
||||||
|
|
||||||
const LIB = '(?(DEFINE)
|
const LIB = '(?(DEFINE)
|
||||||
(?<singleQuotedString>\'[^\\\\\']*+(?:\\\\.[^\\\\\']*+)*+\')
|
(?<singleQuotedString>\'[^\\\\\']*+(?:\\\\.[^\\\\\']*+)*+\')
|
||||||
@ -93,4 +93,4 @@ foreach ($ruleBlocksMatches as $match) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $ruleBlockName, ':', "\n", ' ', implode("\n" . ' | ', $rules), "\n", ';', "\n\n";
|
echo $ruleBlockName, ':', "\n", ' ', implode("\n" . ' | ', $rules), "\n", ';', "\n\n";
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ $meta #
|
|||||||
#semval(%n) $this->stackPos-(%l-%n)
|
#semval(%n) $this->stackPos-(%l-%n)
|
||||||
#semval(%n,%t) $this->stackPos-(%l-%n)
|
#semval(%n,%t) $this->stackPos-(%l-%n)
|
||||||
|
|
||||||
namespace PhpParser;
|
namespace PhpParser\Parser;
|
||||||
#include;
|
#include;
|
||||||
|
|
||||||
/* This is an automatically GENERATED file, which should not be manually edited.
|
/* This is an automatically GENERATED file, which should not be manually edited.
|
||||||
@ -14,7 +14,7 @@ namespace PhpParser;
|
|||||||
* * the skeleton file grammar/kymacc.php.parser
|
* * the skeleton file grammar/kymacc.php.parser
|
||||||
* * the preprocessing script grammar/rebuildParser.php
|
* * the preprocessing script grammar/rebuildParser.php
|
||||||
*/
|
*/
|
||||||
class Parser extends ParserAbstract
|
class Php5 extends \PhpParser\ParserAbstract
|
||||||
{
|
{
|
||||||
protected $tokenToSymbolMapSize = #(YYMAXLEX);
|
protected $tokenToSymbolMapSize = #(YYMAXLEX);
|
||||||
protected $actionTableSize = #(YYLAST);
|
protected $actionTableSize = #(YYLAST);
|
||||||
|
@ -112,6 +112,8 @@
|
|||||||
%token T_ELLIPSIS
|
%token T_ELLIPSIS
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
use PhpParser\Error;
|
||||||
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Expr;
|
use PhpParser\Node\Expr;
|
||||||
use PhpParser\Node\Name;
|
use PhpParser\Node\Name;
|
||||||
use PhpParser\Node\Scalar;
|
use PhpParser\Node\Scalar;
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$grammarFile = __DIR__ . '/zend_language_parser.phpy';
|
$grammarFile = __DIR__ . '/php5.y';
|
||||||
$skeletonFile = __DIR__ . '/kmyacc.php.parser';
|
$skeletonFile = __DIR__ . '/kmyacc.php.parser';
|
||||||
$tmpGrammarFile = __DIR__ . '/tmp_parser.phpy';
|
$tmpGrammarFile = __DIR__ . '/tmp_parser.phpy';
|
||||||
$tmpResultFile = __DIR__ . '/tmp_parser.php';
|
$tmpResultFile = __DIR__ . '/tmp_parser.php';
|
||||||
$parserResultFile = __DIR__ . '/../lib/PhpParser/Parser.php';
|
$parserResultFile = __DIR__ . '/../lib/PhpParser/Parser/Php5.php';
|
||||||
|
|
||||||
// check for kmyacc.exe binary in this directory, otherwise fall back to global name
|
// check for kmyacc.exe binary in this directory, otherwise fall back to global name
|
||||||
$kmyacc = __DIR__ . '/kmyacc.exe';
|
$kmyacc = __DIR__ . '/kmyacc.exe';
|
||||||
|
File diff suppressed because it is too large
Load Diff
2860
lib/PhpParser/Parser/Php5.php
Normal file
2860
lib/PhpParser/Parser/Php5.php
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user