Parse ruby code, ended with outer delimiters

 @param [String, Regexp] outer_delimiters

 @return [Void] parsed ruby code
164146
def parse_ruby_code(outer_delimiters)
      code = String.new
      end_re = if outer_delimiters.is_a?(Regexp)
                 outer_delimiters
               else
                 /\A\s*[#{Regexp.escape outer_delimiters.to_s}]/
               end
      delimiters = []
      string_start_quote_char = nil

      until @line.empty? || (delimiters.empty? && @line =~ end_re)
        char = @line[0]

        # backslash escaped delimiter
        if char == '\\' && RUBY_ALL_DELIMITERS.include?(@line[1])
          code << @line.slice!(0, 2)
          next
        end

        case char
        when RUBY_START_DELIMITERS_RE
          if RUBY_NOT_NESTABLE_DELIMITERS.include?(char) && delimiters.last == char
            # end char of not nestable delimiter
            delimiters.pop
            string_start_quote_char = nil
          else
            # diving into nestable delimiters
            delimiters << char if string_start_quote_char.nil?

            # mark start char of the not nestable delimiters, for example strings
            if RUBY_NOT_NESTABLE_DELIMITERS.include?(char) && string_start_quote_char.nil?
              string_start_quote_char = char
            end
          end

        when RUBY_END_DELIMITERS_RE
          # rising
          delimiters.pop if char == RUBY_DELIMITERS_REVERSE[delimiters.last]
        end

        code << @line.slice!(0)
      end

      syntax_error('Unexpected end of ruby code') unless delimiters.empty?

      code.strip
    end
528974
def join(separator = $,)
      result = ""
      if separator
        each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }
      else
        each { |obj| result << obj.to_s }
      end
      return Erlang.from(result)
    end
379116
function Delimiters (delims, options) {
  this.options = options || {};
  this.delims = delims || [];

  this.defaults = merge({}, {
    beginning: '^',           // '^' Matches beginning of input.
    matter: '([\\s\\S]+?)',   // The "content" between the delims
    body: '([\\s\\S]+|\\s?)', // The "content" after the delims
    end: '$',                 // '$' Matches end of input.
    flags: ''                 // RegExp flags: g, m, i
  }, options);
}
150490
def parsed
      return @parsed if defined?(@parsed)

      @parsed =
        if parser.respond_to?(:call)
          case parser.arity
          when 0
            parser.call
          when 1
            parser.call(body)
          else
            parser.call(body, response)
          end
        end
    end
170443
def array_elements(buffer = '')
      if (term = expression)
        buffer += term[@value]
        # If there is an array_terminator ",", recursively gather the next
        # array element into the buffer
        if (terminator = accept_stripped :comma)
          accept_newline
          buffer += array_elements terminator
        end
      end

      # Array ended prematurely with a trailing comma, therefore the current
      # parsing process will stop
      error :array_elements_terminator if buffer.strip[-1] == ','

      buffer
    end
956372
function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
        var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
        var currentLang = '*';
        var genericLang = lang.split('-', 1)[0];
        var skipLang = false;
        var match = '';

        function nextEntry() {
          // Use infinite loop instead of recursion to avoid reaching the
          // maximum recursion limit for content with many lines.
          while (true) {
            if (!entries.length) {
              parsedRawLinesCallback();
              return;
            }
            var line = entries.shift();

            // comment or blank line?
            if (reComment.test(line))
              continue;

            // the extended syntax supports [lang] sections and @import rules
            if (extendedSyntax) {
              match = reSection.exec(line);
              if (match) { // section start?
                // RFC 4646, section 4.4, "All comparisons MUST be performed
                // in a case-insensitive manner."

                currentLang = match[1].toLowerCase();
                skipLang = (currentLang !== '*') &&
                    (currentLang !== lang) && (currentLang !== genericLang);
                continue;
              } else if (skipLang) {
                continue;
              }
              match = reImport.exec(line);
              if (match) { // @import rule?
                loadImport(baseURL + match[1], nextEntry);
                return;
              }
            }

            // key-value pair
            var tmp = line.match(reSplit);
            if (tmp && tmp.length == 3) {
              dictionary[tmp[1]] = evalString(tmp[2]);
            }
          }
        }
        nextEntry();
      }
536248
def encodingStrings( reverse = false )
      @encodingStrings  = [ {"&" => "&amp;" },  {"<" => "&lt;"} , {">" => "&gt;"}, {"'" => "&apos;"}, {"\"" => "&quot;" }  ] if @encodingStrings.nil?
      if block_given?
         if reverse
            @encodingStrings.reverse_each{ |s| s.each{|k,v| yield v,k } }
         else
            @encodingStrings.each{ |s| s.each{|k,v| yield k,v }  }
         end
      else
         @encodingStrings
      end
   end
