parse

@access public
@return void
@throws MissingParamsException
496007
public function parse()
    {
        foreach ($this->_keys as $key) {
            if(empty($this->_rawRequest[$key['name']]) === true && $key['type'] === 'mandatory')
                throw new MissingParamsException();
        }

    }
273405
function parse() {
        $name_without_parens = preg_replace('/[{}]/', '', $this->full_name);

        $parts = explode('::', $name_without_parens);
        $name_without_case_keys = trim($parts[0]);
        array_shift($parts);
        $this->case_keys = array_map('trim', $parts);

        $parts = explode(':', $name_without_case_keys);
        $this->short_name = trim($parts[0]);
        array_shift($parts);
        $this->context_keys = array_map('trim', $parts);
    }
485209
protected function parseRequest()
    {
        if ($this->customParams === false) {
            // pull various supported inputs from post
            $request = $this->di->get('request');

            // only process if it is a get
            if ($request->isGet() == false) {
                return;
            }
        } else {
            $_REQUEST = $_GET = $this->customParams;
            $request = $this->di->get('request');
        }

        // simple stuff first
        $with = $request->get('with', "string", null);
        $include = $request->get('include', "string", null);
        if (!is_null($with)) {
            $this->suppliedWith = $with;
        } elseif (!is_null($include)) {
            $this->suppliedWith = $include;
        }

        // load possible sort values in the following order
        // be sure to mark this as a paginated result set
        if ($request->get('sort', "string", null) != null) {
            $this->suppliedSort = $request->get('sort', "string", null);
            $this->isPager = true;
        } elseif ($request->get('sort_field', "string", null) != null) {
            $this->suppliedSort = $request->get('sort_field', "string", null);
            $this->isPager = true;
        } elseif ($request->get('sortField', "string", null) != null) {
            $this->suppliedSort = $request->get('sortField', "string", null);
            $this->isPager = true;
        }

        // prep for the harder stuff
        // ?page=1&perPage=25&orderAscending=false

        // load possible limit values in the following order
        // be sure to mark this as a paginated result set
        if ($request->get('limit', "string", null) != null) {
            $this->suppliedLimit = $request->get('limit', "string", null);
            $this->isPager = true;
        } elseif ($request->get('per_page', "string", null) != null) {
            $this->suppliedLimit = $request->get('per_page', "string", null);
            $this->isPager = true;
        } elseif ($request->get('perPage', "string", null) != null) {
            $this->suppliedLimit = $request->get('perPage', "string", null);
            $this->isPager = true;
        }

        // look for string that means to show all records
        if ($this->isPager) {
            if ($this->suppliedLimit == 'all') {
                $this->suppliedLimit = 9999999999;
            }
        }

        // load offset values in the following order
        // Notice that a page is treated differently than offset
        // $this->offset = ($offset != null) ? $offset : $this->offset;
        if ($request->get('offset', "int", null) != null) {
            $this->suppliedOffset = $request->get('offset', "int", null);
            $this->isPager = true;
        } elseif ($request->get('page', "int", null) != null) {
            $this->suppliedOffset = ($request->get('page', "int", null) - 1) * $this->suppliedLimit;
            $this->isPager = true;
        }

        // Check if we pass the count parameter with whatever value
        if ($request->has('count')) {
            $this->isCount = true;
        }

        // http://jsonapi.org/format/#fetching
        $this->parseSearchParameters($request);
    }
