Internal method for parsing a single line. Used by both line based parsing
as well as block parsing. This saves the building of meta data for each
line.

@return {@code true} when a valid line was read, {@code false} on a label
row.
172030
protected boolean parseLineInternal() {
    // Split into numerical attributes and labels
    int i = 0;
    for(/* initialized by nextLineExceptComents()! */; tokenizer.valid(); tokenizer.advance(), i++) {
      if(!isLabelColumn(i) && !tokenizer.isQuoted()) {
        try {
          attributes.add(tokenizer.getDouble());
          continue;
        }
        catch(NumberFormatException e) {
          if(!warnedPrecision && (e == ParseUtil.PRECISION_OVERFLOW || e == ParseUtil.EXPONENT_OVERFLOW)) {
            getLogger().warning("Too many digits in what looked like a double number - treating as string: " + tokenizer.getSubstring());
            warnedPrecision = true;
          }
          // Ignore attempt, add to labels below.
        }
      }
      // Else: labels.
      String lbl = tokenizer.getStrippedSubstring();
      if(lbl.length() > 0) {
        haslabels = true;
        lbl = unique.addOrGet(lbl);
        labels.add(lbl);
      }
    }
    // Maybe a label row?
    if(curvec == null && attributes.size == 0) {
      columnnames = new ArrayList<>(labels);
      haslabels = false;
      curvec = null;
      curlbl = null;
      labels.clear();
      return false;
    }
    // Pass outside via class variables
    curvec = createVector();
    curlbl = LabelList.make(labels);
    attributes.clear();
    labels.clear();
    return true;
  }
580275
@Override
    public boolean parseAndValidateRequest() {
        boolean result = false;
        if(!super.parseAndValidateRequest() || !hasVectorClock(this.isVectorClockOptional)
           || !hasContentLength() || !hasContentType()) {
            result = false;
        } else {
            result = true;
        }

        return result;
    }
60785
public boolean nextLine() throws IOException {
    while(reader.readLine(buf.delete(0, buf.length()))) {
      ++lineNumber;
      if(lengthWithoutLinefeed(buf) > 0) {
        return true;
      }
    }
    return false;
  }
1346881
public boolean parse(Path ttmlFilePath) {
        boolean ret;
        try {
            final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);

            final DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(ttmlFilePath.toFile());

            //Check that we have TTML v1.0 file as we have tested only them...
            final NodeList metaData = doc.getElementsByTagName("ebuttm:documentEbuttVersion");
            if (metaData != null) {
                final Node versionNode = metaData.item(0);
                if (versionNode == null || !versionNode.getTextContent().equalsIgnoreCase("v1.0")) {
                    throw new Exception("Unknown TTML file version");
                }
            } else {
                throw new Exception("Unknown File Format");
            }

            buildColorMap();
            buildFilmList();
            ret = true;
        } catch (Exception ex) {
            //Log.errorLog(912036478, ex, new String[]{ex.getLocalizedMessage(), "File: " + ttmlFilePath});
            Log.errorLog(912036478, new String[]{ex.getLocalizedMessage(), "File: " + ttmlFilePath});
            ret = false;
        }
        return ret;
    }
980518
private boolean multiLineComment(Data data) throws TemplateException {
	SourceCode cfml = data.srcCode;
	if (!cfml.forwardIfCurrent("/*")) return false;
	int pos = cfml.getPos();
	boolean isDocComment = cfml.isCurrent('*');
	while (cfml.isValidIndex()) {
	    if (cfml.isCurrent("*/")) break;
	    cfml.next();
	}
	if (!cfml.forwardIfCurrent("*/")) {
	    cfml.setPos(pos);
	    throw new TemplateException(cfml, "comment is not closed");
	}
	if (isDocComment) {
	    String comment = cfml.substring(pos - 2, cfml.getPos() - pos);
	    data.docComment = docCommentTransformer.transform(data.factory, comment);
	}
	return true;
    }
