/* PARSE METHODS
***********************************************************************
433516
public function parse($mixed)
    {
        if (\Staq\Util::isStack($mixed)) {
            return $this->parseFromStack($mixed);
        }
        return $this->parseFromString($mixed);
    }
397363
function parse(styles) {
  styles = (styles || '').trim();

  if (!styles) return {};

  return styles
    .split(';')
    .reduce(function(obj, str){
      var n = str.indexOf(':');
      // skip if there is no :, or if it is the first/last character
      if (n < 1 || n === str.length-1) return obj;
      obj[str.slice(0,n).trim()] = str.slice(n+1).trim();
      return obj;
    }, {});
}
1174464
private function parseFacts(): void
    {
        // Split the record into facts
        if ($this->gedcom) {
            $gedcom_facts = preg_split('/\n(?=1)/s', $this->gedcom);
            array_shift($gedcom_facts);
        } else {
            $gedcom_facts = [];
        }
        if ($this->pending) {
            $pending_facts = preg_split('/\n(?=1)/s', $this->pending);
            array_shift($pending_facts);
        } else {
            $pending_facts = [];
        }

        $this->facts = [];

        foreach ($gedcom_facts as $gedcom_fact) {
            $fact = new Fact($gedcom_fact, $this, md5($gedcom_fact));
            if ($this->pending !== null && !in_array($gedcom_fact, $pending_facts, true)) {
                $fact->setPendingDeletion();
            }
            $this->facts[] = $fact;
        }
        foreach ($pending_facts as $pending_fact) {
            if (!in_array($pending_fact, $gedcom_facts, true)) {
                $fact = new Fact($pending_fact, $this, md5($pending_fact));
                $fact->setPendingAddition();
                $this->facts[] = $fact;
            }
        }
    }
96437
private function parseMethods()
    {
        $methods = $this->reflectionClass->getMethods(); // this still returns the methods for all parent classes
        if (!is_array($methods) || count($methods) < 1) {
            throw new RestException('Parser: The class "' . $this->class . '" doesn\'t have any methods defined.');
        }

        foreach ($methods as $m) {
            if ($m->isPublic()) {
                $methodParser = new MethodParser($this->parentClasses, $m, $this->normalize);
                $parsedMethod = $methodParser->parse();
                if ($parsedMethod) {
                    $this->parsedClass->addApiMethod($parsedMethod);
                }
            }
        }
    }
817180
protected ISFSObject parseObject(GetterMethodCover method, 
            Object object) {
        return object2params(method.getReturnClass(), 
                object);
    }
1352277
function _parse_object_expressions(obj) {
	debug.assert(obj).is('object');
	if(!obj.$documents) {
		return;
	}

	var expressions = obj.$documents.expressions;
	if(!expressions) {
		return;
	}

	ARRAY(Object.keys(expressions)).forEach(function(prop) {
		var value = expressions[prop], key;
		// FIXME: This code should understand things better
		if(prop.substr(0, 'content.'.length) === 'content.') {
			key = prop.substr('content.'.length);
		} else {
			key = '$' + prop;
		}
		obj[key] = value;
	});
}
416374
@SuppressWarnings("rawtypes")
    protected void parseMethod(Object value, GetterMethodCover method,
            ISFSObject sfsObject) {
        Object answer = value;
        if(method.isColection()) {
            answer = parseCollection(method, (Collection)value);
        }
        else if(method.isTwoDimensionsArray()) {
            answer = parseTwoDimensionsArray(method, value);
        }
        else if(method.isArray()) {
            answer = parseArray(method, value);
        }
        else if(method.isObject()) {
            answer = parseObject(method, value);
        }
        else if(method.isChar()) {
            answer = (byte)(((Character)value).charValue());
        }
        SFSDataType type = getSFSDataType(method);
        sfsObject.put(method.getKey(), new SFSDataWrapper(type, answer));
    }
1063215
public function parse($date)
	{
		foreach ($this->user as $method)
		{
			if (($returned = call_user_func($method, $date)) !== false)
			{
				return $returned;
			}
		}

		foreach ($this->built_in as $method)
		{
			if (($returned = call_user_func(array($this, $method), $date)) !== false)
			{
				return $returned;
			}
		}

		return false;
	}
858478
protected function parse(): void
    {
        // add the root node
        $this->root = new HtmlNode('root');
        $activeNode = $this->root;
        while ( ! is_null($activeNode)) {
            $str = $this->content->copyUntil('<');
            if ($str == '') {
                $info = $this->parseTag();
                if ( ! $info['status']) {
                    // we are done here
                    $activeNode = null;
                    continue;
                }

                // check if it was a closing tag
                if ($info['closing']) {
                    $foundOpeningTag  = true;
                    $originalNode     = $activeNode;
                    while ($activeNode->getTag()->name() != $info['tag']) {
                        $activeNode = $activeNode->getParent();
                        if (is_null($activeNode)) {
                            // we could not find opening tag
                            $activeNode = $originalNode;
                            $foundOpeningTag = false;
                            break;
                        }
                    }
                    if ($foundOpeningTag) {
                        $activeNode = $activeNode->getParent();
                    }
                    continue;
                }

                if ( ! isset($info['node'])) {
                    continue;
                }

                /** @var AbstractNode $node */
                $node = $info['node'];
                $activeNode->addChild($node);

                // check if node is self closing
                if ( ! $node->getTag()->isSelfClosing()) {
                    $activeNode = $node;
                }
            } else if ($this->options->whitespaceTextNode ||
                trim($str) != ''
            ) {
                // we found text we care about
                $textNode = new TextNode($str, $this->options->removeDoubleSpace);
                $activeNode->addChild($textNode);
            }
        }
    }
