1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 04:14:44 +01:00
PHP-Parser/grammar
2011-06-26 20:56:35 +02:00
..
analyzer.php a) changes node structure (Stmt_, Expr_, ...) b) fixes parsing of x::$y[z] 2011-05-27 18:42:36 +02:00
php.kmyacc Move halt_compiler handling from parser to grammar 2011-06-12 17:19:12 +02:00
preprocessor.php Associate some line information with nodes (currently the line the node ends in, as the starting line is harder to fetch) 2011-06-12 17:12:47 +02:00
README.md Add README for grammar folder 2011-06-26 20:56:35 +02:00
rebuildParser.php Associate some line information with nodes (currently the line the node ends in, as the starting line is harder to fetch) 2011-06-12 17:12:47 +02:00
y.output Put statements belonging to a namespace statement into its stmt property, add some further checks against invalid namespace usage and fix the pretty printer to print global namespaces 2011-06-26 18:41:01 +02:00
zend_language_parser.phpy Put statements belonging to a namespace statement into its stmt property, add some further checks against invalid namespace usage and fix the pretty printer to print global namespaces 2011-06-26 18:41:01 +02:00
zend_language_parser.pre.phpy Put statements belonging to a namespace statement into its stmt property, add some further checks against invalid namespace usage and fix the pretty printer to print global namespaces 2011-06-26 18:41:01 +02:00
zend_language_parser.y Initial commit 2011-04-18 19:02:30 +02:00

What do all those files mean?

  • zend_language_parser.y: Original PHP grammer this parser is based on
  • zend_language_parser.pre.phpy: PHP grammer written in a pseudo language, which is transformed into a proper kmyacc grammer using preprocessor.php
  • zend_language_parser.phpy: PHP grammer ready for kmyacc
  • analyzer.php: Analyzes the .pre.phpy-grammer and outputs some info about it
  • preprocessor.php: Transforms a .pre.phpy grammar into a .phpy grammar
  • rebuildParser.php: Builds the actual parser by calling kmyacc
  • php.kmyacc: A kmyacc parser prototype file for PHP
  • y.output: kmyaccs debug output

.pre.phpy pseudo language

The .pre.phpy file is a normal grammer in kmyacc (yacc) style, with some transformations applied to it:

  • Nodes are created using the syntax Name[subNode1: ..., subNode2: ...]. This is transformed into new PHPParser_Node_Name(array('subNode1' => ..., 'subNode2' => ...), #this->line) (# is used instead of $ because $ is a reservered character in kmyacc grammars. It is later transformed back to $)
  • Name::abc is transformed to PHPParser_Node_Name::abc
  • Some function-like constructs are resolved (see preprocessor.php for a list)