1169177
protected boolean parse(ParsingContext context) {
		try {
			context.getParserInterceptor().openContext(context);
			boolean specialTagFound = false;
			final String lineSeparator = getLineSeparator();
			while (context.getMatcher().find()) {
				int groupIndex = findFirstGroup(context.getMatcher(), 0);
				final String tagName = context.getMatcher().group(groupIndex);
				if (lineSeparator.equals(tagName)) {
					context.incrementLineNo();
					continue;
				}
				final Tag tag = getTagForPattern(tagName);
				if (tag != null) {
					if (tag.isActive(context)) {
						final String tagDynamicName;
						if (tag.hasDynamicName()) {
							final OutParameter<String> dname = new OutParameter<>();
							extractDynamicName(tag, tagName, dname);
							tagDynamicName = dname.get();
						} else {
							tagDynamicName = null;
						}
						final String parameterValue;
						if (tag.hasParameter()) {
							groupIndex = findFirstGroup(context.getMatcher(), groupIndex);
							final String parameter = Strings.nullToEmpty(context.getMatcher().group(groupIndex));
							final ContentParserInterceptor subInterceptor = new ContentParserInterceptor(context.getParserInterceptor());
							final boolean inBlock = context.setInBlock(false);
							final boolean inParam = context.setInParameter(true);
							parse(parameter, context.getCurrentFile(),
									context.getMatcher().start(groupIndex) + context.getStartIndex(),
									context.getStage(),
									context,
									subInterceptor);
							context.setInParameter(inParam);
							context.setInBlock(inBlock);
							parameterValue = Strings.emptyToNull(subInterceptor.getResult());
						} else {
							parameterValue = null;
						}
						final String blockContent;
						if (tag.isOpeningTag()) {
							groupIndex = findFirstGroup(context.getMatcher(), groupIndex);
							final String tagContent = context.getMatcher().group(groupIndex);
							final ContentParserInterceptor subInterceptor = new ContentParserInterceptor(context.getParserInterceptor());
							final boolean inBlock = context.setInBlock(true);
							final boolean inParam = context.setInParameter(false);
							context.setVisibleInBlock(false);
							parse(Strings.nullToEmpty(tagContent), context.getCurrentFile(),
									context.getMatcher().start(groupIndex) + context.getStartIndex(),
									context.getStage(),
									context,
									subInterceptor);
							context.setInParameter(inParam);
							context.setInBlock(inBlock);
							blockContent = Strings.nullToEmpty(subInterceptor.getResult());
						} else {
							blockContent = null;
						}
						specialTagFound = true;
						try {
							context.getParserInterceptor().tag(context, tag, tagDynamicName, parameterValue, blockContent);
						} catch (Throwable exception) {
							reportError(context, Messages.SarlDocumentationParser_6, tagName, exception);
							return false;
						}
					} else {
						// Ignore the tag for this stage.
					}
				} else {
					reportError(context, Messages.SarlDocumentationParser_1, tagName);
					return false;
				}
			}
			context.getParserInterceptor().closeContext(context);
			return specialTagFound;
		} catch (ParsingException exception) {
			throw exception;
		} catch (Throwable exception) {
			final Throwable rootException = Throwables.getRootCause(exception);
			throw new ParsingException(
					rootException.getClass().getName() + " - " + rootException.getLocalizedMessage(), //$NON-NLS-1$
					context.getCurrentFile(),
					context.getLineNo(),
					rootException);
		}
	}
594960
def parse_line(self, line):
        """"""
        # The parser may only need to run until it has seen a specific line.
        # Once that's occurred, it can mark itself as complete, to save
        # being run against later log lines.
        if self.parser.complete:
            return

        # Perf data is stored in a json structure contained in a single line,
        # if the MAX_LINE_LENGTH is applied the data structure could be
        # truncated, preventing it from being ingested.
        if 'PERFHERDER_DATA' not in line:
            line = line[:self.MAX_LINE_LENGTH]

        self.parser.parse_line(line, self.lineno)
        self.lineno += 1
1132754
protected boolean lookahead() {
        try {
            next = this.reader.readLine();
            if(next == null) {
                // TODO: make this close-on-exhaust optional?
                reader.close();
            }
            return (next!=null);
        } catch (IOException e) {
            logger.warning(e.toString());
            return false;
        }
    }
1224036
@Override
    public boolean isNewLine(byte[]bytes, int p, int end) {
        return p < end ? bytes[p] == Encoding.NEW_LINE : false;
    }
