Parses the given file and returns an Array containing all the associated
 AST nodes and comments.

 @param [RubyLint::Parser] parser
 @param [String] file
 @return [Array]
337064
def parse_file(parser, file)
      return parser.parse(File.read(file, :encoding => Encoding::UTF_8), file)
    end
532053
def parse_raw_file(file)
      data = {}
      File.readlines(file).each do |line|
        line = str_clean line, false
        next if line.empty? || line[0] == '#'
        prefix, line_data = line.split('|')
        data[prefix] = line_data && line_data.strip.split('&')
      end
      data
    end
884667
def _ParseFile(self, file_obj, line_parser):
    
    lines = [
        l.strip() for l in utils.ReadFileBytesAsUnicode(file_obj).splitlines()
    ]
    try:
      for index, line in enumerate(lines):
        if line:
          line_parser(line)
    except (IndexError, KeyError) as e:
      raise parser.ParseError("Invalid file at line %d: %s" % (index + 1, e))
1217498
def parse_file(self, filename):
        

        with open(filename, "rb", _BUFFERING) as stream:
            self.parse(stream.read())
401338
def parse_gemfile
      gemfile = File.join(Rails.root, 'Gemfile')
      @gem_lines = IO.readlines(gemfile).select{|line| line =~ /\A\s*gem/ }
    end
1258337
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'color2'
          @color2 = Color.new(parent: self).parse_hex_string(value.value.split(' ').first.delete('#'))
        when 'id'
          @id = value.value.to_s
          @file = FileReference.new(parent: self).parse(node)
        when 'type'
          @type = value_to_symbol(value)
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'patternFill'
          @pattern_fill = PatternFill.new(parent: self).parse(node_child)
        end
      end
      self
    end
382554
function parser ( temp, line, block, file, from, to, options ) {

    var parts           = line.replace( /.*@/, '' );
    var index           = indexer( parts, ' ' ) || indexer( parts, '\n' ) || indexer( parts, '\r' ) || parts.length;
    var name            = _dss.trim( parts.substr( 0, index ) );
    var output          = {
      options: options,
      file: file,
      name: name,
      line: {
        contents: _dss.trim( parts.substr( index ) ),
        from: block.indexOf( line ),
        to: block.indexOf( line )
      },
      block: {
        contents: block,
        from: from,
        to: to
      }
    };

    // find the next instance of a parser (if there is one based on the @ symbol)
    // in order to isolate the current multi-line parser
    var nextParserIndex = block.indexOf( '* @', output.line.from + 1 );
    var markupLength = ( nextParserIndex > -1 ) ? nextParserIndex - output.line.from : block.length;
    var contents = block.split( '' ).splice( output.line.from , markupLength ).join( '' );
    var parserMarker = '@' + name;
    contents = contents.replace( parserMarker, '' );

    // Redefine output contents to support multiline contents
    output.line.contents = ( function( contents ) {
      var ret = [];
      var lines = contents.split( '\n' );

      lines.forEach( function( line, i ) {

        var pattern = '*';
        var index = line.indexOf( pattern );

        if ( index >= 0 && index < 10 ) {
          line = line.split( '' ).splice( ( index + pattern.length ), line.length ).join( '' );
        }

        // Trim whitespace from the the first line in multiline contents
        if ( i === 0 ) {
          line = _dss.trim( line );
        }

        if ( line && line.indexOf( parserMarker ) == -1 ) {
          ret.push( line );
        }

      });

      return ret.join( '\n' );

    })( contents );

    line = {};
    line[ name ] = ( _dss.parsers[ name ] ) ? _dss.parsers[ name ].call( output ) : output.line.contents;

    if ( temp[ name ] ) {
      if ( !_dss.isArray( temp[ name ] ) ) {
        temp[name] = [ temp[ name ] ];
      }
      if ( !_dss.isArray( line[ name ] ) ) {
        temp[ name ].push( line[ name ] );
      } else {
        temp[ name ].push( line[ name ][ 0 ] );
      }
    } else {
      temp = _dss.extend( temp, line );
    }
    return temp;
  }
851650
def parse
      file_to_parse = OOXMLDocumentObject.path_to_folder + 'word/commentsExtended.xml'
      return nil unless File.exist?(file_to_parse)

      doc = parse_xml(file_to_parse)
      doc.xpath('w15:commentsEx/*').each do |node_child|
        case node_child.name
        when 'commentEx'
          @comments_extended_array << CommentExtended.new(parent: self).parse(node_child)
        end
      end
      self
    end
1159189
def from_file(filename, encoding='utf-8')
      mode = "rb:#{encoding}"
      mode = "rb" if RUBY_VERSION < '1.9'
      input = File.open(filename, mode) {|f| f.read() }
      compile(parse(input), filename, 1)
      return self
    end
388304
def parse_file(path, target_ext=nil)
      return nil if path.nil?
      return nil if File.directory? path
      _load_from_file path, target_ext
      # if File.directory? path
      #   _load_from_directory path
      # else
      #   _load_from_file path, target_ext
      # end
    end
761893
def parse_files
      @parse_files ||= begin
        files = expand_dirs_to_files(@path)
        files = file_sort(files)

        if @options['only'].present?
          files = file_accept(files, @options['only'])
        end

        # By default, tmp, vender, spec, test, features are ignored.
        %w[vendor spec test features tmp].each do |dir|
          files = file_ignore(files, File.join(@path, dir)) unless @options[dir]
        end

        # Exclude files based on exclude regexes if the option is set.
        @options['exclude'].each do |pattern|
          files = file_ignore(files, pattern)
        end

        %w[Capfile Gemfile Gemfile.lock].each do |file|
          files.unshift File.join(@path, file)
        end

        files.compact
      end
    end