446146
function parse(method, req, res, options) {
    return new Promise(function(resolve, reject) {
        BodyParser[method](options)(req, res, function(err) {
            if (err) {
                return reject(err);
            }

            return resolve();
        });
    });
}
1258849
protected function parse()
    {
        $query = preg_replace('/OR\s+REPLACE/', '', $this->value);
        /**
         * @TODO : Grant parse
         */
        if (preg_match(
            '/(CREATE|UPDATE|DELETE|ALTER|INSERT|DROP|SELECT|GRANT)\s+(SEQUENCE|INDEX|SYNONYM|TABLE|INTO|FROM|VIEW|)\s*([a-zA-Z-_]*)\s*/im',
            $query,
            $matches
        )
        ) {
            $this->type = trim(strtolower($matches[1]));
            if (in_array($this->type, array('create', 'drop'))) {
                $this->type = strtolower(trim(sprintf('%s_%s', $matches[1], $matches[2])));
            }

            $this->data = array(
                'identifier' => $matches[3]
            );
        }
    }
400138
function parse_request(){
		parent::parse_request();
		if (count($this->config->text)){
			if (isset($_GET["to"]))
				$this->request->set_filter($this->config->text[0]["name"],$_GET["to"],"<");
			if (isset($_GET["from"]))
				$this->request->set_filter($this->config->text[1]["name"],$_GET["from"],">");
		}
	}
