Parse the given AST

@returns {Directive[]}
327685
function parseAst(filename, ast) {
  var directives = [];
  esprimaHelper.traverse(ast, function (node) {
    var calleeExpressionName = esprimaHelper.getCallExpressionName(node);
    if (calleeExpressionName === 'directive') {
      var directiveArguments = node['arguments'] || [];
      if (directiveArguments.length >= 2 && directiveArguments[0].type === 'Literal') {
        directives.push(new Directive(filename, directiveArguments));
      }
    }
  });
  return directives;
}
1223950
def parse_directive_location(lexer: Lexer) -> NameNode:
    """"""
    start = lexer.token
    name = parse_name(lexer)
    if name.value in .__members__:
        return name
    raise unexpected(lexer, start)
119171
function parseTagAndAttrs(parts, pos) {
    var m = /^(\w+)/.exec(parts[pos]);
    var tag = { name: lcase(m[1]) };
    if (html4.ELEMENTS.hasOwnProperty(tag.name)) {
      tag.eflags = html4.ELEMENTS[tag.name];
    } else {
      tag.eflags = void 0;
    }
    var buf = parts[pos].substr(m[0].length);
    // Find the next '>'.  We optimistically assume this '>' is not in a
    // quoted context, and further down we fix things up if it turns out to
    // be quoted.
    var p = pos + 1;
    var end = parts.length;
    for (; p < end; p++) {
      if (parts[p] === '>') { break; }
      buf += parts[p];
    }
    if (end <= p) { return void 0; }
    var attrs = [];
    while (buf !== '') {
      m = ATTR_RE.exec(buf);
      if (!m) {
        // No attribute found: skip garbage
        buf = buf.replace(/^[\s\S][^a-z\s]*/, '');

      } else if ((m[4] && !m[5]) || (m[6] && !m[7])) {
        // Unterminated quote: slurp to the next unquoted '>'
        var quote = m[4] || m[6];
        var sawQuote = false;
        var abuf = [buf, parts[p++]];
        for (; p < end; p++) {
          if (sawQuote) {
            if (parts[p] === '>') { break; }
          } else if (0 <= parts[p].indexOf(quote)) {
            sawQuote = true;
          }
          abuf.push(parts[p]);
        }
        // Slurp failed: lose the garbage
        if (end <= p) { break; }
        // Otherwise retry attribute parsing
        buf = abuf.join('');
        continue;

      } else {
        // We have an attribute
        var aName = lcase(m[1]);
        var aValue = m[2] ? decodeValue(m[3]) : aName;
        attrs.push(aName, aValue);
        buf = buf.substr(m[0].length);
      }
    }
    tag.attrs = attrs;
    tag.next = p + 1;
    return tag;
  }