159481
public static function Parse(){
            $oThis = self::CreateInstanceIfNotExists();
            $sRoot = str_replace(array("index.php", " "), array("", "%20"), $_SERVER["SCRIPT_NAME"]);//Bugfix
            $sUri = ($sRoot != "/") ? str_replace($sRoot, "", $_SERVER["REQUEST_URI"]) : substr($_SERVER["REQUEST_URI"], 1, strlen($_SERVER["REQUEST_URI"])-1);
            $aParsedRoute = explode("/", $sUri);
            $mID = (array_key_exists(1, $aParsedRoute)) ? $aParsedRoute[1] : null;
            $sMethod = $oThis->Restful();  
            $oThis->RestParams();

            if(!$oThis->bOverloadFrontend){
                $bResult = Bootstrap::AutoLoad(((!empty($aParsedRoute[0]) && $aParsedRoute[0] != "/" ) ? strtolower(str_replace("@", "", $aParsedRoute[0])) : "main"));

                if(!$bResult)
                    Bootstrap::AutoLoad("main");
            }
            
            $sUri = preg_replace("/\?.*$/", "", $sUri);//Removendo path
            $sUri = preg_replace("/\#.*$/", "", $sUri);//Removendo path
            $bCall = false;

            $aIdent = array("int" => "\d+", "str" => "\w+", "flt" => "[\d.]+");

            foreach($oThis->aRoutes as $sRoute => $fFunc){  
                if (preg_match_all('/{(?P<field>\w+)(:((?P<type>\w{3,3})|regex\((?P<regex>.*)\)))?(:(?P<notnull>notnull))?}/i',$sRoute, $aMatches)){
                    if (preg_match('/(?P<pre>.*\w)\/\{/i',$sRoute, $aMatch)){
                        $sOk = str_replace('/', '\/', $aMatch['pre']);
                        $sRoute = str_replace($aMatch['pre'], $sOk, $sRoute);
                    } 
                    foreach ($aMatches['field'] as $iKey => $sValue) {
                        if ($aMatches['regex'][$iKey]){
                            if ($aMatches['notnull'][$iKey] == 'notnull'){
                                $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':regex('.$aMatches['regex'][$iKey].'):notnull}/i',"\/(".$aMatches['regex'][$iKey].")", $sRoute);
                            }else{
                                $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':regex('.$aMatches['regex'][$iKey].')}/i',"\/?(".$aMatches['regex'][$iKey].")?", $sRoute);                                                                                
                            }
                        }else{
                            if ($aMatches['type'][$iKey]){ 
                                if ($aMatches['notnull'][$iKey] == 'notnull'){
                                    $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':'.$aMatches['type'][$iKey].':notnull}/i',"\/(".$aIdent[$aMatches['type'][$iKey]].")", $sRoute);                                        
                                }else{
                                    $sRoute = preg_replace('/\/?{'.$aMatches['field'][$iKey].':'.$aMatches['type'][$iKey].'}/i',"\/?(".$aIdent[$aMatches['type'][$iKey]].")?", $sRoute);                                        
                                }
                            }else{
                                if ($aMatches['notnull'][$iKey] == 'notnull'){
                                    $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':notnull}/i',"\/([^\/]*)", $sRoute);                                        
                                }else{
                                    $sRoute = preg_replace("/\/?{".$aMatches['field'][$iKey]."}/", "\/?([^\/]*)?", $sRoute);                                                                                            
                                }
                            }
                        } 
                    }
                }
                else{
                    $sRoute = str_replace('/', '\/', $sRoute);
                }                    
                
                if(preg_match_all("/^".$sRoute."\/?$/i", $sMethod."_".$sUri, $aMatches)){
                    $aParams = array();
                    foreach($aMatches as $iKey => $aResult){
                        if($iKey > 0){
                            $aParams[] = $aResult[0];
                        }
                    }

                    $bCall = true; 
                    Storage::Set("route.request", $sRoute);

                    if(is_array($fFunc)){
                        if(is_array($fFunc[1]))
                            $aParams = array_merge($fFunc[1], $aParams);
                        else
                            $aParams = array_merge(array($fFunc[1]), $aParams);

                        call_user_func_array($fFunc[0], $aParams);
                    }
                    else{
                        call_user_func_array($fFunc, $aParams);
                    }

                    break;
                }              
            }        
            
            if(array_key_exists("__dynamicroute", $oThis->aRoutes) && !$bCall)
                call_user_func($oThis->aRoutes["__dynamicroute"]);  
            else
                Output::SendHTTPCode(404);
        }
