/ \copydoc Erebot::Interfaces::Config::Proxy::parseReal()
551238
public function parseReal($module, $param, $default = null)
    {
        return $this->parseSomething(
            $module,
            $param,
            $default,
            array($this, 'parseRealHelper'),
            __FUNCTION__,
            'is_real'
        );
    }
964137
static function Configlist_closure(PHP_ParserGenerator_Data $lemp)
    {
        for ($cfp = self::$current; $cfp; $cfp = $cfp->next) {
            $rp = $cfp->rp;
            $dot = $cfp->dot;
            if ($dot >= $rp->nrhs) {
                continue;
            }
            $sp = $rp->rhs[$dot];
            if ($sp->type == PHP_ParserGenerator_Symbol::NONTERMINAL) {
                if ($sp->rule === 0 && $sp !== $lemp->errsym) {
                    PHP_ParserGenerator::ErrorMsg($lemp->filename, $rp->line,
                        "Nonterminal \"%s\" has no rules.", $sp->name);
                    $lemp->errorcnt++;
                }
                for ($newrp = $sp->rule; $newrp; $newrp = $newrp->nextlhs) {
                    $newcfp = self::Configlist_add($newrp, 0);
                    for ($i = $dot + 1; $i < $rp->nrhs; $i++) {
                        $xsp = $rp->rhs[$i];
                        if ($xsp->type == PHP_ParserGenerator_Symbol::TERMINAL) {
                            $newcfp->fws[$xsp->index] = 1;
                            break;
                        } elseif ($xsp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
                            for ($k = 0; $k < $xsp->nsubsym; $k++) {
                                $newcfp->fws[$xsp->subsym[$k]->index] = 1;
                            }
                            break;
                        } else {
                            $a = array_diff_key($xsp->firstset, $newcfp->fws);
                            $newcfp->fws += $a;
                            if ($xsp->lambda === false) {
                                break;
                            }
                        }
                    }
                    if ($i == $rp->nrhs) {
                        PHP_ParserGenerator_PropagationLink::Plink_add($cfp->fplp, $newcfp);
                    }
                }
            }
        }
    }
1239138
private static function parseMapping($mapping, &$i = 0, $references = array())
    {
        $output = array();
        $len = strlen($mapping);
        ++$i;
        $allowOverwrite = false;

        // {foo: bar, bar:foo, ...}
        while ($i < $len) {
            switch ($mapping[$i]) {
                case ' ':
                case ',':
                    ++$i;
                    continue 2;
                case '}':
                    if (self::$objectForMap) {
                        return (object) $output;
                    }

                    return $output;
            }

            // key
            $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false);

            if ('<<' === $key) {
                $allowOverwrite = true;
            }

            // value
            $done = false;

            while ($i < $len) {
                switch ($mapping[$i]) {
                    case '[':
                        // nested sequence
                        $value = self::parseSequence($mapping, $i, $references);
                        // Spec: Keys MUST be unique; first one wins.
                        // Parser cannot abort this mapping earlier, since lines
                        // are processed sequentially.
                        // But overwriting is allowed when a merge node is used in current block.
                        if ('<<' === $key) {
                            foreach ($value as $parsedValue) {
                                $output += $parsedValue;
                            }
                        } elseif ($allowOverwrite || !isset($output[$key])) {
                            $output[$key] = $value;
                        }
                        $done = true;
                        break;
                    case '{':
                        // nested mapping
                        $value = self::parseMapping($mapping, $i, $references);
                        // Spec: Keys MUST be unique; first one wins.
                        // Parser cannot abort this mapping earlier, since lines
                        // are processed sequentially.
                        // But overwriting is allowed when a merge node is used in current block.
                        if ('<<' === $key) {
                            $output += $value;
                        } elseif ($allowOverwrite || !isset($output[$key])) {
                            $output[$key] = $value;
                        }
                        $done = true;
                        break;
                    case ':':
                    case ' ':
                        break;
                    default:
                        $value = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i, true, $references);
                        // Spec: Keys MUST be unique; first one wins.
                        // Parser cannot abort this mapping earlier, since lines
                        // are processed sequentially.
                        // But overwriting is allowed when a merge node is used in current block.
                        if ('<<' === $key) {
                            $output += $value;
                        } elseif ($allowOverwrite || !isset($output[$key])) {
                            $output[$key] = $value;
                        }
                        $done = true;
                        --$i;
                }

                ++$i;

                if ($done) {
                    continue 2;
                }
            }
        }

        throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping));
    }
