Overview

Namespaces

  • BN
    • Collections
    • Compiler
      • Grammar
      • Parser
        • Operator
        • Token
      • Postfix
        • Operands
        • Operator
        • Token
      • Scanner
        • Converter
      • Token
  • Demo
  • None

Classes

  • ParseClosingBracket
  • ParseOpeningBracket
  • ParseOperator
  • ParseUnknownToken
  • ParseValue
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace BN\Compiler\Parser\Token;
 4: 
 5: use BN\Compiler\Parser\TokenParser;
 6: use BN\Compiler\Token\Token;
 7: use BN\Compiler\Token\TokenType;
 8: 
 9: class ParseClosingBracket extends TokenParser
10: {
11:     public function parse(Token $token)
12:     {
13:         while ($this->isNotLeftBracketAtTopOfStack()) {
14:             if ($this->accumulator->isStackEmpty()) {
15:                 $this->accumulator->stopParsing('mismatchedBrackets', $token->value);
16:                 return;
17:             }
18:             $this->accumulator->pushTokenFromStackToQueue();
19:         }
20:         $this->accumulator->popTokenFromStack();
21:     }
22: 
23:     private function isNotLeftBracketAtTopOfStack()
24:     {
25:         return $this->accumulator->isStackEmpty()
26:             || !$this->accumulator->isTypeAtStackPeek(TokenType::BRACKET_OPENING);
27:     }
28: }
29: 
BN-PHP - Big Number data type for PHP API documentation generated by ApiGen 2.8.0