/*
(non-Javadoc)

@see sfdc.adt.IParser#parse(java.lang.String, java.io.Reader)
1187
@Override
    public ParseResult parse(final Source source) {
        return Util.execute(new ExceptionAction<ParseResult>() {
            @Override
            public ParseResult doAction() throws Throwable {
                logger.fine("Parsing " + source.getSrcInfo());
                final BufferedReader reader = source.createReader();
                try {
                    final ParserImpl impl = factory.create(source.getSrcInfo(),
                            reader);
                    final Doc doc = impl.doc();
                    return new ParseResult(doc, impl.errors());
                } finally {
                    reader.close();
                }
            }
        });
    }
102312
private void parse(Reader reader) throws IOException {
		StringBuilder text = new StringBuilder();
		int character;
		while ((character = reader.read()) != -1) {
			boolean introducedControlSequence = false;
			if (character == SINGLE_CSI) {
				introducedControlSequence = true;
			} else if (character == MULTI_CSI[0]) {
				int nextCharacter = reader.read();
				if (nextCharacter == -1) {
					buffer.append((char) character);
					break;
				} else if (nextCharacter == MULTI_CSI[1]) {
					introducedControlSequence = true;
				} else {
					text.append((char) character);
					text.append((char) nextCharacter);
				}
			} else {
				text.append((char) character);
			}

			if (introducedControlSequence) {
				if (text.length() > 0) {
					listener.parsedString(text.toString());
					text = new StringBuilder();
				}
				parseControlSequence(reader);
			}
		}

		if (text.length() > 0) {
			listener.parsedString(text.toString());
		}
	}
157027
public Collection parse(InputStream stream) throws IOException {
        return parse(new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8)));
    }
292988
public static Parse parseParse(String parse) {
    StringBuffer text = new StringBuffer();
    int offset = 0;
    Stack stack = new Stack();
    List cons = new LinkedList();
    for (int ci = 0, cl = parse.length(); ci < cl; ci++) {
      char c = parse.charAt(ci);
      if (c == '(') {
        String rest = parse.substring(ci + 1);
        String type = getType(rest);
        if (type == null) {
          System.err.println("null type for: " + rest);
        }
        String token = getToken(rest);
        stack.push(new Object[] { type, new Integer(offset)});
        if (token != null && !type.equals("-NONE-")) {
          cons.add(new Object[] { ParserME.TOK_NODE, new Span(offset, offset + token.length())});
          text.append(token).append(" ");
          offset += token.length() + 1;
        }
      }
      else if (c == ')') {
        Object[] parts = (Object[]) stack.pop();
        String type = (String) parts[0];
        if (!type.equals("-NONE-")) {
          int start = ((Integer) parts[1]).intValue();
          cons.add(new Object[] { parts[0], new Span(start, offset - 1)});
        }
      }
    }
    String txt = text.toString();
    Parse p = new Parse(txt, new Span(0, txt.length()), ParserME.TOP_NODE, 1);
    /*
    for (int ti=0;ti < tokens.size();ti++) {
      Object[] parts = (Object[]) cons.get(ti);
      String type = (String) parts[0];
      if (!type.equals(ParserME.TOP_NODE)) {
        Parse con = new Parse(txt, (Span) parts[1], type, 1);
        System.err.println("insert "+type+" "+con.toString());
        p.insert(con);
      }
    }
    */
    for (int ci=0;ci < cons.size();ci++) {
      Object[] parts = (Object[]) cons.get(ci);
      String type = (String) parts[0];
      if (!type.equals(ParserME.TOP_NODE)) {
        Parse con = new Parse(txt, (Span) parts[1], type, 1);
        //System.err.println("insert["+ci+"] "+type+" "+con.toString()+" "+con.hashCode());
        p.insert(con);
        //codeTree(p);
      }
    }
    return p;
  }
309444
public void read(ByteCodeParser in)
    throws IOException
  {
    int length = in.readInt();
    
    int exnCount = in.readShort();

    for (int i = 0; i < exnCount; i++) {
      int index = in.readShort();

      if (index == 0) {
        _methods.add(null);
      }
      
      // _methods.add(in.getConstantPool().getClass(index).getName());
    }
  }