471299
protected function parse()
    {
        $parseOptions = true;
        $this->parsed = $this->tokenPairs;
        while (null !== $tokenPair = \array_shift($this->parsed)) {
            // token is what you'd expect. rest is the remainder of the input
            // string, including token, and will be used if this is a code arg.
            list($token, $rest) = $tokenPair;

            if ($parseOptions && '' === $token) {
                $this->parseShellArgument($token, $rest);
            } elseif ($parseOptions && '--' === $token) {
                $parseOptions = false;
            } elseif ($parseOptions && 0 === \strpos($token, '--')) {
                $this->parseLongOption($token);
            } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
                $this->parseShortOption($token);
            } else {
                $this->parseShellArgument($token, $rest);
            }
        }
    }
134501
public function parse($query=null)
    {
        $this->checkQuery($query);
        
        return $this->getDb()->setQuery($this->getQuery())->parse();
    }
135852
public function parse()
    {
        foreach ($this->parsedMail->getAttachments() as $attachment) {
            if (strpos($attachment->filename, '-report.txt') === false) {
                continue;
            }

            // Handle aliasses first
            foreach (config("{$this->configBase}.parser.aliases") as $alias => $real) {
                if ($attachment->filename == "{$alias}-report.txt") {
                    $this->feedName = $real;
                    break;
                }
            }

            if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                // Sanity check
                $report = str_replace("\r", "", $attachment->getContent());

                if (preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $report, $matches)) {
                    $report = array_combine($matches[1], $matches[2]);

                    if ($this->hasRequiredFields($report) === true) {
                        // incident has all requirements met, filter and add!
                        $report = $this->applyFilters($report);

                        $incident = new Incident();
                        $incident->source      = config("{$this->configBase}.parser.name");
                        $incident->source_id   = false;
                        $incident->ip          = $report['ip'];
                        $incident->domain      = empty($report['uri']) ? false : getDomain($report['uri']);
                        $incident->class       = config("{$this->configBase}.feeds.{$this->feedName}.class");
                        $incident->type        = config("{$this->configBase}.feeds.{$this->feedName}.type");
                        $incident->timestamp   = strtotime($report['last_seen']);
                        $incident->information = json_encode($report);

                        $this->incidents[] = $incident;
                    }
                } else { // Unable to build report
                    $this->warningCount++;
                }
            }
        }

        return $this->success();
    }
1311939
private function parse()
    {
        // Skip if already parsed!
        if ($this->parsed) {
            return;
        }

        // Type switch
        switch($this->query->mode){
            case Query::MODE_SELECT:
                $this->parseSelectQuery(); break;
            case Query::MODE_INSERT:
                $this->parseInsertQuery(); break;
            case Query::MODE_UPDATE:
                $this->parseUpdateQuery(); break;
            case Query::MODE_DELETE:
                $this->parseDeleteQuery(); break;
            case Query::MODE_TRUNCATE:
                $this->parseTruncateQuery(); break;
            case Query::MODE_ADVANCED:
                throw new QueryBuilderParseException("Query mode not yet implemented!"); break; // @codeCoverageIgnore
            case Query::MODE_NONE:
                throw new QueryBuilderParseException("Query has no mode yet!"); break; // @codeCoverageIgnore
            default:
                throw new QueryBuilderParseException("Query mode is invalid!"); break; // @codeCoverageIgnore
        }


        // Set parsed to true.
        $this->parsed = true;
    }
