Parses a tag line and extracts the tagname and values.

@param string The tagline
350536
protected function parseTagLine($tagLine)
    {
        $tagArr = explode(' ', $tagLine);
        $tag = array_shift($tagArr);

        switch (strtolower($tag)) {
            case 'abstract':
                $this->obj->abstract = true; break;
            case 'access':
                if (isset($tagArr[0])) {
                    $this->obj->isPrivate = (strtolower(trim($tagArr[0])) == 'private') ? true : false;
                }
                break;
            case 'author':
                $this->obj->author = implode(' ', $tagArr);
                break;
            case 'copyright':
                $this->obj->copyright = implode(' ', $tagArr);
                break;
            case 'deprecated':
            case 'deprec':
                $this->obj->deprecated = true;
                break;
            case 'extends': break;
            case 'global':
                if (isset($tagArr[0])) {
                    $this->obj->globals[] = $tagArr[0];
                }
                break;
            case 'param':
                $o = new stdClass();
                $o->type = trim(array_shift($tagArr));
                if ($o->type == 'object') {
                    $o->type = 'stdClass';
                }
                $o->comment = implode(' ', $tagArr);
                $this->obj->params[] = $o;
                break;
            case 'externalparam':
                // external parameter, to declare soap parameter that are not method
                // parameters
                $o = new stdClass();
                if (count($tagArr) < 2) {
                    throw new Exception('Not enough parameters on @externalparam '.$tagLine);
                }
                $o->type = trim(array_shift($tagArr));
                if ($o->type == 'object') {
                    $o->type = 'stdClass';
                }
                $o->name = ltrim(array_shift($tagArr), '$');
                $o->comment = implode(' ', $tagArr);
                $this->obj->externalParams[] = $o;
                break;
            case 'return':
                if (isset($tagArr[0])) {
                    $this->obj->return = trim($tagArr[0]);
                    if ($this->obj->return == 'object') {
                        $this->obj->return = 'stdClass';
                    }
                }
                break;
            case 'link':break;
            case 'see':break;
            case 'since':
                if (isset($tagArr[0])) {
                    $this->obj->since = trim($tagArr[0]);
                }
                break;
            case 'static':
                $this->obj->static = true; break;
            case 'throws':
                $this->obj->throws = implode(' ', $tagArr);
                break;
            case 'todo':
                $this->obj->todo[] = implode(' ', $tagArr);
                break;
            case 'var':
                $this->obj->type = trim(array_shift($tagArr));
                $comment = implode(' ', $tagArr);
                //check if its an optional property
                $this->obj->optional = strpos($comment, '[OPTIONAL]') !== false;
                $this->obj->autoincrement = strpos($comment, '[AUTOINCREMENT]') !== false;
                $this->obj->description = trim(str_replace(array('[OPTIONAL]', '[AUTOINCREMENT]'), '', $comment));
                break;
            case 'version':
                if (isset($tagArr[0])) {
                    $this->obj->version = $tagArr[0];
                }
                break;
            default:
                //do nothing
        }
    }
202826
public function parseBody( $line )
    {
        $line = rtrim( $line, "\r\n" );
        if ( $this->text === null )
        {
            $this->text = $line;
        }
        else
        {
            $this->text .= "\n" . $line;
        }
    }
948948
protected function readReply(&$untagged = null)
    {
        do {
            $line = trim($this->readLine(1024));
            // store untagged response lines
            if ($line[0] == '*') {
                $untagged[] = $line;
            }
        }
        while ($line[0] == '*');

        if ($untagged) {
            $untagged = join("\n", $untagged);
        }

        return $line;
    }
1346837
protected function parseTagLine( Line$line ):self
	{
		$node= new TagNode($this,$line);

		$this->appendLine($node->open());

		$node->embed and $this->startEmbedding($node->embed);

		return $this->openNode($node);
	}
