<commit_before>#
# TreeFragments - parsing of strings to trees
#

"""
Support for parsing strings into code trees.
"""

from __future__ import absolute_import

import re
from StringIO import StringIO

from .Scanning import PyrexScanner, StringSourceDescriptor
from .Symtab import ModuleScope
from . import PyrexTypes
from .Visitor import VisitorTransform
from .Nodes import Node, StatListNode
from .ExprNodes import NameNode
from . import Parsing
from . import Main
from . import UtilNodes


class StringParseContext(Main.Context):
    def __init__(self, name, include_directories=None, compiler_directives=None):
        if include_directories is None:
            include_directories = []
        if compiler_directives is None:
            compiler_directives = {}
        Main.Context.__init__(self, include_directories, compiler_directives,
                              create_testscope=False)
        self.module_name = name

    def find_module(self, module_name, relative_to=None, pos=None, need_pxd=1):
        if module_name not in (self.module_name, 'cython'):
            raise AssertionError("Not yet supporting any cimports/includes from string code snippets")
        return ModuleScope(module_name, parent_module=None, context=self)


def parse_from_strings(name, code, pxds={}, level=None, initial_pos=None,<commit_msg>fix compiler crash due to missing parameter in subtype signature<commit_after>#
# TreeFragments - parsing of strings to trees
#

"""
Support for parsing strings into code trees.
"""

from __future__ import absolute_import

import re
from StringIO import StringIO

from .Scanning import PyrexScanner, StringSourceDescriptor
from .Symtab import ModuleScope
from . import PyrexTypes
from .Visitor import VisitorTransform
from .Nodes import Node, StatListNode
from .ExprNodes import NameNode
from . import Parsing
from . import Main
from . import UtilNodes


class StringParseContext(Main.Context):
    def __init__(self, name, include_directories=None, compiler_directives=None):
        if include_directories is None:
            include_directories = []
        if compiler_directives is None:
            compiler_directives = {}
        Main.Context.__init__(self, include_directories, compiler_directives,
                              create_testscope=False)
        self.module_name = name

    def find_module(self, module_name, relative_to=None, pos=None, need_pxd=1, absolute_fallback=True):
        if module_name not in (self.module_name, 'cython'):
            raise AssertionError("Not yet supporting any cimports/includes from string code snippets")
        return ModuleScope(module_name, parent_module=None, context=self)


def parse_from_strings(name, code, pxds={}, level=None, initial_pos=None,
{'fraction_non_alphanumeric': 0.06911604219716261, 'fraction_numerical': 0.0007275372862859222, 'mean_word_length': 3.919499105545617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1760092', 'n_tokens_mistral': 752, 'n_tokens_neox': 736, 'n_words': 235}