767482
public function parse(){
			$data = [];

			preg_match_all('#@(.*?)\n#s', $this->_comments, $annotations);

			foreach ($annotations[1] as $key => $annotation){
				if(preg_match('#([A-Za-z]+)\((.*)\)#is', $annotation)){
					preg_match_all('#([A-Za-z]+)\((.*)\)#is', $annotation, $annotationData);
					$annotationTitle = $annotationData[1][0];

					if(isset(Parser::$_annotations[$annotationTitle])) {
						$annotationContents = explode(", ", $annotationData[2][0]);
						$data[$key] = [];

						foreach ($annotationContents as $annotationContent) {
							preg_match_all('#(.+)="(.*)"#isU', trim($annotationContent), $annotationContentData);

							$data[$key]['type'] = $annotationTitle;
							$data[$key]['class'] = Parser::$_annotations[$annotationTitle];
							$data[$key]['properties'][$annotationContentData[1][0]] = $annotationContentData[2][0];
						}
					}
					else{
						throw new AnnotationNotExistingException('The annotation "' . $annotationTitle . '" does not exist');
					}
				}
			}

			return $data;
		}
818905
public function parse()
    {
        return $this->setDescription()
            ->setArray('IS_ARRAY')
            ->setOptional()
            ->setDefault()
            ->setRequired()
            ->calculateMode(InputArgument::class)
            ->setName();
    }
305740
public function parse()
    {
        $annotations = ['rest' => []];
        foreach ($this->classes as $c) {
            $classAnnotations = $this->annotationsFromClass($c->getName())->toArray();
            if (isset($classAnnotations['rest'])) {
                $annotations['rest'] = array_merge($classAnnotations['rest'], $annotations['rest']);
            }
        }
        $annotations = new ConfigObject($annotations);

        $this->classDefaults = $annotations->get('rest', new ConfigObject([]));

        // get method annotations
        $annotations = ['rest' => [], 'param' => []];
        foreach ($this->classes as $c) {
            try {
                $methodAnnotations = $this->annotationsFromMethod($c->getName(), $this->method->name)->toArray();
            } catch (\Exception $e) {
                continue;
            }
            if (isset($methodAnnotations['rest']) && is_array($methodAnnotations['rest'])) {
                $annotations['rest'] = array_merge($methodAnnotations['rest'], $annotations['rest']);
            }
            if (isset($methodAnnotations['param'])) {
                if (is_array($methodAnnotations['param'])) {
                    $annotations['param'] = array_merge($methodAnnotations['param'], $annotations['param']);
                } else {
                    $annotations['param'][] = $methodAnnotations['param'];
                }

            }
        }

        $annotations = new ConfigObject($annotations);

        $restAnnotations = $annotations->get('rest', new ConfigObject([]));
        $paramAnnotations = $annotations->get('param', new ConfigObject([]));

        // check if we should ignore this method
        if ($restAnnotations->get('ignore', false) !== false) {
            return false;
        }

        // create ApiMethod instance
        $parsedMethod = new ParsedMethod($this->method->name);

        // method
        $parsedMethod->method = $this->getMethod($restAnnotations);
        // role
        $parsedMethod->role = $this->getRole($restAnnotations);
        // cache.ttl
        $parsedMethod->cache = $this->getCache($restAnnotations);
        // header.cache.expires
        $parsedMethod->header = $this->getHeader($restAnnotations);
        // default
        $parsedMethod->default = $this->getDefault($restAnnotations);
        // rateControl.ignore
        $parsedMethod->rateControl = $this->getRateControl($restAnnotations);

        // parse method parameters
        $parameterParser = new ParameterParser($this->method->getParameters(), $paramAnnotations);
        $parameters = $parameterParser->parse();
        foreach ($parameters as $p) {
            $parsedMethod->addParameter($p);
        }

        // build the url pattern
        if ($restAnnotations->get('url', false)) {
            // build url pattern using the provided rest.url pattern
            $urlPattern = $this->buildUrlPatternFromPattern($restAnnotations->get('url'), $parameters);
            $resourceNaming = true;
        } else {
            // build url pattern using method name and parameters
            $urlPattern = $this->buildUrlPatternStandard($this->method->name, $parameters);
            $resourceNaming = false;
        }

        $parsedMethod->setUrlPattern($urlPattern, $resourceNaming);

        return $parsedMethod;
    }