143260
private Tag parseTag() throws IOException, XMLStreamException {
		Tag tag = null;
		boolean go = true;
		state = 0;
		int c, quote=0; // If "quote" is 0, then we're not in a quote.  We set ' (in pretag) or " in attribs accordingly to denote quoted
		String prefix=null,name=null,value=null;
		baos.reset();
		
		while(go && (c=is.read())>=0) {
			++count;
			if(quote!=0) { // If we're in a quote, we only end if we hit another quote of the same time, not preceded by \
				if(c==quote && last!='\\') {
					quote=0;
				} else {
					baos.write(c);
				}
			} else if((state&COMMENT)==COMMENT) { // similar to Quote is being in a comment
				switch(c) {
					case '-':
						switch(state) { // XML has a complicated Quote set... <!-- --> ... we keep track if each has been met with flags. 
							case COMMENT|COMMENT_E:
								state|=COMMENT_D1;
								break;
							case COMMENT|COMMENT_E|COMMENT_D1:
								state|=COMMENT_D2;
								baos.reset();				// clear out "!--", it's a Comment
								break;
							case COMMENT|COMMENT_E|COMMENT_D1|COMMENT_D2:
								state|=COMMENT_D3;
								baos.write(c);
								break;
							case COMMENT|COMMENT_E|COMMENT_D1|COMMENT_D2|COMMENT_D3:
								state|=COMMENT_D4;
								baos.write(c);
								break;
						}
						break;
					case '>': // Tag indicator has been found, do we have all the comment characters in line?
						if((state&COMPLETE_COMMENT)==COMPLETE_COMMENT) {
							byte ba[] = baos.toByteArray();
							tag = new Tag(null,null, new String(ba,0,ba.length-2));
							baos.reset();
							go = false;
							break;
						}
						// fall through on purpose
					default:
						state&=~(COMMENT_D3|COMMENT_D4);
						if((state&IN_COMMENT)!=IN_COMMENT) state&=~IN_COMMENT; // false alarm, it's not actually a comment
						baos.write(c);
				}
			} else { // Normal Tag Processing loop
				switch(c) {
					case '?': 
						switch(state & (QUESTION_F|QUESTION)) {  // Validate the state of Doc tag... <?xml ... ?>
							case QUESTION_F:
								state |= DOC_TYPE;
								state &= ~QUESTION_F;
								break;
							case 0:
								state |=QUESTION_F;
								break;
							default:
								throw new IOException("Bad character [?] at " + count);
						}
						break;
					case '!':
						if(last=='<') { 
							state|=COMMENT|COMMENT_E; // likely a comment, continue processing in Comment Loop
						}
						baos.write(c);
						break;
					case '/':
						state|=(last=='<'?END_TAG:(END_TAG|START_TAG));  // end tag indicator </xxx>, ,or both <xxx/>
						break;
					case ':':
						prefix=baos.toString(); // prefix indicator
						baos.reset();
						break;
					case '=':					// used in Attributes
						name=baos.toString();
						baos.reset();
						state|=VALUE;
						break;
					case '>': // end the tag, which causes end of this subprocess as well as formulation of the found data
						go = false;
						// passthrough on purpose
					case ' ':
					case '\t':
					case '\n': // white space indicates change in internal tag state, ex between name and between attributes
						if((state&VALUE)==VALUE) {
							value = baos.toString();	// we're in VALUE state, add characters to Value
						} else if(name==null) {
							name = baos.toString();		// we're in Name state (default) add characters to Name
						}
						baos.reset();					// we've assigned chars, reset buffer
						if(name!=null) {				// Name is not null, there's a tag in the offing here...
							Tag t = new Tag(prefix,name,value);
							if(tag==null) {				// Set as the tag to return, if not exists
								tag = t;
							} else {					// if we already have a Tag, then we'll treat this one as an attribute
								tag.add(t);
							}
						}
						prefix=name=value=null;			// reset these values in case we loop for attributes.
						break;
					case '\'':							// is the character one of two kinds of quote?
					case '"':
						if(last!='\\') {
							quote=c;
							break;
						}
						// Fallthrough ok
					default:
						baos.write(c);					// write any unprocessed bytes into buffer
						
				}
			}
			last = c;
		}
		int type = state&(DOC_TYPE|COMMENT|END_TAG|START_TAG); // get just the Tag states and turn into Type for Tag
		if(type==0) {
			type=START_TAG;
		}
		tag.state|=type;	// add the appropriate Tag States
		return tag;
	}