358847
protected function _parseLang() {
        $this->_content = preg_replace_callback('`' . preg_quote($this->markup['vars'][7]) . '(\:)(.*)' . preg_quote($this->markup['vars'][2]) . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseLangCallBack'], $this->_content);
        $this->_content = preg_replace_callback('`' . preg_quote($this->markup['vars'][7]) . '(\[template\]\:)(.+)' . preg_quote($this->markup['vars'][2]) . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseLangCallBack'], $this->_content);
        $this->_content = preg_replace_callback('`' . preg_quote($this->markup['vars'][9]) . '(\:)(.*)' . preg_quote($this->markup['vars'][3]) . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseLangCallBackNoEcho'], $this->_content);
        $this->_content = preg_replace_callback('`' . preg_quote($this->markup['vars'][9]) . '(\[template\]\:)(.+)' . preg_quote($this->markup['vars'][3]) . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseLangCallBackNoEcho'], $this->_content);
    }
1075215
public function mergeWith(Parsed $other)
    {
        $mergeMethod = Translations::MERGE_ADD | Translations::MERGE_PLURAL;
        if ($other->sourceStrings !== null) {
            if ($this->sourceStrings === null) {
                $this->sourceStrings = $other->sourceStrings;
            } else {
                $this->sourceStrings->mergeWith($other->sourceStrings, $mergeMethod);
            }
        }
        foreach ($other->translations as $key => $data) {
            if (isset($this->translations[$key])) {
                $this->translations[$key][1]->mergeWith($data[1], $mergeMethod);
            } else {
                $this->translations[$key] = $data;
            }
        }
    }
636478
public function readExtendedMetadata($meta, array &$config)
    {
        $class = $this->getMetaReflectionClass($meta);
        /* @var $relationOverrides RelationOverrides */
        if (!($relationOverrides = $this->reader->getClassAnnotation($class, RelationOverrides::class))) {
            return;
        }

        $config['relationOverrides'] = [];

        /* @var $relationOverride RelationOverride */
        foreach ($relationOverrides->value as $relationOverride) {
            $fieldName = $relationOverride->name;

            if (!$class->hasProperty($fieldName)) {
                throw new MappingException(sprintf(
                    "Property %s doesn't exist",
                    $meta->getName() . '::$' . $fieldName
                ));
            }

            if ($meta->isMappedSuperclass && !$class->getProperty($fieldName)->isPrivate() ||
                $meta->isInheritedField($fieldName) ||
                $meta->hasField($fieldName))
            {
                continue;
            }

            $config['relationOverrides'][] = $relationOverride;
        }
    }
1289668
protected function _parseGravatar() {
        $this->_content = preg_replace_callback('`' . preg_quote($this->markup['vars'][4]) . '(.+):(.+)' . preg_quote($this->markup['vars'][2]) . '`sU', ['Gcs\Framework\Core\Template\Parser', '_parseGravatarCallback'], $this->_content);
        $this->_content = preg_replace_callback('`' . preg_quote($this->markup['vars'][4]) . '(.+)' . preg_quote($this->markup['vars'][2]) . '`sU', ['Gcs\Framework\Core\Template\Parser', '_parseGravatarCallback'], $this->_content);
    }
971173
function parse_contents($contents)
	{
		if($this->fix_newlines) {
			// fix mac/dos formatted newlines
			$contents = preg_replace('!\r\n?!', "\n", $contents);
		}

		$config_data = array();
		$config_data['sections'] = array();
		$config_data['vars'] = array();

		/* reference to fill with data */
		$vars =& $config_data['vars'];

		/* parse file line by line */
		preg_match_all('!^.*\r?\n?!m', $contents, $match);
		$lines = $match[0];
		for ($i=0, $count=count($lines); $i<$count; $i++) {
			$line = $lines[$i];
			if (empty($line)) continue;

			if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
				/* section found */
				if (substr($match[1], 0, 1) == '.') {
					/* hidden section */
					if ($this->read_hidden) {
						$section_name = substr($match[1], 1);
					} else {
						/* break reference to $vars to ignore hidden section */
						unset($vars);
						$vars = array();
						continue;
					}
				} else {
					$section_name = $match[1];
				}
				if (!isset($config_data['sections'][$section_name]))
				$config_data['sections'][$section_name] = array('vars' => array());
				$vars =& $config_data['sections'][$section_name]['vars'];
				continue;
			}

			if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
				/* variable found */
				$var_name = rtrim($match[1]);
				if (strpos($match[2], '"""') === 0) {
					/* handle multiline-value */
					$lines[$i] = substr($match[2], 3);
					$var_value = '';
					while ($i<$count) {
						if (($pos = strpos($lines[$i], '"""')) === false) {
							$var_value .= $lines[$i++];
						} else {
							/* end of multiline-value */
							$var_value .= substr($lines[$i], 0, $pos);
							break;
						}
					}
					$booleanize = false;

				} else {
					/* handle simple value */
					$var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
					$booleanize = $this->booleanize;

				}
				$this->_set_config_var($vars, $var_name, $var_value, $booleanize);
			}
			/* else unparsable line / means it is a comment / means ignore it */
		}
		return $config_data;
	}
991121
private function parseTranslatableStrings(\Gettext\Translations $translations, $rootDirectory, $prefix, $directoryAlternatives)
    {
        foreach ($this->getTranslatableKeys() as $key => $context) {
            list($baseFilename, $subkey) = explode('.', $key, 2);
            foreach ($directoryAlternatives as $subDir) {
                $rel = ($subDir === '') ? "{$baseFilename}.php" : "{$subDir}/{$baseFilename}.php";
                $fileAbs = $rootDirectory.'/'.$rel;
                if (!is_file($fileAbs)) {
                    continue;
                }
                $fileRel = $prefix.$rel;
                $configFile = new \C5TL\Util\ConfigFile($fileAbs);
                $config = $configFile->getArray();
                $subkeys = explode('.', $subkey);
                while (($k = array_shift($subkeys)) !== null) {
                    if (!is_array($config) || !isset($config[$k])) {
                        $config = null;
                        break;
                    }
                    $config = $config[$k];
                }
                if ($config !== null) {
                    $this->parseTranslatableConfigValue($context, $config, $translations, $fileRel);
                }
            }
        }
    }
548773
public function load($configData, $source)
    {
        $logger = \Plop\Plop::getInstance();
        $possibleSources = array(
            self::LOAD_FROM_FILE,
            self::LOAD_FROM_STRING,
        );
        if (!in_array($source, $possibleSources, true)) {
            throw new \Erebot\InvalidValueException('Invalid $source');
        }

        if ($source == self::LOAD_FROM_FILE) {
            if (is_string($configData) && $configData != "") {
                if (!strncasecmp(PHP_OS, "Win", 3)) {
                    if (!in_array($configData[0], array("/", "\\")) &&
                        strlen($configData) > 1 && $configData[1] != ":") {
                        $configData = getcwd() . DIRECTORY_SEPARATOR .
                                        $configData;
                    }
                } elseif ($configData[0] != DIRECTORY_SEPARATOR) {
                    $configData = getcwd() . DIRECTORY_SEPARATOR . $configData;
                }
                $file = \Erebot\URI::fromAbsPath($configData, false);
            } elseif (is_object($configData) &&
                $configData instanceof \Erebot\URIInterface) {
                $file = $configData;
            } else {
                throw new \Erebot\InvalidValueException(
                    "Invalid configuration file"
                );
            }
        } elseif (!is_string($configData)) {
            throw new \Erebot\InvalidValueException(
                "Invalid configuration file"
            );
        } else {
            $file = null;
        }

        $mainSchema = dirname(dirname(__DIR__)) .
                        DIRECTORY_SEPARATOR . 'data' .
                        DIRECTORY_SEPARATOR . 'config.rng';
        $mainSchema = file_get_contents($mainSchema);
        $ue         = libxml_use_internal_errors(true);
        $domxml     = new \Erebot\DOM();
        if ($source == self::LOAD_FROM_FILE) {
            $domxml->load((string) $file);
        } else {
            $domxml->loadXML($configData);
        }

        $domxml->xinclude(LIBXML_NOBASEFIX);
        $this->stripXGlobWrappers($domxml);

        $ok         = $domxml->relaxNGValidateSource($mainSchema);
        $errors     = $domxml->getErrors();
        libxml_use_internal_errors($ue);

        if (!$ok || count($errors)) {
            // Some unpredicted error occurred,
            // show some (hopefully) useful information.
            $logger->error(print_r($errors, true));
            throw new \Erebot\InvalidValueException(
                'Errors were found while validating the configuration file'
            );
        }

        $xml = simplexml_import_dom($domxml);
        parent::__construct($this, $xml);

        if (!isset($xml['version'])) {
            $this->version = null;
        } else {
            $this->version  = (string) $xml['version'];
        }

        if (!isset($xml['timezone'])) {
            throw new \Erebot\InvalidValueException('No timezone defined');
        }
        $this->timezone = (string) $xml['timezone'];

        // Set timezone information.
        // This is needed to configure the logging subsystem.
        if (function_exists('date_default_timezone_set')) {
            if (!date_default_timezone_set($this->timezone)) {
                throw \Erebot\InvalidValueException(
                    sprintf(
                        'Invalid timezone: "%s"',
                        $this->timezone
                    )
                );
            }
        }

        $daemonize      = isset($xml['daemon'])
                        ? $this->parseBool((string) $xml['daemon'])
                        : false;
        $userIdentity   = isset($xml['uid']) ? ((string) $xml['uid']) : null;
        $groupIdentity  = isset($xml['gid']) ? ((string) $xml['gid']) : null;
        $pidfile        = isset($xml['pidfile'])
                        ? ((string) $xml['pidfile'])
                        : null;

        if ($daemonize === null) {
            throw new \Erebot\InvalidValueException('Invalid "daemon" value');
        }

        if (!isset($xml['commands-prefix'])) {
            $this->commandsPrefix = '!';
        } else {
            $this->commandsPrefix = (string) $xml['commands-prefix'];
            if (strcspn($this->commandsPrefix, " \r\n\t") !=
                strlen($this->commandsPrefix)) {
                throw new \Erebot\InvalidValueException(
                    'Invalid command prefix'
                );
            }
        }

        $logger->debug(
            $this->coreTranslator->gettext(
                'Loaded configuration data'
            )
        );

        $this->networks = array();
        foreach ($xml->networks->network as $netCfg) {
            /// @TODO use dependency injection instead.
            $newConfig  = new \Erebot\Config\Network($this, $netCfg);
            $this->networks[$newConfig->getName()] = $newConfig;
            unset($newConfig);
        }

        if ($source == self::LOAD_FROM_FILE) {
            $this->configFile   = $configData;
        } else {
            $this->configFile   = null;
        }

        // Default values.
        $this->daemonize        = $daemonize;
        $this->userIdentity     = $userIdentity;
        $this->groupIdentity    = $groupIdentity;
        $this->pidfile          = $pidfile;
    }
357653
static function Configtable_insert(PHP_ParserGenerator_Config $data)
    {
        $h = self::confighash($data);
        if (isset(self::$x4a[$h])) {
            $np = self::$x4a[$h];
        } else {
            $np = 0;
        }
        while ($np) {
            if (self::Configcmp($np->data, $data) == 0) {
                /* An existing entry with the same key is found. */
                /* Fail because overwrite is not allows. */
                return 0;
            }
            $np = $np->next;
        }
        /* Insert the new data */
        $np = array('data' => $data, 'next' => 0, 'from' => 0);
        $np = new PHP_ParserGenerator_StateNode;
        $np->data = $data;
        if (isset(self::$x4a[$h])) {
            self::$x4a[$h]->from = $np->next;
            $np->next = self::$x4a[$h];
        }
        $np->from = $np;
        self::$x4a[$h] = $np;
        return 1;
    }
734384
private function parseConn($conn)
    {
        while(true)
        {
            $meta = fread($conn, 4);
            if('' === $meta || false === $meta)
            {
                return;
            }
            $length = unpack('N', $meta)[1];
            $data = fread($conn, $length);
            if(false === $data || !isset($data[$length - 1]))
            {
                return;
            }
            $body = ($this->unserialize)($data);
            if(!$body instanceof Operation)
            {
                return;
            }
            try{
                $result = new Result($this->operationParser->parse($body));
            } catch(\Throwable $th) {
                $result = new Result(null, $th);
            }
            $resultData = ($this->serialize)($result);
            $length = strlen($resultData);
            $resultData = pack('N', $length) . $resultData;
            fwrite($conn, $resultData, $length + 4);
        }
    }
979563
function ConfigPrint($fp)
    {
        $rp = $this->rp;
        fprintf($fp, "%s ::=", $rp->lhs->name);
        for ($i = 0; $i <= $rp->nrhs; $i++) {
            if ($i === $this->dot) {
                fwrite($fp,' *');
            }
            if ($i === $rp->nrhs) {
                break;
            }
            $sp = $rp->rhs[$i];
            fprintf($fp,' %s', $sp->name);
            if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
                for ($j = 1; $j < $sp->nsubsym; $j++) {
                    fprintf($fp, '|%s', $sp->subsym[$j]->name);
                }
            }
        }
    }
1178944
public function parse($template)
    {
        $tree = $this->syntax->read($template);

        $compiler = new Compiler();
        $compiler->compile(new ClosureNode($tree));

        return $compiler->getSource();
    }
216126
public function parse()
    {

        // load the web application base directory
        $webappPath = $this->getAuthenticationContext()->getWebappPath();

        // prepare the deployment descriptor
        $deploymentDescriptor = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF' . DIRECTORY_SEPARATOR . 'web.xml';

        // query whether we found epb.xml deployment descriptor file
        if (file_exists($deploymentDescriptor) === false) {
            return;
        }

        // validate the passed configuration file
        /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */
        $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService');
        $configurationService->validateFile($deploymentDescriptor, null, true);

        // prepare and initialize the configuration node
        $webAppNode = new WebAppNode();
        $webAppNode->initFromFile($deploymentDescriptor);

        // query whether or not we've a login configuration
            /** @var \AppserverIo\Appserver\Core\Api\Node\LoginConfigNode $loginConfig */
        if ($loginConfig = $webAppNode->getLoginConfig()) {
            // create the authentication method instance
            $reflectionClass = new ReflectionClass($this->mapAuthenticator($loginConfig->getAuthMethod()->__toString()));
            $authenticator = $reflectionClass->newInstanceArgs(array($loginConfig, $this->getAuthenticationContext(), new Boolean(true)));

            // add the authentication method itself
            $this->getAuthenticationContext()->addAuthenticator($authenticator);

            // initialize the security roles, that are part of the new security subsystem
            /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityRoleNode $securityRoleNode */
            foreach ($webAppNode->getSecurityRoles() as $securityRoleNode) {
                // do something here
            }

            // initialize the security roles, that are part of the new security subsystem
            /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityConstraintNode $securityContstraintNode */
            foreach ($webAppNode->getSecurityConstraints() as $securityContstraintNode) {
                // prepare the array with the authentication constraint role names
                $roleNames = array();
                if ($authConstraint = $securityContstraintNode->getAuthConstraint()) {
                    $roleNames = $authConstraint->getRoleNamesAsArray();
                }
                /** @var \AppserverIo\Appserver\Core\Api\Node\WebResourceCollectionNode $webResourceCollectionNode */
                foreach ($securityContstraintNode->getWebResourceCollections() as $webResourceCollectionNode) {
                    // prepare the arrays for the HTTP methods and the method omissions
                    $httpMethods = $webResourceCollectionNode->getHttpMethodsAsArray();
                    $httpMethodOmissions = $webResourceCollectionNode->getHttpMethodOmissionsAsArray();
                    /** @var \AppserverIo\Appserver\Core\Api\Node\UrlPatternNode $urlPatternNode */
                    foreach ($webResourceCollectionNode->getUrlPatterns() as $urlPatternNode) {
                        // prepare the URL pattern to authenticator mapping with the necessary data
                        $mapping = new Mapping(
                            $urlPatternNode->__toString(),
                            $authenticator->getSerial(),
                            $roleNames,
                            $httpMethods,
                            $httpMethodOmissions
                        );
                        // add the URL pattern to authenticator mapping
                        $this->getAuthenticationContext()->addMapping($mapping);
                    }
                }
            }
        }
    }
909237
private function parseOriginalContent()
    {
        $content = $this->exists() ? file_get_contents($this->getPath()) : '';
        $this->arrayKeys = JsonFormatter::getArrayKeys($content);
        $this->indent = JsonFormatter::getIndent($content);
    }
931020
protected function read($len)
    {
        $contents   = "";
        $clen       = 0;
        while (!feof($this->socket) && $clen < $len) {
            $read = fread($this->socket, $len - $clen);
            if ($read === false) {
                throw new \Erebot\Exception('Connection closed by proxy');
            }
            $contents  .= $read;
            $clen       = strlen($contents);
        }
        return $contents;
    }