567563
private function parse()
    {
        $opts = $this->result->options;
        $commandName = $this->result->command_name;
        $command = null;
        $optionSet = $argumentSet = false;

        // special treatment for -h --help main command options
        if ($opts['help'] === true) {
            $commandName = 'help';
        }

        if ($commandName) {
            $configFile = $this->paths['configs'] . 'commands/' . $commandName . '.yml';
            $command = new Command($configFile);
        }

        // check if any option is set
        // basically check for --version -v --help -h options
        foreach ($opts as $name => $value) {
            if ($value === true) {
                $optionSet = true;
                break;
            }
        }

        // fire up subcommand
        if (isset($command['callback'])) {
            $this->invoke($command['callback'], $command);
        }

        if ($commandName === false && $optionSet === false && $argumentSet === false) {
            $this->parser->outputter->stdout("Type 'phrozn help' for usage.\n");
        }
    }
507617
private function parse()
    {
        if (! $this->state = self::STATE_COMPLETE) {
            throw new QueryBuilderException("Query is not yet completed!");
        }

        if ($this->parser === null) {
            $this->parser = new Parser($this);
        }

        $this->parser->validate();

        return $this->parser;
    }
1193163
protected function parseParams()
    {

        $argumentStack = $this->arguments;

        $expectingValue = false;
        $currentLongName = null;
        $currentValue = null;
        $trailingValues = "";
        $endOfDashedArguments = false;
        $addParam = false;
        $argumentsLeft = sizeof($argumentStack);
        $multiShortParams = array();

        $this->programName = array_shift($argumentStack); // remove first argument which is the program name

        while ($currentArgument = array_shift($argumentStack)) {
            $argumentsLeft--;
            $currentArgumentLength = strlen($currentArgument);

            // arguments that don't start with a dash
            if (substr($currentArgument, 0, 1) !== '-') {
                if ($expectingValue) {
                    $currentValue = $currentArgument;
                    $addParam = true;
                } else {
                    $trailingValues .= " ". $currentArgument;
                    $endOfDashedArguments = true;
                } //if

            // double dash detected
            } elseif (substr($currentArgument, 1, 1)  === '-') {
                if ($expectingValue) {
                    throw new \UnexpectedValueException("Parameter {$currentLongName} expects a values");
                } //if

                /* stop parsing arguments if double dash
                   only param is encountered  */
                if ($currentArgumentLength == 2) {
                    if ($trailingValues !== "") {
                        throw new \UnexpectedValueException("Trailing values must appear after double dash");
                    } //if

                    $trailingValues = " ". implode(" ", $argumentStack);
                    $argumentStack = array();
                    $endOfDashedArguments = true;
                    break;
                } //if

                $longNameParts = explode("=", substr($currentArgument, 2), 2);

                $currentLongName = $longNameParts[0];

                if (sizeof($longNameParts) > 1) {
                    $currentValue = $longNameParts[1];
                    $addParam = true;
                } elseif ($this->definitions->allowsValue($currentLongName)) {
                    $expectingValue = true;
                } else {
                    $addParam = true;
                } //if

            // single dash
            } else {
                if ($expectingValue) {
                    throw new \UnexpectedValueException("Parameter {$currentLongName} expects a values");
                } //if

                $shortNameParts = explode("=", substr($currentArgument, 1), 2);

                $shortName = $shortNameParts[0];

                if (strlen($shortName) <= 1) {
                    $currentLongName = $this->definitions->getLongName($shortName);

                    if ($currentLongName === null) {
                        throw new \InvalidArgumentException("Unable to find name with ".
                            "provided parameter ({$shortName})");
                    } //if

                    if (sizeof($shortNameParts) > 1) {
                        $currentValue = $shortNameParts[1];
                        $addParam = true;
                    } elseif ($this->definitions->allowsValue($currentLongName)) {
                        $expectingValue = true;
                    } else {
                        $addParam = true;
                    } //if

                } else {
                    $multiShortParams = str_split($shortName);

                    /* process the last one (which is the only one that can have a value) */
                    $lastParam = array_pop($multiShortParams);
                    $currentLongName = $this->definitions->getLongName($lastParam);
                    if (sizeof($shortNameParts) > 1) {
                        $currentValue = $shortNameParts[1];
                        $addParam = true;
                    } elseif ($this->definitions->allowsValue($lastParam)) {
                        $expectingValue = true;
                    } else {
                        $addParam = true;
                    } //if

                } //if
                
            } //if

            if ($addParam) {
                if ($endOfDashedArguments) {
                    throw new \UnexpectedValueException("Unexpected argument after undashed values");
                } //if

                /* Not sure how this could happen */
                // @codeCoverageIgnoreStart
                if ($currentLongName === false || $currentLongName === null) {
                    throw new \UnexpectedValueException("Missing argument name");
                } //if
                // @codeCoverageIgnoreEnd

                if (!$this->definitions->paramExists($currentLongName)) {
                    throw new \InvalidArgumentException("Invalid argument name");
                } //if

                $allowsMultiple = $this->definitions->allowsMultiple($currentLongName);
                $allowsValue = $this->definitions->allowsValue($currentLongName);

                if (isset($this->params[$currentLongName]) && !$allowsMultiple) {
                    throw new \UnexpectedValueException("Multiple instace of parameter {$currentLongName} not allowed");
                } //if

                if ($allowsValue) {
                    /* Missing values should always be detected before addParam is true */
                    // @codeCoverageIgnoreStart
                    if ($currentValue === null) {
                        throw new \UnexpectedValueException("Parameter {$currentLongName} expects a values");
                    } //if
                    // @codeCoverageIgnoreEnd

                } elseif ($currentValue !== null) {
                    throw new \UnexpectedValueException("Parameter {$currentLongName} does not accept values");

                } else {
                    $currentValue = true;
                } //if

                if ($allowsMultiple) {
                    if ($allowsValue) {
                        if (!isset($this->params[$currentLongName])) {
                            $this->params[$currentLongName] = array();
                        } //if

                        $this->params[$currentLongName][] = $currentValue;

                    } else {
                        if (!isset($this->params[$currentLongName])) {
                            $this->params[$currentLongName] = 0;
                        } //if

                        $this->params[$currentLongName]++;

                    } //if

                } else {
                    $this->params[$currentLongName] = $currentValue;
                } //if

                foreach ($multiShortParams as $shortName) {
                    $argumentStack[] = "-{$shortName}";
                    $argumentsLeft++;
                } //foreach

                /* reset stuff for next param */
                $expectingValue = false;
                $currentLongName = null;
                $currentValue = null;
                $addParam = false;
                $multiShortParams = array();

            } //if

        } //while

        if ($expectingValue !== false) {
            throw new \UnexpectedValueException("Parameter {$currentLongName} expects a values");
        } //if

        /* Not sure how this could happen */
        // @codeCoverageIgnoreStart
        if ($currentLongName !== null ||
            $addParam !== false ||
            $currentValue !== null ||
            sizeof($multiShortParams) !== 0) {
            throw new \UnexpectedValueException("Unable to process some parameters");
        } //if
        // @codeCoverageIgnoreEnd

        if ($trailingValues !== "") {
            $this->trailingValues = substr($trailingValues, 1); // remove extra space at the begging
        } //if

        $this->parsed = true;
    }