701944
def parse_tag(text)
      match = text.scan(/%([-:\w]+)([-:\w.#\@]*)(.+)?/)[0]
      raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match

      tag_name, attributes, rest = match

      if !attributes.empty? && (attributes =~ /[.#](\.|#|\z)/)
        raise SyntaxError.new(Error.message(:illegal_element))
      end

      new_attributes_hash = old_attributes_hash = last_line = nil
      object_ref = :nil
      attributes_hashes = {}
      while rest && !rest.empty?
        case rest[0]
        when ?{
          break if old_attributes_hash
          old_attributes_hash, rest, last_line = parse_old_attributes(rest)
          attributes_hashes[:old] = old_attributes_hash
        when ?(
          break if new_attributes_hash
          new_attributes_hash, rest, last_line = parse_new_attributes(rest)
          attributes_hashes[:new] = new_attributes_hash
        when ?[
          break unless object_ref == :nil
          object_ref, rest = balance(rest, ?[, ?])
        else; break
        end
      end

      if rest && !rest.empty?
        nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\/\~&!])?(.*)?/)[0]
        if nuke_whitespace
          nuke_outer_whitespace = nuke_whitespace.include? '>'
          nuke_inner_whitespace = nuke_whitespace.include? '<'
        end
      end

      if @options.remove_whitespace
        nuke_outer_whitespace = true
        nuke_inner_whitespace = true
      end

      if value.nil?
        value = ''
      else
        value.strip!
      end
      [tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
       nuke_inner_whitespace, action, value, last_line || @line.index + 1]
    end
923237
public final BELScriptParser.outer_term_return outer_term() throws RecognitionException {
        BELScriptParser.outer_term_return retval = new BELScriptParser.outer_term_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token OPEN_PAREN58=null;
        Token char_literal59=null;
        Token CLOSE_PAREN61=null;
        BELScriptParser.function_return function57 = null;

        BELScriptParser.argument_return argument60 = null;


        Object OPEN_PAREN58_tree=null;
        Object char_literal59_tree=null;
        Object CLOSE_PAREN61_tree=null;

        try {
            // BELScript.g:139:11: ( function OPEN_PAREN ( ( ',' )? argument )* CLOSE_PAREN )
            // BELScript.g:140:5: function OPEN_PAREN ( ( ',' )? argument )* CLOSE_PAREN
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_function_in_outer_term723);
            function57=function();

            state._fsp--;

            adaptor.addChild(root_0, function57.getTree());
            OPEN_PAREN58=(Token)match(input,OPEN_PAREN,FOLLOW_OPEN_PAREN_in_outer_term725); 
            OPEN_PAREN58_tree = (Object)adaptor.create(OPEN_PAREN58);
            adaptor.addChild(root_0, OPEN_PAREN58_tree);

            // BELScript.g:140:25: ( ( ',' )? argument )*
            loop12:
            do {
                int alt12=2;
                int LA12_0 = input.LA(1);

                if ( (LA12_0==OBJECT_IDENT||LA12_0==QUOTED_VALUE||LA12_0==NS_PREFIX||(LA12_0>=43 && LA12_0<=102)) ) {
                    alt12=1;
                }


                switch (alt12) {
            	case 1 :
            	    // BELScript.g:140:26: ( ',' )? argument
            	    {
            	    // BELScript.g:140:26: ( ',' )?
            	    int alt11=2;
            	    int LA11_0 = input.LA(1);

            	    if ( (LA11_0==43) ) {
            	        alt11=1;
            	    }
            	    switch (alt11) {
            	        case 1 :
            	            // BELScript.g:140:26: ','
            	            {
            	            char_literal59=(Token)match(input,43,FOLLOW_43_in_outer_term728); 
            	            char_literal59_tree = (Object)adaptor.create(char_literal59);
            	            adaptor.addChild(root_0, char_literal59_tree);


            	            }
            	            break;

            	    }

            	    pushFollow(FOLLOW_argument_in_outer_term731);
            	    argument60=argument();

            	    state._fsp--;

            	    adaptor.addChild(root_0, argument60.getTree());

            	    }
            	    break;

            	default :
            	    break loop12;
                }
            } while (true);

            CLOSE_PAREN61=(Token)match(input,CLOSE_PAREN,FOLLOW_CLOSE_PAREN_in_outer_term735); 
            CLOSE_PAREN61_tree = (Object)adaptor.create(CLOSE_PAREN61);
            adaptor.addChild(root_0, CLOSE_PAREN61_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
604083
def parse_line(match)
        raise InvalidFormat.new "Couldn't parse plugin" if match.nil?
        Derelict::Plugin.new *match.captures[0..1]
      end
363476
function parse(str) {

  // find the prefix expressions and the main value
  var stringMatches = str.match(stringRegex)
  var allExpString = stringMatches[1] || ''
  var value = stringMatches[2]

  // parse each prefix expression
  var expressions = execAll(allExpressionsRegex, allExpString)
    // grab the expression content inside the braces
    .map(function (match) { return match[1] })
    .map(parseExpression)

  return {
    original:   str,
    value:      value,
    expressions: expressions
  }
}
606825
def as_regexp(options = {})
      unless options.is_a?(::Hash)
        raise ::ArgumentError, "[to_regexp] Options must be a Hash"
      end
      str = self

      return if options[:detect] and str == ''

      if options[:literal] or (options[:detect] and ToRegexp::String.literal?(str))
        content = ::Regexp.escape str
      elsif delim_set = REGEXP_DELIMITERS.detect { |k, _| str.start_with?(k) }
        delim_start, delim_end = delim_set
        /\A#{delim_start}(.*)#{delim_end}(#{INLINE_OPTIONS})\z/u =~ str
        content = $1
        inline_options = $2
        return unless content.is_a?(::String)
        content.gsub! '\\/', '/'
        if inline_options
          options[:ignore_case] = true if inline_options.include?('i')
          options[:multiline] = true if inline_options.include?('m')
          options[:extended] = true if inline_options.include?('x')
          # 'n', 'N' = none, 'e', 'E' = EUC, 's', 'S' = SJIS, 'u', 'U' = UTF-8
          options[:lang] = inline_options.scan(/[nesu]/i).join.downcase
        end
      else
        return
      end
      
      ignore_case = options[:ignore_case] ? ::Regexp::IGNORECASE : 0
      multiline = options[:multiline] ? ::Regexp::MULTILINE : 0
      extended = options[:extended] ? ::Regexp::EXTENDED : 0
      lang = options[:lang] || ''
      if ::RUBY_VERSION > '1.9' and lang.include?('u')
        lang = lang.delete 'u'
      end
      
      if lang.empty?
        [ content, (ignore_case|multiline|extended) ]
      else
        [ content, (ignore_case|multiline|extended), lang ]
      end
    end
1016499
def parse_args(string):
    
    import ast
    is_quoted = False
    result_parts = []
    current_str = ""
    while len(string) > 0:
        if string[0] == "\"":
            is_quoted = not is_quoted
            current_str += string[0]
        elif string[0].isspace():
            if is_quoted:
                current_str += string[0]
            else:
                result_parts.append(current_str)
                current_str = ""
            # end if
        else:
            current_str += string[0]
        # end if
        string = string[1:]
    # end while
    if current_str:  # last part of the array
        result_parts.append(current_str)
    # end if
    for i in range(len(result_parts)):
        # Will try for each element if it is something pythonic. Parsed type will replace original list element.
        try:
            part = ast.literal_eval(result_parts[i])
            result_parts[i] = part  # write it back.
        except ValueError:
            # could not parse -> is string
            pass  # because already is str.
        # end try
    # end for
    return result_parts
226518
def ends_with(self, other):
        ''''''
        @Parser
        def ends_with_parser(text, index):
            res = self(text, index)
            if not res.status:
                return res
            end = other(text, res.index)
            if end.status:
                return res
            else:
                return Value.failure(end.index, 'ends with {}'.format(end.expected))
        return ends_with_parser
942633
def parse_form_data(io, boundary)
      boundary_regexp = /\A--#{Regexp.quote(boundary)}(--)?#{CRLF}\z/
      form_data = Hash.new
      return form_data unless io
      data = nil
      io.each_line{|line|
        if boundary_regexp =~ line
          if data
            data.chop!
            key = data.name
            if form_data.has_key?(key)
              form_data[key].append_data(data)
            else
              form_data[key] = data
            end
          end
          data = FormData.new
          next
        else
          if data
            data << line
          end
        end
      }
      return form_data
    end
757516
function consumeExpr(remaining) {
  var expr;
  var match;
  var name;

  for (var j = 0; j < exprs.length; j++) {
    var e = exprs[j];
    var n = e.name;
    var m = remaining.match(e.regexObj);

    if (m != null) {
      match = m;
      expr = e;
      name = n;
      var consumed = m[0];
      remaining = remaining.substring(consumed.length);
      break; // we've consumed one expr, so we can return now
    }
  }

  return {
    expr: expr,
    match: match,
    name: name,
    remaining: remaining
  };
}
1149611
def parse(scanner, rules, scope = ParserScope.empty)
      catch(:rule_failed) do
        return expr.parse(scanner, rules, scope)
      end
      false
    end