import ast


def get_script_ast(parser, path):
    """
    Returns the AST created from the script tag in the CGX file.
    """
    # Read the data from script block
    script_node = parser.root.child_with_tag("script")
    script = script_node.data
    line, _ = script_node.location

    # Create an AST from the script
    script_tree = ast.parse(script, filename=str(path), mode="exec")
    # Make sure that the lineno's match up with the lines in the CGX file
    ast.increment_lineno(script_tree, n=line)
    return script_tree