852887
private function parseLine( $line, $info ) 
	{
		$handled = false;
		if (preg_match('/^\s*(@[a-z]+)\s(.*)$/i', $line, $matches)) 
		{
			$this->currentTag = substr($matches[1], 1);
			$line = trim( substr($line, strlen($this->currentTag)+2 ) );
			switch( $this->currentTag ) 
			{
				case 'param' :
					if ( preg_match('/^\s*([[:alpha:]|]+)\s([[:alnum:]$_]+)(.*)$/i', $line, $matches) ) 
					{
						if ( !isset($info['arguments']) ) {
							$info['arguments'] = array();
						}
						if ( !isset($info['arguments'][$matches[2]]) ) {
							$info['arguments'][$matches[2]] = array('description' => '');
						}
						$info['arguments'][$matches[2]]['type'] = $matches[1];
						$info['arguments'][$matches[2]]['description'] .= $this->parseDescription($matches[3]);
					}
					$handled = true;
				break;
				case 'return' :
					if ( preg_match('/^\s*([[:alpha:]|]+)\s(.*)$/i', $line, $matches) ) 
					{
						if ( !isset($info['return']) ) {
							$info['return'] = array( 'description' => '' );
						}
						$info['return']['type'] = $matches[1];
						$info['return']['description'] .= $this->parseDescription($matches[2]);
					}
					$handled = true;
				break;
			}
		}
		if (!$handled) {
			switch( $this->currentTag) {
				case 'param' :
				case 'return' :
					if ( !isset( $info[$this->currentTag] ) ) {
						$info[$this->currentTag] = array();
					}
					$info[$this->currentTag]['description'] .= $this->parseDescription($line);
				break;
				default:
					if ( !isset( $info[$this->currentTag] ) ) {
						$info[$this->currentTag] = '';
					}
					$info[$this->currentTag] .= $this->parseDescription($line);
				break;
			}
		}
		return $info;
	}
689235
public function parse($tag_name = null)
    {
        $namespaces = $this->feed->getNamespaces();
        $specs = \WebSyndication\Helper::getSpecifications($this->feed->getProtocol(), $this->feed->getVersion());
        if (!empty($tag_name) && isset($specs[$tag_name])) {

//if (self::$_debug) echo '<br />specs : '.var_export($specs,1);
//if (self::$_debug) echo '<br />XML : '.var_export($this->getXml(),1);

            foreach ($specs[$tag_name] as $var=>$spe) {
                $tagval = self::parseTag($this->getXml(), $var, $spe, $specs);
                if ($tagval) {
                    if (isset($spe['rename'])) {
                        $var = $spe['rename'];
                    }
                    if (self::$_debug) {
                        echo '<br />adding data for tag name "'.$var.'" : '.var_export($tagval, 1);
                    }
                    $this->addData($var, $tagval);
                }
            }
        } else {
            throw new \InvalidArgumentException(
                sprintf('Syndication parser method requires a valid tag name argument (got "%s")!', $tag_name)
            );
        }

        if (self::$_debug) {
            echo '<hr />finally got data : '.var_export($this->getData(), 1);
        }
        return $this->getData();
    }
783678
public static function extract($line)
    {
        $e = explode(': ', $line, 2);
        $header = strtolower(trim($e[0]));
        $value = isset($e[1]) ? trim($e[1]) : null;
        $safe = false;

        foreach (self::$safeCaseValues as $item) {
            if (strncasecmp($header, $item, mb_orig_strlen($item)) === 0) {
                $safe = true;
                break;
            }
            if (strncasecmp($value, $item, mb_orig_strlen($item)) === 0) {
                $safe = true;
                break;
            }
        }

        if (!$safe) {
            $value = strtolower($value);
        }

        return [$header, $value];
    }
1226177
private function parseResponseHeaderLine($line) {
        list($key, $value) = explode(':', $line, 2);
        $key = trim(strtolower(str_replace('-', '_', $key)));
        $value = trim($value);
        if (empty($this->headers[$key])) {
            $this->headers[$key] = $value;
        } elseif (is_array($this->headers[$key])) {
            $this->headers[$key][] = $value;
        } else {
            $this->headers[$key] = array($this->headers[$key], $value);
        }
    }
