# Path: bigrig/parser/parser.py
# class ParseException(Exception):
# class BaseParser(object):
# class Parser(NodeFactory, BaseParser):
#     def __init__(self, token_stream=None):
#     def next(self):
#     def peek(self):
#     def raise_unexpected_token(self, token, expected=None):
#     def expect(self, expected):
#     def has_line_terminator_before_next(self):
#     def expect_semicolon(self):
#     def scan_regexp(self):
#     def scan_regexp_flags(self):
#     def precedence(self, token):
#     def is_unary_op(self, token):
#     def is_comparison_op(self, token):
#     def is_assignment_op(self, token):
#     def is_count_op(self, token):
#     def is_identifier(self, node):
#     def parse_property_assignment(self):
#     def parse_object_literal(self):
#     def parse_array_literal(self):
#     def parse_regexp_literal(self): # seen_equal?
#     def parse_expression(self):
#     def parse_primary_expression(self):
#     def parse_arguments(self):
#     def parse_member_expression(self, allow_call=True):
#     def parse_member_expression_tail(self, allow_call, node):
#     def parse_new_expression(self):
#     def parse_left_hand_side_expression(self):
#     def parse_postfix_expression(self):
#     def parse_unary_expression(self):
#     def parse_binary_operator_expression(self, lhs, min_precedence=4):
#     def parse_assignment_expression(self):
#     def parse_conditional_expression(self):
#     def parse_statement(self):
#     def parse_block_statement(self):
#     def parse_variable_statement(self):
#     def parse_variable_declarations(self):
#     def parse_empty_statement(self):
#     def parse_expression_statement(self):
#     def parse_labelled_statement(self):
#     def parse_if_statement(self):
#     def parse_do_while_statement(self):
#     def parse_while_statement(self):
#     def parse_for_statement(self):
#     def parse_continue_statement(self):
#     def parse_break_statement(self):
#     def parse_return_statement(self):
#     def parse_with_statement(self):
#     def parse_case_clause(self):
#     def parse_switch_statement(self):
#     def parse_throw_statement(self):
#     def parse_try_statement(self):
#     def parse_function_declaration(self):
#     def parse_function_expression(self):
#     def parse_function(self, require_name=False):
#     def parse_parameter_list(self):
#     def parse_function_body(self):
#     def parse_source_elements(self, until=EOF):
#     def parse_program(self):
#     def parse(self):
# def make_string_parser(string, filename=None, line=0, column=0, encoding='utf-8'):
# def parse_string(string, filename=None, line=0, column=0, encoding='utf-8'):
# def make_file_parser(fd, filename=None, line=0, column=0, encoding='utf-8'):
# def parse_file(filename, line=0, column=0, encoding='utf-8'):
# 
# Path: bigrig/parser/node.py
# class NodeType(type):
# class Node(object):
#     def __new__(cls, name, bases, attrs):
#     def __init__(self, *fields, **attributes):
#     def iter_fields(self):
#     def iter_children(self):
# def copy_node_attrs(source, target):


import types
from functools import wraps
from ..parser import parser, node
    from ..parser.scanner import make_string_scanner, TokenStreamAllowReserved
    from ..parser.scanner import make_file_scanner, TokenStreamAllowReserved

    def get_next_locator(self):
        token = self.token_stream.peek()
        return token.locator

    def wrap_method(self, method):
        """
        Create a new parse method that adds locator information to the node
        it returns.
        """
        @wraps(method)
        def wrapped(self, *args, **kwargs):
            locator = self.get_next_locator()
            result = method(*args, **kwargs)
            if isinstance(result, node.Node):
                result.locator = locator
            return result
        return types.MethodType(wrapped, self)

    def __getattribute__(self, name):
        cache = super(LocatedNodeMixin, self).__getattribute__('_method_cache')
        if name in cache:
            return cache[name]
        elif name.startswith('parse_'):
            original = object.__getattribute__(self, name)
            wrapped = self.wrap_method(original)
            cache[name] = wrapped
            return wrapped
        return super(LocatedNodeMixin, self).__getattribute__(name)


