diff --git a/experiment/php/preflight.php b/experiment/php/preflight.php new file mode 100644 index 0000000..da9cc04 --- /dev/null +++ b/experiment/php/preflight.php @@ -0,0 +1,28 @@ + 15) return array('ok'=>false,'reason'=>'depth','offset'=>$i,'containers'=>$containers,'tokens'=>$tokens); + } + elseif ($c === '}' || $c === ']') { --$depth; $in_atom = false; } + elseif ($c === ',' || $c === ':' || $c === ' ' || $c === "\n" || $c === "\r" || $c === "\t") { $in_atom = false; } + elseif (!$in_atom) { ++$tokens; $in_atom = true; } + if ($containers > $container_limit || $tokens > $token_limit) { + return array('ok'=>false,'reason'=>$containers > $container_limit ? 'containers' : 'tokens','offset'=>$i,'containers'=>$containers,'tokens'=>$tokens); + } + } + return array('ok'=>true,'reason'=>'within_budget','offset'=>$n,'containers'=>$containers,'tokens'=>$tokens); +}