184336
function parse()
    {
        $criteria        = $this->criteria;
        $expectAsLiteral = $this->expectAsLiteral;


        $TOKENS  = preg_quote(static::TOKENS);

        $expectAsLiteral = (empty($expectAsLiteral)) ? '/@+-.' : $expectAsLiteral;
        $LITERAL = preg_quote($expectAsLiteral).'A-Za-z0-9_';


        $currentPos = 0;
        $length     = strlen($criteria);
        $parts      = [];
        $levelParts = [&$parts];
        $level      = 0;

        while ($currentPos < $length)
        {
            preg_match("(\G(?P<_literal_>[$LITERAL]*)(?P<_token_>[$TOKENS]|$))"
                , $criteria
                , $matches
                , 0
                , $currentPos
            );

            if ( empty($matches) )
                break;

            if (! empty($matches['_literal_']) ) {
                $levelParts[$level][] = ['_literal_' => $matches['_literal_']];
                $currentPos += strlen($matches['_literal_']);
            }

            # Deal With Token:
            if ( !isset($matches['_token_']) || $matches['_token_'] == '' )
                continue;

            $currentPos += strlen($matches['_token_']);
            $Token = $matches['_token_'];

            ## Regular Expression Token
            #
            #
            if ($Token === '~') {
                // ^ match any character that is not in list
                $pmatch = preg_match("/~(?P<_delimiter_>[^~]+)~/"
                    , $criteria
                    , $matches
                    , 0
                    , 0
                );
                if (! $pmatch )
                    throw new \RuntimeException('Miss usage of ~ ~ token.');

                $val['_regex_'] = $matches['_delimiter_'];
                $levelParts[$level][] = $val;

                $currentPos += strlen($matches[0])+2/*~x~*/;
            }
            ##
            # Variable
            # /:hash_id~\w{24}~
            #
            elseif ($Token === ':') {
                // ^$TOKENS  match any character that is not in list
                $pmatch = preg_match("(\G(?P<_name_>[^$TOKENS]+)(?:~(?P<_delimiter_>[^~]+)~)?:?)"
                    , $criteria
                    , $matches
                    , 0
                    , $currentPos
                );

                if (! $pmatch && !(isset($matches['_name_']) && isset($matches['_delimiter_'])) )
                    throw new \RuntimeException(
                        'Found empty parameter name or delimiter on (%s).'
                        , $criteria
                    );

                $parameter = $matches['_name_'];
                $val       = ['_parameter_' => $parameter];
                if (isset($matches['_delimiter_']))
                    $val[$parameter] = $matches['_delimiter_'];

                $levelParts[$level][] = $val;
                $currentPos += strlen($matches[0]);
            }

            ## Literal Token
            #  localhost\:port
            #
            elseif ($Token === '\\') {
                // Consider next character as Literal
                $nextChar = $currentPos += 1;
                $levelParts[$level][]   = ['_literal_' => $criteria[$nextChar]];
            }

            ## Optional Part
            #  /<u/:username~[a-zA-Z0-9._]+~><-:userid~\w{24}~>
            #
            elseif ($Token === '<') {
                if (! isset($va) ) {
                    $va = [];
                    $n = 0;
                }

                $n++;
                $va[$n] = [];
                $levelParts[$level][] = ['_optional_' => &$va[$n]];
                $level++;
                $levelParts[$level] = &$va[$n];
            }
            ## Close Optional ##
            elseif ($Token === '>') {
                unset($levelParts[$level]);
                $level--;

                if ($level < 0)
                    throw new \RuntimeException('Found closing bracket without matching opening bracket');
            }

            else
                // Recognized unused token return immanently
                $levelParts[$level][]   = ['_token_' => $Token];

        } // end while

        if ($level > 0)
            throw new \RuntimeException('Found unbalanced brackets');


        return ParsedCriteria::of($parts);
    }
232864
private function parseDescription( $line ) {
		while ( preg_match('/{@([^}]*)}/', $line, $matches) ) {
			switch( $matches[1] ) {
				case 'internal' : 
					$line = str_replace( $matches[0], '', $line );
				break;
				default :
					$line = str_replace( $matches[0], $matches[1], $line );
				break;
			}
		}
		$line = str_replace( array( '\@', '{@*}' ), array( '@', '*/' ), $line );
		return $line;
	}
