process block from the block_parser and return a list of processed lines
175485
def process_block(self, block):
        
        ret = []
        output = None
        input_lines = None
        lineno = self.IP.execution_count

        input_prompt = self.promptin % lineno
        output_prompt = self.promptout % lineno
        image_file = None
        image_directive = None

        found_input = False
        for token, data in block:
            if token == COMMENT:
                out_data = self.process_comment(data)
            elif token == INPUT:
                found_input = True
                (out_data, input_lines, output, is_doctest,
                 decorator, image_file, image_directive) = \
                          self.process_input(data, input_prompt, lineno)
            elif token == OUTPUT:
                if not found_input:

                    TAB = ' ' * 4
                    linenumber = 0
                    source = 'Unavailable'
                    content = 'Unavailable'
                    if self.directive:
                        linenumber = self.directive.state.document.current_line
                        source = self.directive.state.document.current_source
                        content = self.directive.content
                        # Add tabs and join into a single string.
                        content = '\n'.join([TAB + line for line in content])

                    e = ('\n\nInvalid block: Block contains an output prompt '
                         'without an input prompt.\n\n'
                         'Document source: {0}\n\n'
                         'Content begins at line {1}: \n\n{2}\n\n'
                         'Problematic block within content: \n\n{TAB}{3}\n\n')
                    e = e.format(source, linenumber, content, block, TAB=TAB)

                    # Write, rather than include in exception, since Sphinx
                    # will truncate tracebacks.
                    sys.stdout.write(e)
                    raise RuntimeError('An invalid block was detected.')

                out_data = \
                    self.process_output(data, output_prompt, input_lines,
                                        output, is_doctest, decorator,
                                        image_file)
                if out_data:
                    # Then there was user submitted output in verbatim mode.
                    # We need to remove the last element of `ret` that was
                    # added in `process_input`, as it is '' and would introduce
                    # an undesirable newline.
                    assert(ret[-1] == '')
                    del ret[-1]

            if out_data:
                ret.extend(out_data)

        # save the image files
        if image_file is not None:
            self.save_image(image_file)

        return ret, image_directive
773100
def _parse_block(self):
        """"""
        if self._iter_rows is not None:
            return

        rows = _avro_rows(self._block, self._avro_schema)
        self._num_items = self._block.avro_rows.row_count
        self._remaining = self._block.avro_rows.row_count
        self._iter_rows = iter(rows)
828384
def program(self):
        
        statements = []
        if self.cur_token.type == TokenTypes.NEW_LINE:
            self.eat(TokenTypes.NEW_LINE)
        while self.cur_token.type != TokenTypes.EOF:
            statements += [self.statement()]
        return Block(statements)
1286359
def memoized_parse_block(code):
    """"""
    success, result = parse_block_memo.get(code, (None, None))
    if success is None:
        try:
            parsed = COMPILER.parse_block(code)
        except Exception as err:
            success, result = False, err
        else:
            success, result = True, parsed
        parse_block_memo[code] = (success, result)
    if success:
        return result
    else:
        raise result
609919
def read_block(handle, signal):
    
    signal_len = len(signal)
    it = (x[1] for x in groupby(handle,
        key=lambda row: row.strip()[:signal_len] == signal))
    found_signal = False
    for header in it:
        header = list(header)
        for h in header[:-1]:
            h = h.strip()
            if h[:signal_len] != signal:
                continue
            yield h, []  # Header only, no contents
        header = header[-1].strip()
        if header[:signal_len] != signal:
            continue
        found_signal = True
        seq = list(s.strip() for s in next(it))
        yield header, seq

    if not found_signal:
        handle.seek(0)
        seq = list(s.strip() for s in handle)
        yield None, seq
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;
  }
460678
def _get_blocks(lines):
    
    cur_block = []
    pre_lang = None
    pre_in_code = None
    for (l, in_code, cur_lang, _) in _parse_code_lines(lines):
        if in_code != pre_in_code:
            if pre_in_code and len(cur_block) >= 2:
                cur_block = cur_block[1:-1] # remove ```
            # remove empty lines at head
            while len(cur_block) > 0:
                if len(cur_block[0]) == 0:
                    cur_block.pop(0)
                else:
                    break
            # remove empty lines at tail
            while len(cur_block) > 0:
                if len(cur_block[-1]) == 0:
                    cur_block.pop()
                else:
                    break
            if len(cur_block):
                yield (pre_in_code, pre_lang, cur_block)
            cur_block = []
        cur_block.append(l)
        pre_lang = cur_lang
        pre_in_code = in_code
    if len(cur_block):
        yield (pre_in_code, pre_lang, cur_block)
