PropagationLink.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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: PropagationLink.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. * A followset propagation link indicates that the contents of one
  51. * configuration followset should be propagated to another whenever
  52. * the first changes.
  53. *
  54. * @category PHP
  55. * @package PHP_ParserGenerator
  56. * @author Gregory Beaver <cellog@php.net>
  57. * @copyright 2006 Gregory Beaver
  58. * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  59. * @version Release: @package_version@
  60. * @link http://pear.php.net/package/PHP_ParserGenerator
  61. * @since Class available since Release 0.1.0
  62. */
  63. class PHP_ParserGenerator_PropagationLink
  64. {
  65. /**
  66. * The configuration that defines this propagation link
  67. *
  68. * @var PHP_ParserGenerator_Config
  69. */
  70. public $cfp;
  71. /**
  72. * The next propagation link
  73. *
  74. * @var PHP_ParserGenerator_PropagationLink|0
  75. */
  76. public $next = 0;
  77. /**
  78. * Add a propagation link to the current list
  79. *
  80. * This prepends the configuration passed in to the first parameter
  81. * which is either 0 or a PHP_ParserGenerator_PropagationLink defining
  82. * an existing list.
  83. *
  84. * @param PHP_ParserGenerator_PropagationLink|null
  85. * @param PHP_ParserGenerator_Config
  86. */
  87. static function Plink_add(&$plpp, PHP_ParserGenerator_Config $cfp)
  88. {
  89. $new = new PHP_ParserGenerator_PropagationLink;
  90. $new->next = $plpp;
  91. $plpp = $new;
  92. $new->cfp = $cfp;
  93. }
  94. /**
  95. * Transfer every propagation link on the list "from" to the list "to"
  96. */
  97. static function Plink_copy(PHP_ParserGenerator_PropagationLink &$to, PHP_ParserGenerator_PropagationLink $from)
  98. {
  99. while ($from) {
  100. $nextpl = $from->next;
  101. $from->next = $to;
  102. $to = $from;
  103. $from = $nextpl;
  104. }
  105. }
  106. /**
  107. * Delete every propagation link on the list
  108. *
  109. * @param PHP_ParserGenerator_PropagationLink|0
  110. *
  111. * @return void
  112. */
  113. static function Plink_delete($plp)
  114. {
  115. while ($plp) {
  116. $nextpl = $plp->next;
  117. $plp->next = 0;
  118. $plp = $nextpl;
  119. }
  120. }
  121. }