743388
private function parse()
    {
        $this->rawDocblock = $this->reflection->getDocComment();
        $raw = str_replace("\r\n", "\n", $this->rawDocblock);
        $lines = explode("\n", $raw);
        $matches = null;

        switch (count($lines)) {
            case 1:
                if (!preg_match('#\\/\\*\\*([^*]*)\\*\\/#', $lines[0], $matches)) {
                    return;
                }
                $lines[0] = substr($lines[0], 3, -2);
                break;
            case 2:
                break;
            default:
                array_shift($lines);
                array_pop($lines);
                break;
        }
        $this->parseLines($lines);
    }
344693
protected static String parseValue (String line)
    {
        int eidx = line.indexOf("=");
        return (eidx == -1) ? "" : line.substring(eidx+1).trim();
    }
145364
private void parseLine( List<String> names, String line )
    {
        int commentPos = line.indexOf( '#' );
        if( commentPos >= 0 )
        {
            line = line.substring( 0, commentPos );
        }
        line = line.trim();
        if( !line.isEmpty() && !names.contains( line ) )
        {
            names.add( line );
        }
    }
780339
private Value parse(String line) {
        int i = line.indexOf(" : ");
        if (i == -1) {
            throw new IllegalArgumentException("Malformed line in RI Query "
                    + "result (expected ' : ' delimiter): '" + line + "'");
        } else {
            return NTriplesUtil.parseValue(line.substring(i + 3), factory);
        }
    }
663648
private function parseLine($line)
    {
        if ($line == '') {
            return;
        }

        $slices = NodeObject::getLineSlices($line);
        if ($this->isBlob()) {
            $this->pathChildren[] = $this->blob->getName();
        } else {
            if ($this->isRoot()) {
                // if is root check for first children
                $pattern = '/(\w+)\/(.*)/';
                $replacement = '$1';
            } else {
                // filter by the children of the path
                $actualPath = $this->subject->getFullPath();
                if (!preg_match(sprintf('/^%s\/(\w*)/', preg_quote($actualPath, '/')), $slices['fullPath'])) {
                    return;
                }
                $pattern = sprintf('/^%s\/(\w*)/', preg_quote($actualPath, '/'));
                $replacement = '$1';
            }

            $name = preg_replace($pattern, $replacement, $slices['fullPath']);
            if (strpos($name, '/') !== false) {
                return;
            }

            if (!in_array($name, $this->pathChildren)) {
                $path = rtrim(rtrim($slices['fullPath'], $name), '/');
                $treeObject = new TreeObject(
                    $this->repository,
                    $slices['permissions'],
                    $slices['type'],
                    $slices['sha'],
                    $slices['size'],
                    $name,
                    $path
                );
                $this->children[] = $treeObject;
                $this->pathChildren[] = $name;
            }
        }
    }
814231
public function parseString($string)
    {
        $lines     = preg_split('(\r\n|\r|\n)', $string);
        $lineCount = count($lines);
        $diffs     = array();
        $diff      = null;
        $collected = array();

        for ($i = 0; $i < $lineCount; ++$i) {
            if (preg_match('(^---\\s+(?P<file>\\S+))', $lines[$i], $fromMatch) &&
                 preg_match('(^\\+\\+\\+\\s+(?P<file>\\S+))', $lines[$i + 1], $toMatch))
            {
                // If a diff already has started, parse the colected lines for
                // the affected diff.
                if ($diff !== null) {
                    $this->parseFileDiff($diff, $collected);
                    $diffs[]   = $diff;
                    $collected = array();
                }

                $diff = new \Arbit\VCSWrapper\Diff\Collection($fromMatch['file'], $toMatch['file']);
                ++$i;
            } else {
                // Collect all lines, which do not indicate a starting diff.
                $collected[] = $lines[$i];
            }
        }

        // We reached the end of the diff, perhaps there are still lines to
        // calcualte a diff from?
        if (count($collected) &&
             ($diff !== null))
        {
            $this->parseFileDiff($diff, $collected);
            $diffs[] = $diff;
        }

        return $diffs;
    }