Lines Matching refs:this

36         $this->_definition = $definition;
37 $this->_args = $args;
40 public function definition() { return $this->_definition; }
41 public function args() { return $this->_args; }
45 foreach ($this->args() as $arg) {
61 if ($this->definition() === null) {
62 $this->ensureWellFormed(false);
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();
73 return $this->definition()->getRepresentation($this);
86 if ($this->definition() !== null && $this->definition()->fixing() == Fixing::None) {
89 foreach ($this->args() as $arg) {
106 if ($this->isExpanded($recursive)) {
109 $elmDef->spliceInstancesIn($this->_args);
111 foreach ($this->args() as $arg) {
128 if ($this->isExpanded($recursive)) {
131 foreach ($this->args() as $arg) {
153 if ($this->definition() !== null) {
154 echo $indentStr . '+-' . $this->definition()->name() . "\n";
158 foreach ($this->args() as $arg) {
163 $arg->printTree($indentStr . $extraIndentStr, $argIdx == count($this->args()));
173 foreach ($this->args() as $arg) {
189 if ($this->definition() === null) {
190 if (count($this->args()) > 1) {
191 …throw new MalformedExpressionException($this, 'An expression that has more than a single root is n…
194 $this->definition()->ensureWellFormed($this);
197 foreach ($this->args() as $arg) {
214 if ($this->definition() === null) {
215 $this->ensureWellFormed(false);
217 if (count($this->args()) == 0) {
220 return $this->evaluateArgs()[0];
222 return $this->definition()->evaluate($this);
238 public function arity() { return $this->_arity; }
239 public function nested() { return $this->_nested; }
240 public function fixing() { return $this->_fixing; }
241 public function priority() { return $this->_priority; }
242 public function tokenDefs() { return $this->_tokenDefs; }
243 public function name() { return $this->_name; }
271 $this->_name = $name;
272 $this->_tokenDefs = $tokenDefs;
273 $this->_arity = $arity;
274 $this->_nested = $nested;
275 $this->_fixing = $fixing;
276 $this->_priority = $priority;
278 switch ($this->fixing()) {
280 if ($this->arity() != 0) {
283 if (count($this->tokenDefs()) != 1) {
288 if ($this->arity() == 0) {
291 if (count($this->tokenDefs()) != 1 && count($this->tokenDefs()) != $this->arity()) {
296 if ($this->arity() == 0) {
299 if (count($this->tokenDefs()) != 1 && count($this->tokenDefs()) != $this->arity()) {
304 if ($this->arity() == 0 || $this->arity() == 1) {
307 … if (count($this->tokenDefs()) != 1 && count($this->tokenDefs()) != $this->arity() - 1) {
312 if ($this->arity() !== null) {
315 if (count($this->tokenDefs()) != 2) {
324 if ($this->fixing() == Fixing::Wrap) {
325 if ($this->nested() === null) {
329 if ($this->nested() !== null) {
462 switch ($this->fixing()) {
464 if ($args[$position]->definition() == $this->tokenDefs()[0]) {
465 $position = self::_spliceNone($args, $position, $this);
470 if ($this->arity() < 0) {
471 … $chainLength = self::_getLongestAlternateChain($args, $position, $this->tokenDefs()[0]);
473 $position = self::_splicePrefix($args, $position, $chainLength, $this);
476 } else if (count($this->tokenDefs()) == 1) {
477 …ainLength = self::_getLongestAlternateChain($args, $position, $this->tokenDefs()[0], $this->arity(…
478 if ($chainLength == $this->arity()) {
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);
488 if ($this->arity() < 0) {
489 … $chainLength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0]);
491 $position = self::_splicePostfix($args, $position + 1, $chainLength, $this);
494 } else if (count($this->tokenDefs()) == 1) {
495 …ength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0], $this->arity(…
496 if ($chainLength == $this->arity()) {
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);
506 if ($this->arity() < 0) {
507 … $chainLength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0]);
509 $position = self::_spliceInfix($args, $position + 1, $chainLength, $this);
512 } else if (count($this->tokenDefs()) == 1) {
513 …ength = self::_getLongestAlternateChain($args, $position + 1, $this->tokenDefs()[0], $this->arity(…
514 if ($chainLength == $this->arity() - 1) {
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]);
538 if ($this->trySpliceAt($args, $i)) {
550 $this->ensureWellFormed($elmInstance);
551 return $this->_evaluateWellFormed($elmInstance);
555 if ($idx < count($this->tokenDefs())) {
556 return $this->tokenDefs()[$idx]->representation();
557 } elseif (count($this->tokenDefs()) == 1) {
558 return $this->tokenDefs()[0]->representation();
564 $this->ensureWellFormed($elmInstance);
574 if ($this->fixing() == Fixing::Prefix || $this->fixing() == Fixing::Wrap) {
575 $pieces[] = $this->getTokenDefRepr(0);
577 $argIdx = ($this->fixing() == Fixing::Postfix || $this->fixing() == Fixing::Infix ? -1 : 0);
581 if ($this->fixing() == Fixing::None && $this->fixing() == Fixing::Wrap) {
584 …if ($argIdx >= count($argsRepr) || ($this->fixing() == Fixing::Infix && $argIdx >= count($argsRepr…
587 $pieces[] = $this->getTokenDefRepr($argIdx);
589 if ($this->fixing() == Fixing::Wrap) {
590 $pieces[] = $this->getTokenDefRepr(1);
604 if ($elmInstance->definition() != $this) {
609 switch ($this->fixing()) {
615 } else if ($args[0]->definition() != $this->tokenDefs()[0]) {
616 …MalformedExpressionException($elmInstance, 'Expected a token of type ' . $this->tokenDefs()[0]->na…
622 if ($this->arity() < 0) { // Any number of tokens, > 0
623 if (count($args) < 1 && $this->fixing() == Fixing::Infix) {
628 } elseif (count($args) != $this->arity()) {
629 …row new MalformedExpressionException($elmInstance, 'Expected exactly ' . $this->arity() . ' argume…