497596
protected function doParse()
    {
        $object = $this->objectNameToKey($this->objectName);

        if ('ok' !== $this->data['@attributes']['stat']) {
            $errorCode = (int) $this->data['@attributes']['err_code'];
            $errorMessage = $this->data['err'];

            if (in_array($errorCode, array(1, 15))) {
                throw new AuthenticationErrorException($errorMessage, $errorCode);
            } else {
                throw new RuntimeException($errorMessage, $errorCode);
            }
        } else {
            if (array_key_exists('result', $this->data)) {
                $this->parseMultiRecordResult($object, $this->data);
            } elseif (array_key_exists($object, $this->data)) {
                $this->parseSingleRecordResult($object, $this->data);
            } elseif (array_key_exists('api_key', $this->data)) {
                $this->resultCount = 0;
                $this->result = $this->data['api_key'];
            } else {
                $asString = true;
                throw new RuntimeException('Unknown response format: '.$this->responseObj->getBoby($asString));
            }
        }
    }
458076
public function parse()
    {
        $newTokens = array();
        $len = count($this->tokens);
        $this->stack = array();
        $propValue = 'PROPERTY';
        $pushes = array(
            'L_BRACKET' => 'bracket',
            'L_BRACE' => 'brace',
            'AT_IDENTIFIER' => 'at',
            'L_SQ_BRACKET' => 'square'
        );
        $pops = array(
            'R_BRACKET' => 'bracket',
            'R_BRACE' => 'brace',
            'R_SQ_BRACKET' => 'square'
        );
        $this->index = 0;
        while ($this->index < $len) {
            $token = &$this->tokens[$this->index];
            $stackSize = count($this->stack);
            $state = !$stackSize? null : $this->stack[$stackSize - 1];
            $tokName = &$token[0];
            $inBrace = in_array('brace', $this->stack);
            $inBracket = in_array('bracket', $this->stack);
            $inSq = in_array('square', $this->stack);
            $inAt = in_array('at', $this->stack);
            if ($tokName === self::$deleteToken) {
                continue;
            }

            if ($tokName === 'L_BRACE') {
                if ($state === 'at') {
                    array_pop($this->stack);
                }
                $this->stack[] = $pushes[$tokName];
                $propValue = 'PROPERTY';
            } elseif (isset($pushes[$tokName])) {
                $this->stack[] = $pushes[$tokName];
            } elseif (isset($pops[$tokName]) && $state === $pops[$tokName]) {
                array_pop($this->stack);
            } elseif (!$inBracket && $tokName === 'COLON') {
                $propValue = 'VALUE';
            } elseif ($tokName === 'SEMICOLON') {
                $propValue = 'PROPERTY';
                if ($state === 'at') {
                    array_pop($this->stack);
                }
            } elseif ($tokName === 'GENERIC_IDENTIFIER') {
                // this is where the fun starts.
                // we have to figure out exactly what this is
                // if we can look ahead and find a '{' before we find a
                // ';', then this is part of a selector.
                // Otherwise it's part of a property/value pair.
                // the exception is when we have something like:
                // font : { family : sans-serif; }
                // then we need to check for ':{'
                if ($inSq) {
                    $token[0] = 'ATTR_SELECTOR';
                } elseif ($inBracket) {
                    $this->parseIdentifier($token);
                } elseif (!$inAt) {
                    $semi = $this->nextOfType('SEMICOLON');
                    $colonBrace = $this->nextSequence(array('COLON', 'L_BRACE'), array('WHITESPACE'));
                    $brace = $this->nextOfType('L_BRACE');

                    $ruleTerminator = min($semi, $colonBrace);
                    if ($brace < $ruleTerminator) {
                        $this->parseRule();
                        $propValue = 'PROPERTY';
                    } else {
                        $this->tokens[$this->index][0] = $propValue;
                        if ($propValue === 'VALUE') {
                            $this->parseIdentifier($token);
                        }
                    }
                }
            }
            $this->index++;
        }
        $this->cleanup();
    }
575195
protected function parse()
    {
        $this->checkFormat();
        $this->parsePalmDb();
        $this->parsePalmDoc();
        $this->parseMobiHeader();
        $this->parseExth();
    }