744822
void parse(Reader reader) throws ParseException {
        if (reader == null) {
            //just log and return default properties
            Log.warn("parsing NULL reader, so fallback on default configuration!");
            return;
        }
        
        BufferedReader br = new BufferedReader(reader);
        String line;
        try {
            while ((line = br.readLine()) != null) {
                int commentMarker = line.indexOf('#');
                if (commentMarker != -1) {
                    if (commentMarker == 0) {
                        //skip its a comment
                        continue;
                    } else {
                        //it's a malformed comment
                        throw new ParseException(line, commentMarker);
                    }
                } else {
                    if (line.isEmpty() || line.matches("^\\s*$")) {
                        //skip it's a black line
                        continue;
                    }
                    
                    //split till the first space
                    int deilimiterIdx = line.indexOf(' ');
                    String key = line.substring(0, deilimiterIdx).trim();
                    String value = line.substring(deilimiterIdx).trim();
                    
                    m_properties.put(key, value);
                }
            }
        } catch (IOException ex) {
            throw new ParseException("Failed to read", 1);
        }
    }
1105956
@SuppressWarnings("resource")
	@Override
	public Object parse(String source) throws Exception {
		return new CSVReader(new StringReader(source), defaultSeparatorChar, defaultQuoteChar, defaultEscapeChar,
				defaultSkipLines, defaultStrictQuotes, defaultIgnoreLeadingWhiteSpace).readAll();
	}
1132325
public void parse(String str) {
		if (buffer.length() > 0) {
			str = buffer.toString().concat(str);
			buffer = new StringBuilder();
		}
		Reader reader = new StringReader(str);
		try {
			try {
				parse(reader);
			} finally {
				reader.close();
			}
		} catch (IOException ex) {
			/* ignore */
		}
	}
657913
public void parseXml(Reader reader) throws IOException, XmlPullParserException {
    this.xmlPullParser.setInput(reader);
    Xml.parseElement(this.xmlPullParser, this, this.defaultNamespaceDictionary, null);
  }
64896
public void parseFile(File file) throws ParserException, IOException {

        Reader reader = null;

        try {
            reader = new FileReader(file);
            nanoElement.parseFromReader(reader);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        } finally {
            if (reader != null) reader.close();
        }
    }
1338504
public void parse (String string) {
		char[] data = string.toCharArray();
		parse(data, 0, data.length);
	}
554378
@Override
    protected void parse() throws ProtocolException {
        cursor = offset;
        optimalEncodingMessageSize = 4;

        // version
        version = readUint32();
        // peek at marker
        byte marker = payload[cursor];
        boolean useSegwit = marker == 0;
        // marker, flag
        if (useSegwit) {
            readBytes(2);
            optimalEncodingMessageSize += 2;
        }
        // txin_count, txins
        parseInputs();
        // txout_count, txouts
        parseOutputs();
        // script_witnesses
        if (useSegwit)
            parseWitnesses();
        // lock_time
        lockTime = readUint32();
        optimalEncodingMessageSize += 4;

        length = cursor - offset;
    }
1287066
public Object parse(InputSource is) throws ParserConfigurationException, SAXException, IOException{
        SAXUtil.newSAXParser(true, false, false).parse(is, this);
        return reset();
    }
1245826
@Nonnull
  public static ESuccess parseJson (@Nonnull @WillClose final Reader aReader,
                                    @Nonnull final IJsonParserHandler aParserHandler)
  {
    return parseJson (aReader, aParserHandler, (IJsonParserCustomizeCallback) null, (IJsonParseExceptionCallback) null);
  }
179777
public T parse(Reader reader) throws IOException {
    T bean = createBean();
    populate(bean, reader);
    return bean;
  }
627970
public void read(ByteCodeParser in)
    throws IOException
  {
    int length = in.readInt();
    
    int exnCount = in.readShort();

    for (int i = 0; i < exnCount; i++) {
      int index = in.readShort();

      if (index == 0)
        _exceptions.add(null);
      
      _exceptions.add(in.getConstantPool().getClass(index).getName());
    }
  }
266644
public static ProtoFile parse(String name, Reader reader) throws IOException {
    CharArrayWriter writer = new CharArrayWriter();
    char[] buffer = new char[1024];
    int count;
    while ((count = reader.read(buffer)) != -1) {
      writer.write(buffer, 0, count);
    }
    return new ProtoParser(name, writer.toCharArray()).readProtoFile();
  }