371108
private void parseLine__singleLineMode(String line) throws SyntaxErrorException
	{
		// reset
		setPropertyNameStart(POSITION__NOT_SET);
		setPropertyNameEnd(POSITION__NOT_SET);
		setRestOfLineStart(POSITION__NOT_SET);

		int _nextStateIndex = 0;
		State _currentState = null;
		char[] _nextChar = new char[1];

		for (int _i = 0; _i <= line.length(); _i++)
		{
			setCurrentChar(_i);
			_currentState = getAutomaton()[_nextStateIndex];
			_currentState.execute();
			if (line.length() == _i || !_currentState.isFollowable()) break;
			_nextChar[0] = line.charAt(_i);
			String _charToParse = new String(_nextChar);
			try
			{
				_nextStateIndex = _currentState.chooseNext(_charToParse);
			}
			catch (SyntaxErrorException _exception)
			{
				throw new SyntaxErrorException("Error at pos " + _i + " in line :'" + line + "'");
			}
		}
		// sanity check : final state and not error
		if (null == _currentState || !_currentState.isFinal())
		{
			throw new SyntaxErrorException("Undefined error at pos in line :'" + line + "'");
		}

		// do the thing.
		if (null != getParserOutcome())
		{
			if (isParserOutcomeSingleLine())
			{
				boolean _leftTrim = (FinalState.IS_SINGLE_LINE_LEFT_TRIM == getParserOutcome());
				parseLine__extractSingleLineProperty(line, _leftTrim);
			}
			else if (isParserOutcomeMultipleLine())
			{
				String _propertyName = line.substring(getPropertyNameStart(), getPropertyNameEnd());
				setMultipleLinePropertyName(_propertyName);
				setMultipleLinePropertyValue(new ArrayList<String>());
				String _endTag = line.substring(getRestOfLineStart()).trim();
				if (!getEndTagChecker().matcher(_endTag).matches())
				{
					throw new SyntaxErrorException(
							"End tag MUST match the rule : '" + CharacterPattern.END_TAG + "', got '" + _endTag + "'");
				}
				setMultipleLineEndTag(_endTag);
			}
		}
	}
763952
public boolean readInstance(Reader fileReader) {

        //ArffReader arff = new ArffReader(reader, this, m_Lines, 1);
        Instance inst = arff.readInstance();
        if (inst != null) {
            inst.setDataset(this);
            add(inst);
            return true;
        } else {
            return false;
        }
    }
1362342
@Override
  public boolean tokenizeLine(String line, BufferedReader reader, Record record) throws IOException {
    int numChars = line.length();
    final char DELIMITER = separatorChar;
    final char QUOTE = quoteChar;
    final StringBuilder sb = new StringBuilder(30);
    boolean isQuoted = false;
    int i = 0;
    int j = 0;
    
    while (true) {
      
      if (!isQuoted) {
        if (i == line.length()) {
          break; // we're done
        }
        final char c = line.charAt(i);
        if (c == DELIMITER) {
          put(sb, j, record);
          j++;
          sb.setLength(0);
        } else if (c == QUOTE) {
          if (sb.length() == 0) {
            isQuoted = true;
          } else if (i + 1 < line.length() && line.charAt(i + 1) == QUOTE) {
            sb.append(c);
            i++;
          } else {
            isQuoted = true;
          }
        } else {
          sb.append(c);
        }
          
      } else {
        assert isQuoted;
        if (i == line.length()) {
          sb.append('\n');
          i = -1;
          line = reader.readLine();
          if (line == null) {
            throw new IllegalStateException("unexpected end of file, unclosed quotation");
          }
          numChars += line.length();
          if (!verifyRecordLength(
              numChars, maxCharactersPerRecord, sb, line, ignoreTooLongRecords, LOG)) {
            return false; // attempt to ignore it
          }
        } else {
          final char c = line.charAt(i);
          if (c == QUOTE) {
            if (i + 1 < line.length() && line.charAt(i + 1) == QUOTE) {
              sb.append(c); // found two quotes -> insert single quote
              i++;
            } else {
              isQuoted = false;
            }
          } else {
            sb.append(c);
          }
        }
      }

      i++;
    }
    
    if (!(j == 0 && sb.length() == 0)) {
      put(sb, j, record);
    }
    
    return true;
  }
