# Path: scrapers/js2py/translators/friendly_nodes.py
# REGEXP_CONVERTER = PyJsParser()
# 
# Path: scrapers/js2py/prototypes/jsarray.py
# def to_arr(this):
#     def toString():
#             def func():
#     def toLocaleString():
#     def concat():
#     def join(separator):
#     def pop(): #todo check
#     def push(item): # todo check
#     def reverse():
#     def shift():  #todo check
#     def slice(start, end): # todo check
#     def sort(cmpfn):
#     def splice(start, deleteCount):
#     def unshift():
#     def indexOf(searchElement):
#     def lastIndexOf(searchElement):
#     def every(callbackfn):
#     def some(callbackfn):
#     def forEach(callbackfn):
#     def map(callbackfn):
#     def filter(callbackfn):
#     def reduce(callbackfn):
#     def reduceRight(callbackfn):
# def sort_compare(a, b, comp):
# ARR_STACK = set({})
#         A = this.Js([])
#         A = this.Js([])
#             E = items.pop(0)
#             E = items.pop(0)
#         T = arguments[1]
#         T = arguments[1]
#         T = arguments[1]
#         T = arguments[1]
#         A = this.Js([])
#         T = arguments[1]
# class ArrayPrototype:


from copy import copy
from .translators.friendly_nodes import REGEXP_CONVERTER
from .utils.injector import fix_js_args
from types import FunctionType, ModuleType, GeneratorType, BuiltinFunctionType, MethodType, BuiltinMethodType
from .prototypes import jsfunction, jsobject, jsnumber, jsstring, jsboolean, jsarray, jsregexp, jserror
import re
import traceback
import six
    import code
        if not regexp[-1]=='/':
            #contains some flags (allowed are i, g, m
            spl =  regexp.rfind('/')
            flags = set(regexp[spl+1:])
            self.value = regexp[1:spl]
            if 'g' in flags:
                self.glob = True
            if 'i' in flags:
                self.ignore_case = re.IGNORECASE
            if 'm' in flags:
                self.multiline = re.MULTILINE
        else:
            self.value = regexp[1:-1]

        try:
            if self.value in REGEXP_DB:
                self.pat = REGEXP_DB[regexp]
            else:
                comp =  'None'
                # we have to check whether pattern is valid.
                # also this will speed up matching later
                # todo critical fix patter conversion etc. ..!!!!!
                # ugly hacks porting js reg exp to py reg exp works in 99% of cases ;)
                possible_fixes = [
                    (u'[]', u'[\0]'),
                    (u'[^]', u'[^\0]'),
                    (u'nofix1791', u'nofix1791')
                ]
                reg = self.value
                for fix, rep in possible_fixes:

# Path: scrapers/js2py/translators/friendly_nodes.py
# REGEXP_CONVERTER = PyJsParser()
# 
# Path: scrapers/js2py/prototypes/jsarray.py
# def to_arr(this):
#     def toString():
#             def func():
#     def toLocaleString():
#     def concat():
#     def join(separator):
#     def pop(): #todo check
#     def push(item): # todo check
#     def reverse():
#     def shift():  #todo check
#     def slice(start, end): # todo check
#     def sort(cmpfn):
#     def splice(start, deleteCount):
#     def unshift():
#     def indexOf(searchElement):
#     def lastIndexOf(searchElement):
#     def every(callbackfn):
#     def some(callbackfn):
#     def forEach(callbackfn):
#     def map(callbackfn):
#     def filter(callbackfn):
#     def reduce(callbackfn):
#     def reduceRight(callbackfn):
# def sort_compare(a, b, comp):
# ARR_STACK = set({})
#         A = this.Js([])
#         A = this.Js([])
#             E = items.pop(0)
#             E = items.pop(0)
#         T = arguments[1]
#         T = arguments[1]
#         T = arguments[1]
#         T = arguments[1]
#         A = this.Js([])
#         T = arguments[1]
# class ArrayPrototype:


# Path: scrapers/js2py/base.py
from copy import copy
from .translators.friendly_nodes import REGEXP_CONVERTER
from .utils.injector import fix_js_args
from types import FunctionType, ModuleType, GeneratorType, BuiltinFunctionType, MethodType, BuiltinMethodType
from .prototypes import jsfunction, jsobject, jsnumber, jsstring, jsboolean, jsarray, jsregexp, jserror
import re
import traceback
import six
    import code

        if not regexp[-1]=='/':
            #contains some flags (allowed are i, g, m
            spl =  regexp.rfind('/')
            flags = set(regexp[spl+1:])
            self.value = regexp[1:spl]
            if 'g' in flags:
                self.glob = True
            if 'i' in flags:
                self.ignore_case = re.IGNORECASE
            if 'm' in flags:
                self.multiline = re.MULTILINE
        else:
            self.value = regexp[1:-1]

        try:
            if self.value in REGEXP_DB:
                self.pat = REGEXP_DB[regexp]
            else:
                comp =  'None'
                # we have to check whether pattern is valid.
                # also this will speed up matching later
                # todo critical fix patter conversion etc. ..!!!!!
                # ugly hacks porting js reg exp to py reg exp works in 99% of cases ;)
                possible_fixes = [
                    (u'[]', u'[\0]'),
                    (u'[^]', u'[^\0]'),
                    (u'nofix1791', u'nofix1791')
                ]
                reg = self.value
                for fix, rep in possible_fixes:

                    comp = REGEXP_CONVERTER._interpret_regexp(reg, flags)