79654
function parse(tokens) {
    var ast = [];

    var current = ast;

    var _line = 0;
    var _char = 0;

    var openCount = 0;
    var closeCount = 0;

    for (var i = 0; i < tokens.length; i++) {
        var token = tokens[i];

        switch (token.type) {
            case TYPES.open:
                // Every time we open a list, we drop into a sub-array
                var child = [];
                child.parent = current;
                current.push(child);
                current = child;
                openCount += 1;
                break;

            case TYPES.open_array:
            case TYPES.quote:
                var child = [];
                var quote = {"'": child };
                child.parent = current;
                current.push(quote);
                current = child;
                openCount += 1;
                break;

            case TYPES.close_array:
            case TYPES.close:
                // If no current, we probably have too many closing parens
                if (!current) _tooManyClosingParensErr(closeCount, openCount);
                // If we close a list, jump back up to the parent list
                current = current.parent;
                closeCount += 1;
                break;

            case TYPES.identifier:
            case TYPES.suffixed_number:
                current.push(token.string);
                break;

            case TYPES.number:
                current.push(Number(token.string));
                break;

            case TYPES.string:
                // We need to strip the quotes off the string entity
                var dequoted = token.string.slice(1).slice(0, token.string.length - 2);
                current.push(dequoted);
                break;

            case TYPES.json:
                try {
                    var deticked = token.string.slice(1).slice(0, token.string.length - 2);
                    current.push(JSON.parse(deticked));
                }
                catch (e) {
                    throw new Error([
                        'Runiq: Couldn\'t parse inlined JSON!',
                        '--- Error occurred at line ' + _line + ', char ' + _char
                    ].join('\n'));
                }
                break;
        }

        // Capture line numbers and columns for future use
        var lines = token.string.split(NEWLINE);
        _line += lines.length - 1;
        if (lines.length > 1) _char = lines[lines.length - 1].length;
        else _char += token.string.length;
    }

    // Raise error if we have a parentheses mismatch
    if (openCount > closeCount) _tooManyOpenParensErr(closeCount, openCount);
    if (openCount < closeCount) _tooManyClosingParensErr(closeCount, openCount);

    // For both safety and to ensure we actually have a JSON-able AST
    return JSON.parse(JSONStableStringify(ast));
}
162706
function parse(tokens, basePath, iterSuffix) {
  const len = tokens.length;
  const body = [];

  let i = 0;
  while (i < len) {
    const token = tokens[i];
    if (subroutines[token.tokenType]) {
      const rest = tokens.slice(i + 1);
      const [
        branches,
        tokensHandled,
        shouldBreak,
      ] = subroutines[token.tokenType](token, rest, basePath, iterSuffix);

      body.push(...branches);

      i += tokensHandled;

      if (shouldBreak) {
        break;
      }
    } else {
      i += 1;
    }
  }

  return [body, i + 1];
}
725558
function parseHTML(html) {
	var temp = [];

	function push(code, type, padding) {
		code = code.replace(/\n/g, '');
		if (padding) {
			temp.push({code: code, type: type, padding: padding});
		} else {
			temp.push({code: code, type: type});
		}
	}

	function dig(nodes) {
		for (var i = 0; i < nodes.length; i ++) {
			var node = nodes[i];
			switch (node.type) {
				case 'comment':
				break;

				case 'text':
				var words = trim(node.raw).split(' ');
				for (var j = 0, jj = words.length; j < jj; j++) {
					push(words[j] + (j + 1 == jj ? '' : ' '), 'text');
				}
				break;

				case 'directive':
				push('<' + node.raw + '>', 'tag');
				break;

				default:
				var tag = node.name;
				var attribs = node.attribs || {};

				push('<' + tag, 'tag', paddingHTML);
				for (var key in attribs) {
					push(' ' + key + '="' + attribs[key] + '"', 'tag', paddingHTML);
				}
				push('>', 'tag');

				switch (tag) {
					case 'br':
					case 'input':
					case 'hr':
					case 'link':
					case 'meta':
					case 'img':
					case 'embed':
					case 'param':
					case 'area':
					case 'base':
					case 'col':
					case 'keygen':
					case 'source':
					continue;

					case 'script':
					if ((!attribs.type || attribs.type == 'text/javascript') && node.children && node.children[0]) {
						temp = temp.concat(parseJS(node.children[0].raw));
					}
					break;

					case 'style':
					if ((!attribs.type || attribs.type == 'text/css') && node.children && node.children[0]) {
						temp = temp.concat(parseCSS(node.children[0].raw));
					}
					break;

					default:
					if (node.children) dig(node.children);
				}

				push('</' + tag + '>', 'tag')
			}
		}
	}

	var handler = new htmlparser.DefaultHandler(function (error, dom) {});
	new htmlparser.Parser(handler).parseComplete(html);
	dig(handler.dom);

	var nodes = [];
	for (var i = 0, j = 0, ii = temp.length, lastType; i < ii; i++) {
		var tmp = temp[i];
		if (i && (lastType == tmp.type || !tmp.type)) {
			nodes[++j] = tmp;
		} else {
			if (!nodes[j]) {
				nodes[j] = tmp;
			} else {
				nodes[j].code += tmp.code;
				nodes[j].padding = tmp.padding;
			}
		}
		lastType = tmp.type;
	}
	return nodes;
}
326393
def parse(directive):
    
    if not directive:
        # Handle null case
        return None

    if isinstance(directive, (list, tuple)):
        results = []
        for d in directive:
            results.extend(parse(d))
        return results

    if isinstance(directive, (dict, client.Placement)):
        # We've been handed something that we can simply hand back to
        # the api. (Forwards compatibility)
        return [directive]

    # Juju 2.0 can't handle lxc containers.
    directive = directive.replace('lxc', 'lxd')

    if ":" in directive:
        # Planner has given us a scope and directive in string form
        scope, directive = directive.split(":")
        return [client.Placement(scope=scope, directive=directive)]

    if directive.isdigit():
        # Planner has given us a machine id (we rely on juju core to
        # verify its validity.)
        return [client.Placement(scope=MACHINE_SCOPE, directive=directive)]

    if "/" in directive:
        # e.g. "0/lxd/0"
        # https://github.com/juju/juju/blob/master/instance/placement_test.go#L29
        return [
            client.Placement(scope=MACHINE_SCOPE, directive=directive),
        ]

    # Planner has probably given us a container type. Leave it up to
    # juju core to verify that it is valid.
    return [client.Placement(scope=directive)]