842523
public List<String> parse(String line) throws ParseException {
    List<String> cols = new ArrayList<>();
    boolean afterQuote = false;
    boolean afterEscape = false;
    boolean afterSeparator = false;
    boolean outerQuote = false;
    boolean afterEndField = false;
    StringBuilder sb = new StringBuilder();

    for (int i = 0; ; ++i) {
      char c = (i == line.length()) ? EOT : line.charAt(i);
      if (afterEndField && c != separator && c != EOT) {
        if (!trim || c != ' ') {
          throw new ParseException("Extraneous character after end of quoted field", i);
        }
      } else if (afterEscape) {
        if (c == EOT) {
          // [abc\^]
          throw new ParseException("Escape not followed by a character", i);
        } else {
          // [abc\x...] => abcx...
          afterEscape = false;
          sb.append(c);
        }
      } else if (c == separator) {
        if (outerQuote && !afterQuote) {
          // ["abc,...] => abc,...
          sb.append(c);
          afterSeparator = false;
        } else {
          // [abc,...] => {abc, ...}
          endCol(cols, sb, i, outerQuote, afterQuote);
          afterQuote = afterEscape = afterEndField = outerQuote = false;
          afterSeparator = true;
        }
      } else if (c == EOT) {
        if (sb.length() != 0 || afterSeparator || outerQuote) {
          // [...,abc^] => {..., abc}
          // [...,^] => {..., ""}
          endCol(cols, sb, i, outerQuote, afterQuote);
        }
        return cols;
      } else if (c == escape) {
        // [...\...]
        afterEscape = true;
        afterSeparator = false;
      } else if (c == quote) {
        if (afterQuote && outerQuote) {
          // Two consecutive quotes inside quoted string, so the pair has to be internal
          // (the second quote cannot be terminating the field).
          sb.append(quote);
          afterQuote = false;
        } else if (sb.length() == 0 && !outerQuote) {
          outerQuote = true;
        } else if (sb.length() != 0 && !outerQuote) {
          // Fields that are not quote-delimited cannot have any internal quotes,
          // unless they are escaped which was already handled.
          throw new ParseException(escape == NUL
              ? "Unescaped quote inside non-quote-delimited field"
              : "Quote inside non-quote-delimited field",
              i);
        } else {
          afterQuote = true;
        }
        afterSeparator = false;
      } else if (c == ' ' && trim
          && ((!outerQuote && sb.length() == 0) // Trimmed space before field
              || afterEndField)) {              // Trimmed space after field
      } else if (c == ' ' && trim && afterQuote) {
        afterEndField = true;
      } else if (outerQuote && afterQuote) {
        // ["abc"x]
        throw new ParseException("Extraneous character after end of quoted field", i);
      } else {
        // Common character.
        sb.append(c);
        afterSeparator = false;
      }
    }
  }
159453
private boolean isCompleteLine(String[] line)
    {
        // If the last string starts with a quote, but doesnt't end with one
        //   then it must be a linefeed in the middle of a data field
        String lastStr = line[line.length-1];
        boolean isPartial = lastStr != null 
            && (lastStr.equals("\"") || line.length == 1
                || (lastStr.startsWith("\"") && !lastStr.endsWith("\"")));
        return !isPartial;
    }
975084
public static String[] parse(final String line) {
        boolean insideQuote = false;
        final ArrayList<String> result = new ArrayList<>();
        int quoteCount = 0;
        final StringBuilder sb = new StringBuilder();
        for (int i = 0; i < line.length(); i++) {
            final char c = line.charAt(i);

            if (c == QUOTE) {
                insideQuote = !insideQuote;
                quoteCount++;
            }

            if (c == COMMA && !insideQuote) {
                String value = sb.toString();
                value = unQuoteUnEscape(value);
                result.add(value);
                sb.setLength(0);
                continue;
            }

            sb.append(c);
        }

        result.add(sb.toString());

        // Validate
        if (quoteCount % 2 != 0) {
            return new String[0];
        }

        return result.toArray(new String[result.size()]);
    }
