Lines Matching refs:args
35 public function __construct($definition, $args) { argument
37 $this->_args = $args;
41 public function args() { return $this->_args; } function in AST\\ElementInstance
45 foreach ($this->args() as $arg) {
64 if (count($this->args()) == 0) {
67 if ($this->args()[0] instanceof ElementInstance) {
68 return $this->args()[0]->getRepresentation();
70 return $this->args()[0]->match();
89 foreach ($this->args() as $arg) {
111 foreach ($this->args() as $arg) {
131 foreach ($this->args() as $arg) {
158 foreach ($this->args() as $arg) {
163 $arg->printTree($indentStr . $extraIndentStr, $argIdx == count($this->args()));
173 foreach ($this->args() as $arg) {
190 if (count($this->args()) > 1) {
197 foreach ($this->args() as $arg) {
217 if (count($this->args()) == 0) {
335 private static function _getLongestAlternateChain($args, $position, $tokDef, $stopAt=-1) { argument
337 for ($lastFound = $position; $lastFound < count($args); $lastFound += 2) {
338 if ($args[$lastFound]->definition() == $tokDef) {
350 private static function _isMatchingAlternateChain($args, $position, $tokDefs) { argument
352 …for ($lastFound = $position; $lastFound < count($args) && $tokDefIdx < count($tokDefs); $lastFound…
353 if ($args[$lastFound]->definition() == $tokDefs[$tokDefIdx]) {
362 private static function _getWrappedSequence($args, $position, $tokDefs, $nested) { argument
367 if ($args[$position]->definition() != $openTokDef) {
371 for ($i = $position + 1; $i < count($args); ++$i) {
372 if ($args[$i]->definition() == $closeTokDef) {
376 } else if ($nested && $args[$i]->definition() == $openTokDef) {
383 private static function _extractAlternateChain($args, $position, $length) { argument
385 for ($i = $position; $i < count($args) && count($retval) < $length; $i += 2) {
386 $retval[] = $args[$i];
391 private static function _splicePrefix(&$args, $firstTokPosition, $chainLength, $definition) { argument
395 $elmArgs = self::_extractAlternateChain($args, $firstTokPosition + 1, $chainLength);
397 if ($firstTokPosition + $chainLength * 2 > count($args)) {
400 array_splice($args, $firstTokPosition, $chainLength * 2, array($elmInst));
404 private static function _splicePostfix(&$args, $firstTokPosition, $chainLength, $definition) { argument
408 $elmArgs = self::_extractAlternateChain($args, $firstTokPosition - 1, $chainLength);
412 } elseif ($firstTokPosition + $chainLength * 2 - 1 > count($args)) {
415 array_splice($args, $firstTokPosition - 1, $chainLength * 2, array($elmInst));
419 private static function _spliceInfix(&$args, $firstTokPosition, $chainLength, $definition) { argument
423 $elmArgs = self::_extractAlternateChain($args, $firstTokPosition - 1, $chainLength + 1);
427 } elseif ($firstTokPosition + $chainLength * 2 > count($args)) {
430 array_splice($args, $firstTokPosition - 1, $chainLength * 2 + 1, array($elmInst));
434 private static function _spliceWrap(&$args, $firstTokPosition, $sequenceLength, $definition) { argument
441 if ($firstTokPosition + $sequenceLength > count($args)) {
444 $elmArgs = array_slice($args, $firstTokPosition + 1, $sequenceLength - 2);
446 array_splice($args, $firstTokPosition, $sequenceLength, array($elmInst));
450 private static function _spliceNone(&$args, $firstTokPosition, $definition) { argument
454 if ($firstTokPosition + 1 > count($args)) {
457 …array_splice($args, $firstTokPosition, 1, array(new ElementInstance($definition, array($args[$firs…
461 public function trySpliceAt(&$args, &$position) { argument
464 if ($args[$position]->definition() == $this->tokenDefs()[0]) {
465 $position = self::_spliceNone($args, $position, $this);
471 … $chainLength = self::_getLongestAlternateChain($args, $position, $this->tokenDefs()[0]);
473 $position = self::_splicePrefix($args, $position, $chainLength, $this);
477 …$chainLength = self::_getLongestAlternateChain($args, $position, $this->tokenDefs()[0], $this->ari…
479 $position = self::_splicePrefix($args, $position, $chainLength, $this);
482 } else if (self::_isMatchingAlternateChain($args, $position, $this->tokenDefs())) {
483 $position = self::_splicePrefix($args, $position, $this->arity(), $this);
489 … $chainLength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0]);
491 $position = self::_splicePostfix($args, $position + 1, $chainLength, $this);
495 …$chainLength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0], $this-…
497 $position = self::_splicePostfix($args, $position + 1, $chainLength, $this);
500 … } else if (self::_isMatchingAlternateChain($args, $position + 1, $this->tokenDefs())) {
501 $position = self::_splicePostfix($args, $position + 1, $this->arity(), $this);
507 … $chainLength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0]);
509 $position = self::_spliceInfix($args, $position + 1, $chainLength, $this);
513 …$chainLength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0], $this-…
515 $position = self::_spliceInfix($args, $position + 1, $chainLength, $this);
518 … } else if (self::_isMatchingAlternateChain($args, $position + 1, $this->tokenDefs())) {
519 $position = self::_spliceInfix($args, $position + 1, $this->arity() - 1, $this);
524 …$sequenceLength = self::_getWrappedSequence($args, $position, $this->tokenDefs(), $this->nested());
526 $position = self::_spliceWrap($args, $position, $sequenceLength, $this);
529 throw new UnmatchedWrapperException($this, $args[$position]);
535 public function spliceInstancesIn(&$args) { argument
537 for ($i = 0; $i < count($args); ++$i) {
538 if ($this->trySpliceAt($args, $i)) {
566 foreach ($elmInstance->args() as $arg) {
607 $args = $elmInstance->args();
611 if (count($args) != 1) {
613 } else if (!($args[0] instanceof TokenInstance)) {
615 } else if ($args[0]->definition() != $this->tokenDefs()[0]) {
623 if (count($args) < 1 && $this->fixing() == Fixing::Infix) {
625 } elseif (count($args) == 0) {
628 } elseif (count($args) != $this->arity()) {