Parses a COBOL source into an in-memory model.

@param cobolReader reads the raw COBOL source
@return a list of root COBOL data items
@throws RecognizerException if COBOL recognition fails
422142
public List < CobolDataItem > toModel(final Reader cobolReader)
            throws RecognizerException {
        return emitModel(parse(lex(clean(cobolReader))));
    }
353486
@Override
    <T> T read(Class<T> rootType) {
        try {
            try {
                return parseRemaining(rootType);
            } finally {
                input.close();
            }
        } catch (RuntimeException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
793508
public Map<String, String> extractAbbrPairs(String inFile) {
        FileReader fr;
        try {
            fr = new FileReader(inFile);
            return extractAbbrPairs(fr);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return new HashMap<String, String>();
        }
    }
955821
protected void processReader(IModule module, ModuleBuildReader reader) throws IOException {
		// Add the cache key generator list to the result list
		List<ICacheKeyGenerator> keyGenList = reader.getCacheKeyGenerators();
		if (keyGenList != null) {
			keyGens.addAll(keyGenList);
		}
		if (smGen != null) {
			// If we're generating a source map, then merge the source map for the module
			// into the layer source map.
			SourceMap moduleSourceMap = reader.getSourceMap();
			if (moduleSourceMap != null && writer instanceof LineCountingStringWriter) {
				sectionCount++;
				LineCountingStringWriter lcWriter = (LineCountingStringWriter)writer;
				try {
					smGen.mergeMapSection(lcWriter.getLine(), lcWriter.getColumn(), moduleSourceMap.map);
				} catch (SourceMapParseException e) {
					throw new IOException(e);
				}
				// Save the sources content, indexed by the module name, so that we can
				// add the 'sourcesContent' property to the layer map after the map
				// has been generated.  We need to do this because SourceMapGeneratorV3
				// does not merge the sourcesContent properties from module source maps into
				// the merged layer source map.
				sourcesMap.put(moduleSourceMap.name, moduleSourceMap.source);
			}
		}
		// Add the reader contents to the result
		try {
			IOUtils.copy(reader, writer);
		} finally {
			IOUtils.closeQuietly(reader);
		}
		if (reader.isError()) {
			errorMessages.add(reader.getErrorMessage());
		}
	}
928280
public static NaryTreebank readTreesInPtbFormat(Reader reader) throws IOException {
        NaryTreebank trees = new NaryTreebank();
        while (true) {
            NaryTree tree = NaryTree.readTreeInPtbFormat(reader);
            if (tree != null) {
                tree.intern();
                trees.add(tree);
            }
            if (tree == null) {
                break;
            }
        }
        return trees;
    }
1224992
public void parse(Reader xmlReader) throws XMLStreamException {
    if (isoControlCharsAwareParser) {
      throw new XMLStreamException("Method call not supported when isoControlCharsAwareParser=true");
    }
    parse(inf.rootElementCursor(xmlReader));
  }
84338
private Map<String, String> extractAbbrPairs(Reader r) {
        Map<String, String> candidates = new HashMap<String, String>();
        String str, tmpStr, longForm = "", shortForm = "";
        String currSentence = "";
        int openParenIndex, closeParenIndex = -1, sentenceEnd, newCloseParenIndex, tmpIndex = -1;
        boolean newParagraph = true;
        StringTokenizer shortTokenizer;

        try {

            BufferedReader fin = new BufferedReader(r);
            while ((str = fin.readLine()) != null) {
                if (str.length() == 0 || newParagraph && !Character.isUpperCase(str.charAt(0))) {
                    currSentence = "";
                    newParagraph = true;
                    continue;
                }
                newParagraph = false;
                str += " ";
                currSentence += str;
                openParenIndex = currSentence.indexOf(" (");
                do {
                    if (openParenIndex > -1) {
                        openParenIndex++;
                    }
                    sentenceEnd = Math.max(currSentence.lastIndexOf(". "), currSentence.lastIndexOf(", "));
                    if ((openParenIndex == -1) && (sentenceEnd == -1)) {
                        // Do nothing
                    } else if (openParenIndex == -1) {
                        currSentence = currSentence.substring(sentenceEnd + 2);
                    } else if ((closeParenIndex = currSentence.indexOf(')', openParenIndex)) > -1) {
                        sentenceEnd = Math.max(currSentence.lastIndexOf(". ", openParenIndex), currSentence.lastIndexOf(", ",
                                openParenIndex));
                        if (sentenceEnd == -1) {
                            sentenceEnd = -2;
                        }
                        longForm = currSentence.substring(sentenceEnd + 2, openParenIndex);
                        shortForm = currSentence.substring(openParenIndex + 1, closeParenIndex);
                    }
                    if (shortForm.length() > 0 || longForm.length() > 0) {
                        if (shortForm.length() > 1 && longForm.length() > 1) {
                            if ((shortForm.indexOf('(') > -1)
                                    && ((newCloseParenIndex = currSentence.indexOf(')', closeParenIndex + 1)) > -1)) {
                                shortForm = currSentence.substring(openParenIndex + 1, newCloseParenIndex);
                                closeParenIndex = newCloseParenIndex;
                            }
                            if ((tmpIndex = shortForm.indexOf(", ")) > -1) {
                                shortForm = shortForm.substring(0, tmpIndex);
                            }
                            if ((tmpIndex = shortForm.indexOf("; ")) > -1) {
                                shortForm = shortForm.substring(0, tmpIndex);
                            }
                            shortTokenizer = new StringTokenizer(shortForm);
                            if (shortTokenizer.countTokens() > 2 || shortForm.length() > longForm.length()) {
                                // Long form in ( )
                                tmpIndex = currSentence.lastIndexOf(" ", openParenIndex - 2);
                                tmpStr = currSentence.substring(tmpIndex + 1, openParenIndex - 1);
                                longForm = shortForm;
                                shortForm = tmpStr;
                                if (!hasCapital(shortForm)) {
                                    shortForm = "";
                                }
                            }
                            if (isValidShortForm(shortForm)) {
                                List<String> list = extractAbbrPair(shortForm.trim(), longForm.trim());
                                if (list.size() == 2) {
                                    candidates.put(list.get(0), list.get(1));
                                }
                            }
                        }
                        currSentence = currSentence.substring(closeParenIndex + 1);
                    } else if (openParenIndex > -1) {
                        if ((currSentence.length() - openParenIndex) > 200) {
                            // Matching close paren was not found
                            currSentence = currSentence.substring(openParenIndex + 1);
                        }
                        break; // Read next line
                    }
                    shortForm = "";
                    longForm = "";
                } while ((openParenIndex = currSentence.indexOf(" (")) > -1);
            }
            fin.close();
        } catch (Exception ioe) {
            ioe.printStackTrace();
            System.out.println(currSentence);
            System.out.println(tmpIndex);
        }
        return candidates;
    }
1332353
def parse_from_string(
        root_processor,  # type: RootProcessor
        xml_string  # type: Text
):
    # type: (...) -> Any
    
    if not _is_valid_root_processor(root_processor):
        raise InvalidRootProcessor('Invalid root processor')

    parseable_xml_string = xml_string  # type: Union[Text, bytes]
    if _PY2 and isinstance(xml_string, Text):
        parseable_xml_string = xml_string.encode('utf-8')

    root = ET.fromstring(parseable_xml_string)
    _xml_namespace_strip(root)

    state = _ProcessorState()
    state.push_location(root_processor.element_path)
    return root_processor.parse_at_root(root, state)
593970
public void parseReader(Reader reader) throws ParserException, IOException {

        try {
            nanoElement.parseFromReader(reader);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        }
    }
1050145
public Object parse(Reader reader) {
        if (reader == null) {
            throw new IllegalArgumentException("Reader must not be null");
        }

        Object content;
        JsonParser parser = createParser();
        content = parser.parse(reader);
        return content;
    }
343879
@SuppressWarnings("unchecked")
    public static List<TopLevelGdl> parse(Reader input) throws Exception {
        try {
            Scanner lexer = new GdlScanner(input);
            SymbolFactory symbolFactory = new ComplexSymbolFactory();
            Symbol result = new GdlParser(lexer, symbolFactory).parse();
            return (List<TopLevelGdl>) result.value;
        } finally {
            input.close();
        }
    }
355569
private static void parse(final Reader r) throws IOException {
		final BufferedReader br = new BufferedReader(r);
		String line;
		final ArrayList<String> sequence = new ArrayList<String>();

		line = br.readLine();
		while (true) {
			if (line == null) {
				break;
			}
			line = line.trim();
			if (line.length() == 0 || line.charAt(0) == '#') {
				line = br.readLine();
				continue;
			}
			sequence.add(line);

			// read the following lines until a line does not begin with '>' or
			// EOF
			while (true) {
				line = br.readLine();
				if (line == null) {
					addEntry(sequence);
					sequence.clear();
					break;
				}
				line = line.trim();
				if (line.length() == 0 || line.charAt(0) == '#') {
					continue;
				}
				if (line.charAt(0) != '>') {
					addEntry(sequence);
					sequence.clear();
					break;
				}
				sequence.add(line);
			}
		}
		if (!sequence.isEmpty()) {
			addEntry(sequence);
		}
	}
683901
@Override
    public boolean parseManagementInterfaces(final XMLExtendedStreamReader reader, final ModelNode address,
            final List<ModelNode> list) throws XMLStreamException {
        requireNoAttributes(reader);

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case NATIVE_INTERFACE: {
                    parseManagementInterface(reader, address, false, list);
                    break;
                }
                case HTTP_INTERFACE: {
                    parseManagementInterface(reader, address, true, list);
                    break;
                }
                case NATIVE_REMOTING_INTERFACE: {
                    parseNativeRemotingManagementInterface(reader, address, list);
                    break;
                }
                default: {
                    throw unexpectedElement(reader);
                }
            }
        }

        return true;
    }