617213
function (source) {
  var ast = parser.parseEval(source)
  var array = ast.children.find((child) => child.kind === 'array')
  return parseValue(array)
}
528104
function(raw_directive) {

		if (Lava.schema.DEBUG && !raw_directive.content) Lava.t("empty attach_directives");

		var blocks = Lava.parsers.Common.asBlocks(raw_directive.content),
			sugar = blocks[0],
			directives = blocks.slice(1),
			i,
			count;

		if (Lava.schema.DEBUG) {
			if (sugar.type != 'tag' || sugar.content || directives.length == 0) Lava.t("Malformed attach_directives");
			for (i = 0, count = directives.length; i < count; i++) {
				if (directives[i].type != 'directive') Lava.t("Malformed attach_directives");
			}
		}

		sugar.content = directives;
		return Lava.parsers.Common.compileAsView([sugar]);

	}
545653
function parse(code) {
  var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

  opts.allowHashBang = true;
  opts.sourceType = "module";
  opts.ecmaVersion = Infinity;
  opts.plugins = {
    jsx: true,
    flow: true
  };
  opts.features = {};

  for (var key in _transformation2["default"].pipeline.transformers) {
    opts.features[key] = true;
  }

  var ast = babylon.parse(code, opts);

  if (opts.onToken) {
    // istanbul ignore next

    var _opts$onToken;

    (_opts$onToken = opts.onToken).push.apply(_opts$onToken, ast.tokens);
  }

  if (opts.onComment) {
    // istanbul ignore next

    var _opts$onComment;

    (_opts$onComment = opts.onComment).push.apply(_opts$onComment, ast.comments);
  }

  return ast.program;
}
1278618
function parse(params) {
  var opts = {};
  var tokens = params.split(/,(?=(?:[^"]|"[^"]*")*$)/);
  for (var i = 0, len = tokens.length; i < len; i++) {
    var param = /(\w+)=["]?([^"]+)["]?$/.exec(tokens[i])
    if (param) {
      opts[param[1]] = param[2];
    }
  }
  return opts;
}
1105761
function parseFunctionSourceElements() {
        var sourceElement, sourceElements = [], token, directive, firstRestricted,
            oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken;

        startToken = lookahead;
        expect('{');

        while (index < length) {
            if (lookahead.type !== Token.StringLiteral) {
                break;
            }
            token = lookahead;

            sourceElement = parseSourceElement();
            sourceElements.push(sourceElement);
            if (sourceElement.expression.type !== Syntax.Literal) {
                // this is not directive
                break;
            }
            directive = source.slice(token.start + 1, token.end - 1);
            if (directive === 'use strict') {
                strict = true;
                if (firstRestricted) {
                    throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
                }
            } else {
                if (!firstRestricted && token.octal) {
                    firstRestricted = token;
                }
            }
        }

        oldLabelSet = state.labelSet;
        oldInIteration = state.inIteration;
        oldInSwitch = state.inSwitch;
        oldInFunctionBody = state.inFunctionBody;

        state.labelSet = {};
        state.inIteration = false;
        state.inSwitch = false;
        state.inFunctionBody = true;

        while (index < length) {
            if (match('}')) {
                break;
            }
            sourceElement = parseSourceElement();
            if (typeof sourceElement === 'undefined') {
                break;
            }
            sourceElements.push(sourceElement);
        }

        expect('}');

        state.labelSet = oldLabelSet;
        state.inIteration = oldInIteration;
        state.inSwitch = oldInSwitch;
        state.inFunctionBody = oldInFunctionBody;

        return delegate.markEnd(delegate.createBlockStatement(sourceElements), startToken);
    }
1253025
function parse(text) {
    const ast = remark.parse(text);
    const src = new StructuredSource(text);
    traverse(ast).forEach(function(node) {
        // eslint-disable-next-line no-invalid-this
        if (this.notLeaf) {
            if (node.type) {
                const replacedType = SyntaxMap[node.type];
                if (!replacedType) {
                    debug(`replacedType : ${replacedType} , node.type: ${node.type}`);
                } else {
                    node.type = replacedType;
                }
            }
            // map `range`, `loc` and `raw` to node
            if (node.position) {
                const position = node.position;
                const positionCompensated = {
                    start: { line: position.start.line, column: position.start.column - 1 },
                    end: { line: position.end.line, column: position.end.column - 1 }
                };
                const range = src.locationToRange(positionCompensated);
                node.loc = positionCompensated;
                node.range = range;
                node.raw = text.slice(range[0], range[1]);
                // Compatible for https://github.com/wooorm/unist, but hidden
                Object.defineProperty(node, "position", {
                    enumerable: false,
                    configurable: false,
                    writable: false,
                    value: position
                });
            }
        }
    });
    return ast;
}
1229227
function(ast) {
    if (ast) {
        try {
            var doc = reader.parse(ast.lines);
        } catch(e) {
            console.error(e.stack);
            console.log('Source : \n* ' + ast.lines.join('\n* '));
            return;
        }
        this.summary = doc.summary;
        this.tags = {};
        this.annotations = [];
        for(var i = 0; i < doc.body.length; i++) {
            var child = doc.body[i];
            if (child.kind === 'annotation') {
                this.annotations.push(child);
            } else {
                var name = child.kind.toLowerCase();
                if (typeof child.name === 'string') {
                    name = child.name.toLowerCase();
                }
                if (!this.tags.hasOwnProperty(name)) {
                    this.tags[name] = [];
                }
                this.tags[name].push(child);
            }
        }
    }
}
46245
function parseStyles(inlineStyles) {
  var styles = {};

  if(_.isUndefined(inlineStyles)) {
    return styles;
  }
  var styleRules = inlineStyles.split(';');
  _(styleRules).each(function(style) {
    var keyValue = style.split(':');
    if(keyValue.length == 2) {
      styles[keyValue[0].replace(/[\s]/g, '')] = keyValue[1];
    }
  });
  return styles;
}
252252
def parse(str)
      @document = AST::Document.new(file_path: file_path)
      @root = @document.root

      @dependency_paths = []

      if str.is_a?(Array)
        reset(str, [[@root]])
      else
        reset(str.split(/\r?\n/, -1), [[@root]]) # -1 is for not suppressing empty lines
      end

      parse_line while next_line

      reset

      @document
    end
493871
function parseArguments() {
        var args = [];

        expect('(');

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

        expect(')');

        return args;
    }