Brackets parsers
180059
function parsers(snapdragon, options) {
  var reflinks = snapdragon.reflinks = {unresolved: [], resolved: {}};
  if (options && options.reflinks) {
    reflinks.resolved = extend({}, options.reflinks);
  }

  snapdragon.parser.sets.reflink = snapdragon.parser.sets.reflink || [];
  snapdragon.parser

    /**
     * Newlins
     */

    .capture('newline', /^\n/)

    /**
     * Text parser
     */

    .capture('text', function() {
      if (this.isInside('reflink')) return;
      var pos = this.position();
      var m = this.match(not);
      if (!m || !m[0]) return;

      return pos({
        type: 'text',
        val: m[0]
      });
    })

    /**
     * Bracket (noop)
     */

    .capture('reflink', function() {})

    /**
     * Open: '['
     */

    .capture('reflink.open', function() {
      var parsed = this.parsed;
      var pos = this.position();
      var m = this.match(/^\[(?=.*\])/);
      if (!m) return;

      var prev = this.prev();
      var last = utils.last(prev.nodes);

      var open = pos({
        type: 'reflink.open',
        val: m[0]
      });

      var node = pos({
        type: 'reflink',
        label: '',
        nodes: [open]
      });

      define(node, 'parsed', parsed);
      define(node, 'parent', prev);
      define(open, 'parent', node);
      this.push('reflink', node);
      prev.nodes.push(node);
    })

    /**
     * Bracket text
     */

    .capture('reflink.inner', function() {
      if (!this.isInside('reflink')) return;
      var pos = this.position();
      var m = this.match(not);
      if (!m || !m[0]) return;

      var prev = this.prev();
      var node = pos({
        type: 'reflink.inner',
        val: m[0]
      });

      if (prev.type !== 'reflink') {
        node.type = 'text';
      }

      prev.nodes.push(node);
      define(node, 'parent', prev);
      prev.label = node.val;
    })

    /**
     * Close: ']'
     */

    .capture('reflink.close', function() {
      var parsed = this.parsed;
      var pos = this.position();
      var m = this.match(/^(\])(:?)([^\n]+)?/);
      if (!m) return;

      var prev = this.prev();
      var last = utils.last(prev.nodes);

      var node = pos({
        type: 'reflink.close',
        val: m[1] + (m[2] ? (m[2] + ' ') : '')
      });

      define(node, 'rest', this.input);

      if (last.type === 'reflink.open') {
        node.type = 'reflink.inner';
        node.escaped = true;
        return node;
      }

      var parent = this.pop('reflink');
      if (!this.isType(parent, 'reflink')) {
        if (this.options.strict) {
          throw new Error('missing opening "["');
        }
        node.type = 'reflink.inner';
        node.escaped = true;
        return node;
      }

      parent.nodes.push(node);
      define(node, 'parent', parent);

      if (m[3] && !m[2]) {
        node.val += m[3];
        return;
      }

      if (m[2] && m[3]) {
        var tok = pos({type: 'reflink.link'});
        parseLink(m[3], tok, parent);
        parent.nodes.push(tok);
        define(tok, 'parent', parent);

        var key = parent.label;
        tok.label = key;

        if (tok.resolved) {
          reflinks.resolved[key] = tok;
        } else {
          reflinks.unresolved.push(tok);
        }
      }
    });
}
496917
def parse_array(raw_array):
    """"""
    array_strip_brackets = raw_array.replace('{', '').replace('}', '')
    array_strip_spaces = array_strip_brackets.replace('"', '').replace(' ', '')
    return array_strip_spaces.split(',')
325788
function brackets() {
			for (;;) {
				oToken = that.advance();
				if (!oToken || oToken.id === ';') {
					that.expected("')'", oToken);
				}
				sValue += oToken.value;
				if (oToken.id === ")") {
					return;
				}
				if (oToken.id === "(") {
					brackets();
				}
			}
		}