551589
public static InputReader getInstance(Reader in, char[] shared)
    {
        Set<ParserFeature> features = NO_FEATURES;
        return new ReadableInput(getFeaturedReader(in, shared.length, features), shared, features);
    }
584822
public static void loadFrom(Reader reader, Proto target) throws Exception
    {
        loadFrom(new ANTLRReaderStream(reader), target);
    }
83055
private static NaryTree readSubtreeInPtbFormat(Reader reader) throws IOException {
        ReaderState state = ReaderState.START;
        StringBuilder symbolSb = new StringBuilder();
        ArrayList<NaryTree> children = null;
        boolean isLexical = false;

        char[] cbuf = new char[1];
        while (reader.read(cbuf) != -1) {
        //for (int i=0; i<treeStr.length(); i++) {
            //char c = treeStr.charAt(i);
            char c = cbuf[0];
            if (state == ReaderState.START) {
                if (c == '(') {
                    state = ReaderState.NONTERMINAL;
                } else if (c == ')') {
                    // This was the tail end of a tree.
                    break;
                } else if (!isWhitespace(c)) {
                    symbolSb.append(c);
                    state = ReaderState.LEXICAL;
                    isLexical = true;
                }
            } else if (state == ReaderState.LEXICAL) {
                if (isWhitespace(c) || c == ')') {
                    state = ReaderState.DONE;
                    break;
                } else {
                    symbolSb.append(c);
                }
            } else if (state == ReaderState.NONTERMINAL) {
                if (isWhitespace(c)) {
                    state = ReaderState.CHILDREN;
                    children = readTreesInPtbFormat(reader);
                    state = ReaderState.DONE;
                    break;
                } else {
                    symbolSb.append(c);
                }
            } else {
                throw new IllegalStateException("Invalid state: " + state);
            }
        }
        if (state != ReaderState.DONE) {
            // This reader did not start with a valid PTB style tree.
            return null;
        }
        
        int start = NOT_INITIALIZED;
        int end = NOT_INITIALIZED;
        String symbol = symbolSb.toString();
        NaryTree root = new NaryTree(symbol, start, end, children, isLexical);
        return root;
    }