1280512
function parseApplications(response) {
  let entities = {};
  Object.keys(response).forEach(key => {
    entities[key] = parseApplication(response[key]);
  });
  return entities;
}
1141634
public function parse()
    {
        $this->lexer->moveNext();

        while (true) {
            if (!$this->lexer->lookahead) {
                break;
            }

            $this->lexer->moveNext();
            $thisLine = null;

            switch ($this->lexer->token['type']) {
                case Lexer::T_OPEN_PARENTHESIS:
                case Lexer::T_OPEN_BRACKET:
                case Lexer::T_OPEN_CURLY_BRACE:
                    $thisLine = '[';
                    $this->currentLevel++;
                    break;
                case Lexer::T_CLOSE_PARENTHESIS:
                case Lexer::T_CLOSE_BRACKET:
                case Lexer::T_CLOSE_CURLY_BRACE:
                    $thisLine = ']';
                    $this->currentLevel--;
                    break;
                case Lexer::T_STRING:
                    $thisLine = "'".str_replace("'", "\'", $this->lexer->token['value'])."'";
                    break;
                case Lexer::T_DOUBLEPOINT:
                    $thisLine = '=>';
                    break;
                case Lexer::T_COMMENT_PARAMSTART:
                    $paramName = $this->lexer->lookahead['value'];
                    $thisLine = '$this->getParam("'.$paramName.'")';
                    // scroll to end of param
                    while ($this->lexer->token['type'] != Lexer::T_COMMENT_PARAMEND) {
                        $this->lexer->moveNext();
                    }
                    break;
                case Lexer::T_COMMENT_IFPARAMSTART:
                case Lexer::T_COMMENT_IFNOTPARAMSTART:
                    $conditionalId = str_pad((string) $this->conditionalCounter, 5, '0', STR_PAD_LEFT);
                    $this->conditionalCounter++;

                    $isNegated = '';
                    if ($this->lexer->token['type'] == Lexer::T_COMMENT_IFNOTPARAMSTART) {
                        $isNegated = 'true';
                    }

                    $this->addContent('$this->getConditional'.$conditionalId.'('.$isNegated.'),');
                    $this->openConditional($conditionalId, $this->lexer->lookahead['value']);
                    break;
                case Lexer::T_COMMENT_IFPARAMEND:
                case Lexer::T_COMMENT_IFNOTPARAMEND:
                    $this->closeConditional();
                    break;
                case Lexer::T_DATE_EMPTY:
                    $thisLine = 'new '.$this->mongoDateClass.'()';
                    break;
                case Lexer::T_DATE_WITH_PARAM:
                    $paramName = $this->lexer->lookahead['value'];
                    $thisLine = '$this->getParam("'.$paramName.'")';
                    break;
                case Lexer::T_BOOLEAN_TRUE:
                    $thisLine = 'true';
                    break;
                case Lexer::T_BOOLEAN_FALSE:
                    $thisLine = 'false';
                    break;
                case Lexer::T_NULL:
                    $thisLine = 'null';
                    break;
                case Lexer::T_COMMA:
                case Lexer::T_NUMBER:
                case Lexer::T_DASH:
                    $thisLine = $this->lexer->token['value'];
                    break;
                default:
                    // nothing
            }

            if (!is_null($thisLine)) {
                $this->addContent($thisLine);
            }
        }

        return implode(PHP_EOL, $this->lines);
    }
177914
protected function parseUrl(
        /*# string */ $httpMethod,
        /*# string */ $url
    ) {
        $this->server = $_SERVER;
        $server = &$this->server;

        // set http method
        if ($httpMethod) {
            $server['REQUEST_METHOD'] = $httpMethod;
        } elseif (!isset($server['REQUEST_METHOD'])) {
            $server['REQUEST_METHOD'] = 'GET';
        }

        // parse url
        if (empty($url)) {
            $this->request = $_REQUEST;
        } else {
            $parts = (array) parse_url($url);

            // scheme
            if (isset($parts['scheme'])) {
                $scheme = strtolower($parts['scheme']);
                $server['HTTPS'] = 'https' === $scheme ? $scheme : '';
            }

            // host
            if (isset($parts['host'])) {
                $server['HTTP_HOST'] = $parts['host'];
            }

            // port
            if (isset($parts['port'])) {
                $server['SERVER_PORT'] = $parts['port'];
            }

            // fix query
            $this->fixUrlQuery($parts);

            // fix path
            $this->fixUrlPath($parts);
        }

        // normalize
        $server['PATH_INFO'] = '/' . trim($server['PATH_INFO'], '/');

        return $this;
    }
743352
private function parseParameterValues()
    {
        $this->filterParameters = $this->parseOperators($this->filterParameters);
        foreach ($this->dataParameters as $key => $input) {
            $this->dataParameters[$key] = $this->parseValue($input);
        }
    }
394208
private void parseActions(String actions)
   {
      boolean exclusionListNeeded = actions != null && actions.startsWith("!");
      if (exclusionListNeeded)
         actions = actions.substring(1);

      Object[] methodInfo = canonicalMethods(actions);
      if (exclusionListNeeded)
      {
         this.httpExceptionList = (TreeSet<String>) methodInfo[0];
         this.httpExceptionString = (String) methodInfo[1];
      }
      else
      {
         this.httpMethods = (TreeSet<String>) methodInfo[0];
         this.httpMethodsString = (String) methodInfo[1];
      }
   }