# Path: bigrig/parser/parser.py
# class ParseException(Exception):
# class BaseParser(object):
# class Parser(NodeFactory, BaseParser):
#     def __init__(self, token_stream=None):
#     def next(self):
#     def peek(self):
#     def raise_unexpected_token(self, token, expected=None):
#     def expect(self, expected):
#     def has_line_terminator_before_next(self):
#     def expect_semicolon(self):
#     def scan_regexp(self):
#     def scan_regexp_flags(self):
#     def precedence(self, token):
#     def is_unary_op(self, token):
#     def is_comparison_op(self, token):
#     def is_assignment_op(self, token):
#     def is_count_op(self, token):
#     def is_identifier(self, node):
#     def parse_property_assignment(self):
#     def parse_object_literal(self):
#     def parse_array_literal(self):
#     def parse_regexp_literal(self): # seen_equal?
#     def parse_expression(self):
#     def parse_primary_expression(self):
#     def parse_arguments(self):
#     def parse_member_expression(self, allow_call=True):
#     def parse_member_expression_tail(self, allow_call, node):
#     def parse_new_expression(self):
#     def parse_left_hand_side_expression(self):
#     def parse_postfix_expression(self):
#     def parse_unary_expression(self):
#     def parse_binary_operator_expression(self, lhs, min_precedence=4):
#     def parse_assignment_expression(self):
#     def parse_conditional_expression(self):
#     def parse_statement(self):
#     def parse_block_statement(self):
#     def parse_variable_statement(self):
#     def parse_variable_declarations(self):
#     def parse_empty_statement(self):
#     def parse_expression_statement(self):
#     def parse_labelled_statement(self):
#     def parse_if_statement(self):
#     def parse_do_while_statement(self):
#     def parse_while_statement(self):
#     def parse_for_statement(self):
#     def parse_continue_statement(self):
#     def parse_break_statement(self):
#     def parse_return_statement(self):
#     def parse_with_statement(self):
#     def parse_case_clause(self):
#     def parse_switch_statement(self):
#     def parse_throw_statement(self):
#     def parse_try_statement(self):
#     def parse_function_declaration(self):
#     def parse_function_expression(self):
#     def parse_function(self, require_name=False):
#     def parse_parameter_list(self):
#     def parse_function_body(self):
#     def parse_source_elements(self, until=EOF):
#     def parse_program(self):
#     def parse(self):
# def make_string_parser(string, filename=None, line=0, column=0, encoding='utf-8'):
# def parse_string(string, filename=None, line=0, column=0, encoding='utf-8'):
# def make_file_parser(fd, filename=None, line=0, column=0, encoding='utf-8'):
# def parse_file(filename, line=0, column=0, encoding='utf-8'):
# 
# Path: bigrig/parser/node.py
# class NodeType(type):
# class Node(object):
#     def __new__(cls, name, bases, attrs):
#     def __init__(self, *fields, **attributes):
#     def iter_fields(self):
#     def iter_children(self):
# def copy_node_attrs(source, target):


# Path: bigrig/interpreter/locator_parser.py
import types
from functools import wraps
from ..parser import parser, node
    from ..parser.scanner import make_string_scanner, TokenStreamAllowReserved
    from ..parser.scanner import make_file_scanner, TokenStreamAllowReserved


    def get_next_locator(self):
        token = self.token_stream.peek()
        return token.locator

    def wrap_method(self, method):
        """
        Create a new parse method that adds locator information to the node
        it returns.
        """
        @wraps(method)
        def wrapped(self, *args, **kwargs):
            locator = self.get_next_locator()
            result = method(*args, **kwargs)
            if isinstance(result, node.Node):
                result.locator = locator
            return result
        return types.MethodType(wrapped, self)

    def __getattribute__(self, name):
        cache = super(LocatedNodeMixin, self).__getattribute__('_method_cache')
        if name in cache:
            return cache[name]
        elif name.startswith('parse_'):
            original = object.__getattribute__(self, name)
            wrapped = self.wrap_method(original)
            cache[name] = wrapped
            return wrapped
        return super(LocatedNodeMixin, self).__getattribute__(name)


class LocatorParser(LocatedNodeMixin, parser.Parser):