1<?php 2/** 3 * PHP_ParserGenerator, a php 5 parser generator. 4 * 5 * This is a direct port of the Lemon parser generator, found at 6 * {@link http://www.hwaci.com/sw/lemon/} 7 * 8 * PHP version 5 9 * 10 * LICENSE: 11 * 12 * Copyright (c) 2006, Gregory Beaver <cellog@php.net> 13 * All rights reserved. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 19 * * Redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer. 21 * * Redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in 23 * the documentation and/or other materials provided with the distribution. 24 * * Neither the name of the PHP_ParserGenerator nor the names of its 25 * contributors may be used to endorse or promote products derived 26 * from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 29 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 32 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 36 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * @category PHP 41 * @package PHP_ParserGenerator 42 * @author Gregory Beaver <cellog@php.net> 43 * @copyright 2006 Gregory Beaver 44 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 45 * @version CVS: $Id: Rule.php 302382 2010-08-17 06:08:09Z jespino $ 46 * @link http://pear.php.net/package/PHP_ParserGenerator 47 * @since File available since Release 0.1.0 48 */ 49/** 50 * Each production rule in the grammar is stored in this class 51 * 52 * @category PHP 53 * @package PHP_ParserGenerator 54 * @author Gregory Beaver <cellog@php.net> 55 * @copyright 2006 Gregory Beaver 56 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 57 * @version Release: @package_version@ 58 * @link http://pear.php.net/package/PHP_ParserGenerator 59 * @since Class available since Release 0.1.0 60 */ 61class PHP_ParserGenerator_Rule 62{ 63 /** 64 * Left-hand side of the rule 65 * @var array an array of {@link PHP_ParserGenerator_Symbol} objects 66 */ 67 public $lhs; 68 /** 69 * Alias for the LHS (NULL if none) 70 * 71 * @var array 72 */ 73 public $lhsalias = array(); 74 /** 75 * Line number for the rule 76 * @var int 77 */ 78 public $ruleline; 79 /** 80 * Number of right-hand side symbols 81 */ 82 public $nrhs; 83 /** 84 * The right-hand side symbols 85 * @var array an array of {@link PHP_ParserGenerator_Symbol} objects 86 */ 87 public $rhs; 88 /** 89 * Aliases for each right-hand side symbol, or null if no alis. 90 * 91 * In this rule: 92 * <pre> 93 * foo ::= BAR(A) baz(B). 94 * </pre> 95 * 96 * The right-hand side aliases are A for BAR, and B for baz. 97 * @var array aliases are indexed by the right-hand side symbol index. 98 */ 99 public $rhsalias = array(); 100 /** 101 * Line number at which code begins 102 * @var int 103 */ 104 public $line; 105 /** 106 * The code executed when this rule is reduced 107 * 108 * <pre> 109 * foo(R) ::= BAR(A) baz(B). {R = A + B;} 110 * </pre> 111 * 112 * In the rule above, the code is "R = A + B;" 113 * @var string|0 114 */ 115 public $code; 116 /** 117 * Precedence symbol for this rule 118 * @var PHP_ParserGenerator_Symbol 119 */ 120 public $precsym; 121 /** 122 * An index number for this rule 123 * 124 * Used in both naming of reduce functions and determining which rule code 125 * to use for reduce actions 126 * @var int 127 */ 128 public $index; 129 /** 130 * True if this rule is ever reduced 131 * @var boolean 132 */ 133 public $canReduce; 134 /** 135 * Next rule with the same left-hand side 136 * @var PHP_ParserGenerator_Rule|0 137 */ 138 public $nextlhs; 139 /** 140 * Next rule in the global list 141 * @var PHP_ParserGenerator_Rule|0 142 */ 143 public $next; 144} 145