105177
function listShortcuts(blocks, filePath) {
    var parser = parsers.getForFile(filePath);

    if (!parser) {
        return Immutable.List();
    }

    return blocks
        .map(function(block) {
            return block.getShortcuts();
        })
        .filter(function(shortcuts) {
            return (
                shortcuts &&
                shortcuts.acceptParser(parser.getName())
            );
        });
}
685205
def extract_tree_block(self):
        ""        

        lines = iter(self.data)
        while 1:
            try:
                line = next(lines).strip()
            except StopIteration:
                break
    
            # enter trees block
            if line.lower() == "begin trees;":
                while 1:
                    # iter through trees block
                    sub = next(lines).strip().split()
                    
                    # skip if a blank line
                    if not sub:
                        continue

                    # look for translation
                    if sub[0].lower() == "translate":
                        while sub[0] != ";":
                            sub = next(lines).strip().split()
                            self.tdict[sub[0]] = sub[-1].strip(",")

                    # parse tree blocks
                    if sub[0].lower().startswith("tree"):
                        self.newicks.append(sub[-1])
        
                    # end of trees block
                    if sub[0].lower() == "end;":
                        break
130754
def _blockread(self, fname):
        
        with open(fname, 'rb') as f:
            while True:
                a = []
                for i in range(self.bsize):
                    line = f.readline()
                    if not line: break
                    a.append(line.split())
                if a == []: raise StopIteration
                yield a
1025576
def iter_lines(self, section):
        
        try:
            section = self._get_section(section, create=False)
        except KeyError:
            return

        for block in section:
            for line in block:
                yield line
373827
def tokenize_block(iterable, token_types):
    
    lines = FileWrapper(iterable)
    parse_buffer = ParseBuffer()
    line = lines.peek()
    while line is not None:
        for token_type in token_types:
            if token_type.start(line):
                result = token_type.read(lines)
                if result is not None:
                    parse_buffer.append((token_type, result))
                    break
        else:  # unmatched newlines
            next(lines)
            parse_buffer.loose = True
        line = lines.peek()
    return parse_buffer
1251212
def extract_resource_info( lines, blocks, file_name )
      blocks ? info = [] : blocks = []
      blocks.each.map do |b|
        if lines[ b[:init] ].include? "=begin resource"
          n_lines = b[:end] - b[:init] - 1
          begin
            info.push YAML.load( lines[ b[:init] +1, n_lines ].join.gsub(/\ *#/, '') )
          rescue Psych::SyntaxError => e
            puts "Error parsing block in #{file_name} file [#{b[:init]} - #{b[:end]}]"
          rescue => e
            puts e
          end
        end
      end

      info.first ? info.first : {}
    end
251713
function processInline(tokens) {
  if (tokens[0] && (tokens[0].type === 'header' ||
      tokens[0].type === 'list' || tokens[0].type === 'ordered-list' ||
      tokens[0].type === 'blockquote')) {
    tokens[0].content = processEmphasis(tokens[0].content);
    tokens[0].length = getTokensLength(tokens[0].content);
    delete tokens[0].markup;
  } else if (Array.isArray(tokens)) {
    tokens = processEmphasis(tokens);
  }

  return tokens;
}
519847
private String process() throws IOException
    {
        final StringBuilder out = new StringBuilder();
        final Block parent = this.readLines();
        parent.removeSurroundingEmptyLines();

        this.recurse(parent, false);
        Block block = parent.blocks;
        while (block != null)
        {
            this.emitter.emit(out, block);
            block = block.next;
        }

        return out.toString();
    }
72587
def __get_doc_block_lines(self):
        
        line1 = None
        line2 = None

        i = 0
        for line in self._routine_source_code_lines:
            if re.match(r'\s*/\*\*', line):
                line1 = i

            if re.match(r'\s*\*/', line):
                line2 = i

            if self._is_start_of_stored_routine(line):
                break

            i += 1

        return line1, line2
803830
def _parse_block_header(line):
    
    level = line[1]
    one, _rest = line[4:].split(')=', 1)
    name, _rest = _rest.split('(', 1)
    seqcount, _rest = _rest.split(')', 1)
    params = _rest.strip('{}:')
    # try:
    #     params = dict((key, float(val))
    #             for key, val in (pair.split('=')
    #                 for pair in _rest[1:-2].split(',')))
    # except ValueError:
    #     # Couldn't convert params to key-val pairs, for whatever reason
    #     logging.warn("Failed to parse CMA params: %s", _rest[1:-2])
    #     params = {}
    return int(level), int(one), name, int(seqcount), params