Parse a single line.

@return {@code true} if the line was read successful.
354714
private boolean parseLine() {
    cureid = null;
    curpoly = null;
    curlbl = null;
    polys.clear();
    coords.clear();
    labels.clear();

    Matcher m = COORD.matcher(reader.getBuffer());
    for(/* initialized by nextLineExceptComments */; tokenizer.valid(); tokenizer.advance()) {
      m.region(tokenizer.getStart(), tokenizer.getEnd());
      if(m.find()) {
        try {
          double c1 = ParseUtil.parseDouble(m.group(1));
          double c2 = ParseUtil.parseDouble(m.group(2));
          if(m.group(3) != null) {
            double c3 = ParseUtil.parseDouble(m.group(3));
            coords.add(new double[] { c1, c2, c3 });
          }
          else {
            coords.add(new double[] { c1, c2 });
          }
          continue;
        }
        catch(NumberFormatException e) {
          LOG.warning("Looked like a coordinate pair but didn't parse: " + tokenizer.getSubstring());
        }
      }
      // Match polygon separator:
      // FIXME: Avoid unnecessary subSequence call.
      final int len = tokenizer.getEnd() - tokenizer.getStart();
      if(POLYGON_SEPARATOR.length() == len && //
          reader.getBuffer().subSequence(tokenizer.getStart(), tokenizer.getEnd()).equals(POLYGON_SEPARATOR)) {
        if(!coords.isEmpty()) {
          polys.add(new Polygon(new ArrayList<>(coords)));
        }
        continue;
      }
      String cur = tokenizer.getSubstring();
      // First label will become the External ID
      if(cureid == null) {
        cureid = new ExternalID(cur);
      }
      else {
        labels.add(cur);
      }
    }
    // Complete polygon
    if(!coords.isEmpty()) {
      polys.add(new Polygon(coords));
    }
    curpoly = new PolygonsObject(polys);
    curlbl = (haslabels || !labels.isEmpty()) ? LabelList.make(labels) : null;
    return true;
  }
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;
        }
    }
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;
    }
65416
private String parseLevelOfTheory(String line) {
        StringBuffer summary = new StringBuffer();
        summary.append(line);
        try {

            do {
                line = input.readLine().trim();
                summary.append(line);
            } while (!(line.indexOf('@') >= 0));
        } catch (Exception exc) {
            logger.debug("syntax problem while parsing summary of g98 section: ");
            logger.debug(exc);
        }
        logger.debug("parseLoT(): " + summary.toString());
        StringTokenizer st1 = new StringTokenizer(summary.toString(), "\\");

        // Must contain at least 6 tokens
        if (st1.countTokens() < 6) {
            return null;
        }

        // Skip first four tokens
        for (int i = 0; i < 4; ++i) {
            st1.nextToken();
        }

        return st1.nextToken() + "/" + st1.nextToken();
    }
1220033
def parse_line(line, &warning_handler)
      line_definitions.each do |_lt, definition|
        match = definition.matches(line, &warning_handler)
        return match if match
      end

      nil
    end
1362271
public String readLine() throws IOException {
        StringBuilder str = new StringBuilder();
        while (true) {
            int c = read();
            if (c < 0) {
                break;
            }
            if (c == '\n') {
                // if possible consume another '\r'
                int peek = stream.read();
                if (peek != '\r' && peek >= 0){
                    stream.unread(peek);
                }
                break;
            }
            if (c == '\r') {
                // if possible consume another '\n'
                int peek = stream.read();
                if (peek != '\n' && peek >= 0){
                    stream.unread(peek);
                }
                break;
            }
            str.append((char) c);
        }
        return str.toString();
    }
659041
public String readLine() throws IOException
  {
    CharBuffer cb = _cb;

    if (cb == null) {
      cb = _cb = new CharBuffer();
    }
    else {
      cb.length(0);
    }

    String result;

    if (readLine(cb, true)) {
      result = cb.toString();
      cb.length(0);
    }
    else if (cb.length() == 0)
      result = null;
    else {
      result = cb.toString();
      cb.length(0);
    }

    return result;
  }
418054
def parse(self, line, **options):
        
        line = line.strip()
        if not line:
            return (False, (), {})
        split = line.split()
        cmd, args = split[0], split[1:]
        return (cmd, args, {})
77265
def _parse_line(sep, line):
    
    strs = line.split(sep, 1)
    return (strs[0].strip(), None) if len(strs) == 1 else (strs[0].strip(), strs[1].strip())
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;
        }
    }
407156
@Override
    public int read() throws IOException {
        if (newLineWasRead) {
            line += 1;
            column = 1;
            newLineWasRead = false;
        }

        int charRead = super.read();
        if (charRead > -1) {
            char c = (char)charRead;
            // found a \r or \n, like on Mac or Unix
            // could also be Windows' \r\n
            if (c == '\r' || c == '\n') {
                newLineWasRead = true;
                if (c == '\r') {
                    mark(1);
                    c = (char)super.read();
                    // check if we have \r\n like on Windows
                    // if it's not \r\n we reset, otherwise, the \n is just consummed
                    if (c != '\n') {
                        reset();
                    }
                }
            } else {
                column += 1;
            }
        }

        return charRead;
    }
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;
  }
335397
protected boolean parseEmptyOrCommentLine(final ParserData parserData, final String line) {
        if (isBlankLine(line)) {
            if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) {
                parserData.getContentSpec().appendChild(new TextNode("\n"));
            } else {
                parserData.getCurrentLevel().appendChild(new TextNode("\n"));
            }
            return true;
        } else {
            if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) {
                parserData.getContentSpec().appendComment(line);
            } else {
                parserData.getCurrentLevel().appendComment(line);
            }
            return true;
        }
    }
747998
boolean readBoolean() throws IOException {
		char ch = reader.next();
		String expected = null;
		if (ch == 't') {
			expected = "rue"; // true
		} else if (ch == 'f') {
			expected = "alse"; // false
		} else {
			throw new JsonParseException("Unexpected char: " + ch, reader.readed);
		}
		for (int i = 0; i < expected.length(); i++) {
			char theChar = reader.next();
			if (theChar != expected.charAt(i)) {
				throw new JsonParseException("Unexpected char: " + theChar,
						reader.readed);
			}
		}
		return ch == 't';
	}
227505
public static int readLine(InputStream in,
                               OutputStream out) throws IOException {

        int count = 0;

        for (;;) {
            int b = in.read();

            if (b == -1) {
                break;
            }

            count++;

            out.write(b);

            if (b == '\n') {
                break;
            }
        }

        return count;
    }
796485
private static String readLine(InputStream is) throws IOException {
        StringBuilder builder = new StringBuilder();
        while (true) {
            int ch = is.read();
            if (ch == '\r') {
                ch = is.read();
                if (ch == '\n') {
                    break;
                } else {
                    throw new IOException("unexpected char after \\r: " + ch);
                }
            } else if (ch == -1) {
                if (builder.length() > 0) {
                    throw new IOException("unexpected end of stream");
                }
                break;
            }
            builder.append((char) ch);
        }
        return builder.toString();
    }
1304797
public boolean readLine(Appendable buf) throws IOException {
    boolean success = false;
    while(true) {
      // Process buffer:
      while(pos < end) {
        success = true;
        final char c = buffer[pos++];
        if(c == '\n') {
          return success;
        }
        if(c == '\r') {
          continue;
        }
        buf.append(c);
      }
      // Refill buffer:
      assert (pos >= end) : "Buffer wasn't empty when refilling!";
      end = in.read(buffer, 0, buffer.length);
      pos = 0;
      if(end < 0) { // End of stream.
        return success;
      }
    }
  }