340567
function lex(text) {
  let root = new StyleNode();
  root['start'] = 0;
  root['end'] = text.length
  let n = root;
  for (let i = 0, l = text.length; i < l; i++) {
    if (text[i] === OPEN_BRACE) {
      if (!n['rules']) {
        n['rules'] = [];
      }
      let p = n;
      let previous = p['rules'][p['rules'].length - 1] || null;
      n = new StyleNode();
      n['start'] = i + 1;
      n['parent'] = p;
      n['previous'] = previous;
      p['rules'].push(n);
    } else if (text[i] === CLOSE_BRACE) {
      n['end'] = i + 1;
      n = n['parent'] || root;
    }
  }
  return root;
}
11756
def brackets_whitespace(input)
      output = input.gsub(/([\(\[\{])\s*/, '\1')
      output = output.gsub(/\s*([\]\)\}])/, '\1')
      output = output.gsub(/\s+([\(\[\{])\s*/, ' \1')
      output = output.gsub(/\s*([\]\)\}])\s+/, '\1 ')
    end
77238
private ParseTree parseLogicalOR(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseLogicalAND(expressionIn);
    while (peek(TokenType.OR)) {
      Token operator = eat(TokenType.OR);
      ParseTree right = parseLogicalAND(expressionIn);
      left = new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
    }
    return left;
  }
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
  }
}
42012
protected void parseBracketCreateMatrix(TokenList tokens, Sequence sequence) {
        List<TokenList.Token> left = new ArrayList<TokenList.Token>();

        TokenList.Token t = tokens.getFirst();

        while( t != null ) {
            TokenList.Token next = t.next;
            if( t.getSymbol() == Symbol.BRACKET_LEFT ) {
                left.add(t);
            } else if( t.getSymbol() == Symbol.BRACKET_RIGHT ) {
                if( left.isEmpty() )
                    throw new RuntimeException("No matching left bracket for right");

                TokenList.Token start = left.remove(left.size() - 1);

                // Compute everything inside the [ ], this will leave a
                // series of variables and semi-colons hopefully
                TokenList bracketLet = tokens.extractSubList(start.next,t.previous);
                parseBlockNoParentheses(bracketLet, sequence, true);
                MatrixConstructor constructor = constructMatrix(bracketLet);

                // define the matrix op and inject into token list
                Operation.Info info = Operation.matrixConstructor(constructor);
                sequence.addOperation(info.op);

                tokens.insert(start.previous, new TokenList.Token(info.output));

                // remove the brackets
                tokens.remove(start);
                tokens.remove(t);
            }

            t = next;
        }

        if( !left.isEmpty() )
            throw new RuntimeException("Dangling [");
    }
902948
function parseEmphasis(tokens) {
  const newTokens = [];
  let i = 0;
  while (i < tokens.length) {
    if (typeof tokens[i] === 'string') {
      if (tokens[i] !== '') {
        newTokens.push(tokens[i]);
      }
      i++;
    } else {
      const currTag = tokens[i].type;
      if (INLINE_OPEN.indexOf(currTag) !== -1) {
        const closeTag = getCloseTag(currTag);
        const closePos = getClosePos(tokens, i, closeTag, tokens[i].markup);
        if (closePos !== -1) {
          let intEmphasis = getOneEmphasis(tokens, i, closePos);
          if (Array.isArray(intEmphasis) && intEmphasis.length === 0) {
            intEmphasis = '';
          }
          if (currTag === 'link_open') {
            newTokens.push(getUrlToken({ tokens, intEmphasis, num: i }));
          } else {
            newTokens.push(getEmphasisToken({ tokens, intEmphasis, currTag, num: i }));
          }
          i = closePos + 1;
          continue;
        }
      }
      newTokens.push(tokens[i]);
      i++;
    }
  }
  return newTokens;
}
1146511
def bracketedList(l, r, sep, expr, allow_missing_close=False):
  
  # We may need to backtrack for lists, because of list comprehension, but not for
  # any of the other lists
  strict = l != '['
  closer = sym(r) if not allow_missing_close else p.Optional(sym(r))
  if strict:
    return sym(l) - listMembers(sep, expr) - closer
  else:
    return sym(l) + listMembers(sep, expr) + closer
