php-parser/grammar
2011-07-03 16:35:45 +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 Associate last encountered doccomment with next node 2011-07-03 16:35:45 +02:00
preprocessor.php Associate last encountered doccomment with next node 2011-07-03 16:35:45 +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 Associate last encountered doccomment with next node 2011-07-03 16:35:45 +02:00
zend_language_parser.phpy Associate last encountered doccomment with next node 2011-07-03 16:35:45 +02:00
zend_language_parser.pre.phpy Add missing #line hint for strings 2011-06-28 14:16:10 +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)