877959
public static HostsFileEntries parse(Reader reader) throws IOException {
        checkNotNull(reader, "reader");
        BufferedReader buff = new BufferedReader(reader);
        try {
            Map<String, Inet4Address> ipv4Entries = new HashMap<String, Inet4Address>();
            Map<String, Inet6Address> ipv6Entries = new HashMap<String, Inet6Address>();
            String line;
            while ((line = buff.readLine()) != null) {
                // remove comment
                int commentPosition = line.indexOf('#');
                if (commentPosition != -1) {
                    line = line.substring(0, commentPosition);
                }
                // skip empty lines
                line = line.trim();
                if (line.isEmpty()) {
                    continue;
                }

                // split
                List<String> lineParts = new ArrayList<String>();
                for (String s: WHITESPACES.split(line)) {
                    if (!s.isEmpty()) {
                        lineParts.add(s);
                    }
                }

                // a valid line should be [IP, hostname, alias*]
                if (lineParts.size() < 2) {
                    // skip invalid line
                    continue;
                }

                byte[] ipBytes = NetUtil.createByteArrayFromIpAddressString(lineParts.get(0));

                if (ipBytes == null) {
                    // skip invalid IP
                    continue;
                }

                // loop over hostname and aliases
                for (int i = 1; i < lineParts.size(); i ++) {
                    String hostname = lineParts.get(i);
                    String hostnameLower = hostname.toLowerCase(Locale.ENGLISH);
                    InetAddress address = InetAddress.getByAddress(hostname, ipBytes);
                    if (address instanceof Inet4Address) {
                        Inet4Address previous = ipv4Entries.put(hostnameLower, (Inet4Address) address);
                        if (previous != null) {
                            // restore, we want to keep the first entry
                            ipv4Entries.put(hostnameLower, previous);
                        }
                    } else {
                        Inet6Address previous = ipv6Entries.put(hostnameLower, (Inet6Address) address);
                        if (previous != null) {
                            // restore, we want to keep the first entry
                            ipv6Entries.put(hostnameLower, previous);
                        }
                    }
                }
            }
            return ipv4Entries.isEmpty() && ipv6Entries.isEmpty() ?
                    HostsFileEntries.EMPTY :
                    new HostsFileEntries(ipv4Entries, ipv6Entries);
        } finally {
            try {
                buff.close();
            } catch (IOException e) {
                logger.warn("Failed to close a reader", e);
            }
        }
    }