675154
function parse_javascript(file /*, options*/) {
  let source = fs.readFileSync(file, 'utf8');

  let nodes, list = {};

  try {
    nodes = parser.parse(source);
  } catch (err) {
    throw new Error(`${err} [${file}:${err.line},${err.column}]`);
  }

  // do pre-distribute early work
  _.each(nodes, node /*, id*/ => {
    let clone;

    // assign hierarchy helpers
    node.aliases  = [];
    node.children = [];

    // set source fiel of the node
    node.file = file;

    if (node.type === 'class') {
      node.subclasses = [];
    }

    // collect sections
    if (node.type === 'section') {
      list[node.id] = node;
      return;
    }

    // elements with undefined section get '' section,
    // and will be resolved later, when we'll have full
    // element list
    list[(node.section || '') + '.' + node.id] = node;

    // bound methods produce two methods with the same description but different signatures
    // E.g. Element.foo(@element, a, b) becomes
    // Element.foo(element, a, b) and Element#foo(a, b)
    if (node.type === 'method' && node.bound) {
      clone = _.clone(node);
      clone.id = node.id.replace(/(.+)\.(.+)$/, '$1#$2');

      // link to methods
      node.bound = clone.id;
      clone.bound = node.id;

      // insert bound method clone
      list[(node.section || '') + '.' + clone.id] = clone;
    }
  });

  // TODO: section.related_to should mark related element as belonging to the section
  //_.each(list, function (node, id) {
  //  var ref_id = '.' + node.related_to, ref;
  //  if ('section' === node.type && node.related_to && list[ref_id]) {
  //    ref = list[ref_id];
  //    ref.id = node.id + '.' + node.related_to;
  //    delete list[ref_id];
  //    list[ref.id] = ref;
  //  }
  //});

  return list;
}
835954
function parseFile(fs, file, type) {
    var filepath = file.getPath();
    var parser = file.getParser();

    if (!parser) {
        return Promise.reject(
            error.FileNotParsableError({
                filename: filepath
            })
        );
    }

    return fs.readAsString(filepath)
    .then(function(content) {
        if (type === 'readme') {
            return parser.parseReadme(content);
        } else if (type === 'glossary') {
            return parser.parseGlossary(content);
        } else if (type === 'summary') {
            return parser.parseSummary(content);
        } else if (type === 'langs') {
            return parser.parseLanguages(content);
        } else {
            throw new Error('Parsing invalid type "' + type + '"');
        }
    })
    .then(function(result) {
        return [
            file,
            result
        ];
    });
}
721387
def extract_annotations_from(file, pattern)
      lineno = 0
      result = File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
        lineno += 1
        next list unless line =~ pattern
        list << Annotation.new(lineno, $1, $2)
      end
      result.empty? ? {} : { file => result }
    end
1029185
def parse_file_content(file_path)
      text = ::File.read(file_path)
      tokens = text.split(%r{^\[(.*?)\]\r?\n})
      tokens.shift # first item should be blank
      tokens.in_groups_of(2).each_with_object({}) do |pair, h|
        h[pair[0]] = pair[1]
      end
    end
736413
def parse_from_file(file_object):
    

    logger.info('Parsing %s file.', file_object.file_name)

    # Read the files
    doc_content = file_object.read_file('document.xml')

    # Parse the document
    document = parse_document(doc_content)

    try:
        style_content = file_object.read_file('styles.xml')
        parse_style(document, style_content)
    except KeyError:
        logger.warning('Could not read styles.')

    try:
        doc_rel_content = file_object.read_file('_rels/document.xml.rels')
        parse_relationship(document, doc_rel_content, 'document')
    except KeyError:
        logger.warning('Could not read document relationships.')

    try:
        doc_rel_content = file_object.read_file('_rels/endnotes.xml.rels')
        parse_relationship(document, doc_rel_content, 'endnotes')
    except KeyError:
        logger.warning('Could not read endnotes relationships.')

    try:
        doc_rel_content = file_object.read_file('_rels/footnotes.xml.rels')
        parse_relationship(document, doc_rel_content, 'footnotes')
    except KeyError:
        logger.warning('Could not read footnotes relationships.')

    try:
        comments_content = file_object.read_file('comments.xml')
        parse_comments(document, comments_content)
    except KeyError:
        logger.warning('Could not read comments.')

    try:
        footnotes_content = file_object.read_file('footnotes.xml')
        parse_footnotes(document, footnotes_content)
    except KeyError:
        logger.warning('Could not read footnotes.')

    try:
        endnotes_content = file_object.read_file('endnotes.xml')
        parse_endnotes(document, endnotes_content)
    except KeyError:
        logger.warning('Could not read endnotes.')

    try:
        numbering_content = file_object.read_file('numbering.xml')
        parse_numbering(document, numbering_content)
    except KeyError:
        logger.warning('Could not read numbering.')

    return document
711574
function parse_files(files, options, callback) {
  var nodes = {
    // root section node
    '': {
      id: '',
      type: 'section',
      children: [],
      description: '',
      short_description: '',
      href: '#',
      root: true,
      file: '',
      line: 0
    }
  };

  var reportObject = { };
  
  async.forEachSeries(files, function (file, next_file) {
    var fn = parsers[path.extname(file)];

    if (!fn) {
      next_file();
      return;
    }

    console.info('Parsing file: ' + file);
    fn(file, options, function (err, file_nodes, file_report) {
      // TODO:  fail on name clash here as well -- as we might get name clash
      //        from different parsers, or even different files
      _.extend(nodes, file_nodes);
      _.extend(reportObject, file_report);
      next_file(err);
    });
  }, function (err) {
    callback(err, nodes, reportObject);
  });
}