79819
JCExpression bracketsSuffix(JCExpression t) {
        if ((mode & EXPR) != 0 && token.kind == DOT) {
            mode = EXPR;
            int pos = token.pos;
            nextToken();
            accept(CLASS);
            if (token.pos == endPosTable.errorEndPos) {
                // error recovery
                Name name;
                if (LAX_IDENTIFIER.accepts(token.kind)) {
                    name = token.name();
                    nextToken();
                } else {
                    name = names.error;
                }
                t = F.at(pos).Erroneous(List.<JCTree>of(toP(F.at(pos).Select(t, name))));
            } else {
                Tag tag = t.getTag();
                // Type annotations are illegal on class literals. Annotated non array class literals
                // are complained about directly in term3(), Here check for type annotations on dimensions
                // taking care to handle some interior dimension(s) being annotated.
                if ((tag == TYPEARRAY && TreeInfo.containsTypeAnnotation(t)) || tag == ANNOTATED_TYPE)
                    syntaxError("no.annotations.on.dot.class");
                t = toP(F.at(pos).Select(t, names._class));
            }
        } else if ((mode & TYPE) != 0) {
            if (token.kind != COLCOL) {
                mode = TYPE;
            }
        } else if (token.kind != COLCOL) {
            syntaxError(token.pos, "dot.class.expected");
        }
        return t;
    }
145156
Rule BracketedVoice() {
		return Sequence('[', ZeroOrMore(WSP()),
				FirstOf(SingleVoice(), BracedVoice(), ParenVoice()),
				OneOrMore(Sequence(BarStaves(),
									FirstOf(SingleVoice(), BracedVoice(), ParenVoice()))),
				ZeroOrMore(WSP()),
				']')
			.label(BracketedVoice);
	}
433684
def parse(cls, parser, text, pos):
        """"""
        try:
            parser._parsing_parenthesized_simple_values_expression = True
            remaining_text, recognized_tokens = parser.parse(text, cls.grammar)
            return remaining_text, recognized_tokens
        except SyntaxError as e:
            return text, e
        finally:
            parser._parsing_parenthesized_simple_values_expression = False
680804
def get_parens(line,retlevel=0,retblevel=0):
    
    if len(line) == 0: return line
    parenstr = ''
    level = 0
    blevel = 0
    for char in line:
        if char == '(':
            level += 1
        elif char == ')':
            level -= 1
        elif char == '[':
            blevel += 1
        elif char == ']':
            blevel -= 1
        elif (char.isalpha() or char == '_' or char == ':' or char == ',' 
          or char == ' ') and level == retlevel and blevel == retblevel:
            return parenstr
        parenstr = parenstr + char
    
    if level == retlevel and blevel == retblevel: return parenstr    
    raise Exception("Couldn't parse parentheses: {}".format(line))
493871
function parseArguments() {
        var args = [];

        expect('(');

        if (!match(')')) {
            while (startIndex < length) {
                args.push(parseAssignmentExpression());
                if (match(')')) {
                    break;
                }
                expectCommaSeparator();
            }
        }

        expect(')');

        return args;
    }
230188
function parsePrimary() {
                    var token, expr;

                    token = lexer.peek();

                    if (typeof token === 'undefined') {
                        throw new SyntaxError('Unexpected termination of expression');
                    }

                    if (token.type === T.Identifier) {
                        token = lexer.next();
                        if (matchOp(lexer.peek(), '(')) {
                            return parseFunctionCall(token.value);
                        } else {
                            return MathLib.Expression.variable(token.value);
                        }
                    }

                    if (token.type === T.Number) {
                        token = lexer.next();
                        return MathLib.Expression.number(token.value);
                    }

                    if (matchOp(token, '(')) {
                        lexer.next();
                        expr = parseAssignment();
                        token = lexer.next();
                        if (!matchOp(token, ')')) {
                            throw new SyntaxError('Expecting )');
                        }
                        return new MathLib.Expression({
                            subtype: 'brackets',
                            value: 'brackets',
                            content: expr
                        });
                    }

                    throw new SyntaxError('Parse error, can not process token ' + token.value);
                }
1164207
def parse(cls, parser, text, pos):
        """"""
        match = cls.regex.match(text)
        if match:
            # Check if match is is not in the grammar of the specific keyword class.
            if match.group(0).lower() not in cls.grammar:
                result = text, SyntaxError(repr(match.group(0)) + " is not a member of " + repr(cls.grammar))
            else:
                result = text[len(match.group(0)):], cls(match.group(0))
        else:
            result = text, SyntaxError("expecting " + repr(cls.__name__))
        return result