224711
private Block readLines() throws IOException
    {
        final Block block = new Block();
        final StringBuilder sb = new StringBuilder(80);
        int c = this.reader.read();
        LinkRef lastLinkRef = null;
        while (c != -1)
        {
            sb.setLength(0);
            int pos = 0;
            boolean eol = false;
            while (!eol)
            {
                switch (c)
                {
                case -1:
                    eol = true;
                    break;
                case '\n':
                    c = this.reader.read();
                    if (c == '\r')
                    {
                        c = this.reader.read();
                    }
                    eol = true;
                    break;
                case '\r':
                    c = this.reader.read();
                    if (c == '\n')
                    {
                        c = this.reader.read();
                    }
                    eol = true;
                    break;
                case '\t':
                {
                    final int np = pos + (4 - (pos & 3));
                    while (pos < np)
                    {
                        sb.append(' ');
                        pos++;
                    }
                    c = this.reader.read();
                    break;
                }
                default:
                    if (c != '<' || !this.config.panicMode)
                    {
                        pos++;
                        sb.append((char)c);
                    }
                    else
                    {
                        pos += 4;
                        sb.append("&lt;");
                    }
                    c = this.reader.read();
                    break;
                }
            }

            final Line line = new Line();
            line.value = sb.toString();
            line.init();

            // Check for link definitions
            boolean isLinkRef = false;
            String id = null, link = null, comment = null;
            if (!line.isEmpty && line.leading < 4 && line.value.charAt(line.leading) == '[')
            {
                line.pos = line.leading + 1;
                // Read ID up to ']'
                id = line.readUntil(']');
                // Is ID valid and are there any more characters?
                if (id != null && line.pos + 2 < line.value.length())
                {
                    // Check for ':' ([...]:...)
                    if (line.value.charAt(line.pos + 1) == ':')
                    {
                        line.pos += 2;
                        line.skipSpaces();
                        // Check for link syntax
                        if (line.value.charAt(line.pos) == '<')
                        {
                            line.pos++;
                            link = line.readUntil('>');
                            line.pos++;
                        }
                        else
                        {
                            link = line.readUntil(' ', '\n');
                        }

                        // Is link valid?
                        if (link != null)
                        {
                            // Any non-whitespace characters following?
                            if (line.skipSpaces())
                            {
                                final char ch = line.value.charAt(line.pos);
                                // Read comment
                                if (ch == '\"' || ch == '\'' || ch == '(')
                                {
                                    line.pos++;
                                    comment = line.readUntil(ch == '(' ? ')' : ch);
                                    // Valid linkRef only if comment is valid
                                    if (comment != null)
                                    {
                                        isLinkRef = true;
                                    }
                                }
                            }
                            else
                            {
                                isLinkRef = true;
                            }
                        }
                    }
                }
            }

            // To make compiler happy: add != null checks
            if (isLinkRef && id != null && link != null)
            {
                if (id.toLowerCase().equals("$profile$"))
                {
                    this.emitter.useExtensions = this.useExtensions = link.toLowerCase().equals("extended");
                    lastLinkRef = null;
                }
                else
                {
                    // Store linkRef and skip line
                    final LinkRef lr = new LinkRef(link, comment, comment != null
                            && (link.length() == 1 && link.charAt(0) == '*'));
                    this.emitter.addLinkRef(id, lr);
                    if (comment == null)
                    {
                        lastLinkRef = lr;
                    }
                }
            }
            else
            {
                comment = null;
                // Check for multi-line linkRef
                if (!line.isEmpty && lastLinkRef != null)
                {
                    line.pos = line.leading;
                    final char ch = line.value.charAt(line.pos);
                    if (ch == '\"' || ch == '\'' || ch == '(')
                    {
                        line.pos++;
                        comment = line.readUntil(ch == '(' ? ')' : ch);
                    }
                    if (comment != null)
                    {
                        lastLinkRef.title = comment;
                    }

                    lastLinkRef = null;
                }

                // No multi-line linkRef, store line
                if (comment == null)
                {
                    line.pos = 0;
                    block.appendLine(line);
                }
            }
        }

        return block;
    }
103372
protected boolean parseGlobalOptionsLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException {
        // Read in the variables from the line
        final HashMap<ParserType, String[]> variableMap = getLineVariables(parserData, line, lineNumber, '[', ']', ',', false);

        // Check the read in values are valid
        if ((variableMap.size() > 1 && variableMap.containsKey(ParserType.NONE)) || (variableMap.size() > 0 && !variableMap.containsKey(
                ParserType.NONE))) {
            throw new ParsingException(format(ProcessorConstants.ERROR_RELATIONSHIP_BASE_LEVEL_MSG, lineNumber, line));
        }
        String[] variables = variableMap.get(ParserType.NONE);

        // Check that some options were found, if so then parse them
        if (variables.length > 0) {
            addOptions(parserData, parserData.getCurrentLevel(), variables, 0, line, lineNumber);
        } else {
            log.warn(format(ProcessorConstants.WARN_EMPTY_BRACKETS_MSG, lineNumber));
        }

        return true;
    }