Example #1
0
 /**
  * 
  * @param Context $context
  */
 public function handle(Context $context)
 {
     $string = new StringExpr();
     $string->handle($context);
     $this->key = $string->getResult();
     $nameSeparator = new StructuralChar(array(":"));
     $nameSeparator->handle($context);
     $value = new Value();
     $value->handle($context);
     $this->value = $value->getResult();
 }
Example #2
0
 /**
  * value の内容を解釈してその結果を $result に格納します.
  * 
  * <pre>
  * value = false / null / true / object / array / number / string
  * </pre>
  * 
  * @param  Context $context
  */
 public function handle(Context $context)
 {
     $current = $context->current();
     if ($current === "-" || Number::checkDigit($context)) {
         $number = new Number();
         $number->handle($context);
         $this->result = $number->getResult();
         return;
     }
     switch ($current) {
         case "f":
             $this->decodeLiteral($context, "false", false);
             break;
         case "n":
             $this->decodeLiteral($context, "null", null);
             break;
         case "t":
             $this->decodeLiteral($context, "true", true);
             break;
         case "[":
             $array = new ArrayExpr();
             $array->handle($context);
             $this->result = $array->getResult();
             break;
         case "{":
             $object = new ObjectExpr();
             $object->handle($context);
             $this->result = $object->getResult();
             break;
         case '"':
             $string = new StringExpr();
             $string->handle($context);
             $this->result = $string->getResult();
             break;
         default:
             $context->throwException("Invalid value format");
     }
 }