def prepare_context(grammar=None, lexer=None, lkt_file=None, warning_set=default_warning_set, symbol_canonicalizer=None, show_property_logging=False, types_from_lkt=False, lkt_semantic_checks=False, case_insensitive: bool = False, version: Optional[str] = None, build_date: Optional[str] = None, standalone: bool = False): """ Create a compile context and prepare the build directory for code generation. :param langkit.parsers.Grammar grammar: The language grammar to use for this context. :param langkit.lexer.Lexer lexer: The language lexer to use for this context. :param str|None lkt_file: If provided, file from which to read the Lkt language spec. :param WarningSet warning_set: Set of warnings to emit. :param langkit.compile_context.LibraryEntity|None symbol_canonicalizer: Symbol canonicalizer to use for this context, if any. :param bool show_property_logging: See CompileCtx.show_property_logging. :param bool types_from_lkt: See CompileCtx.types_from_lkt. :param case_insensitive: See CompileCtx's constructor. :param version: See CompileCtx's constructor. :param build_date: See CompileCtx's constructor. :param standalone: See CompileCtx's constructor. """ # Have a clean build directory if P.exists('build'): shutil.rmtree('build') os.mkdir('build') # Try to emit code ctx = CompileCtx(lang_name='Foo', short_name='foo', lexer=lexer, grammar=grammar, symbol_canonicalizer=symbol_canonicalizer, show_property_logging=show_property_logging, lkt_file=lkt_file, types_from_lkt=types_from_lkt, lkt_semantic_checks=lkt_semantic_checks, case_insensitive=case_insensitive, version=version, build_date=build_date, standalone=standalone) ctx.warnings = warning_set ctx.pretty_print = pretty_print return ctx
def prepare_context(grammar, lexer=None, warning_set=default_warning_set): """ Create a compile context and prepare the build directory for code generation. :param langkit.parsers.Grammar grammar: The language grammar to use for this context. :param langkit.lexer.Lexer lexer: The language lexer to use for this context. :param WarningSet warning_set: Set of warnings to emit. """ if lexer is None: from lexer_example import foo_lexer lexer = foo_lexer # Have a clean build directory if os.path.exists('build'): shutil.rmtree('build') os.mkdir('build') # Try to emit code ctx = CompileCtx(lang_name='Foo', lexer=lexer, grammar=grammar) ctx.warnings = warning_set ctx.pretty_print = pretty_print return ctx
def prepare_context(grammar=None, lexer=None, lkt_file=None, warning_set=default_warning_set, symbol_canonicalizer=None, show_property_logging=False): """ Create a compile context and prepare the build directory for code generation. :param langkit.parsers.Grammar grammar: The language grammar to use for this context. :param langkit.lexer.Lexer lexer: The language lexer to use for this context. :param str|None lkt_file: If provided, file from which to read the Lkt language spec. :param WarningSet warning_set: Set of warnings to emit. :param langkit.compile_context.LibraryEntity|None symbol_canonicalizer: Symbol canonicalizer to use for this context, if any. :param bool show_property_logging: See CompileCtx.show_property_logging. """ # Have a clean build directory if P.exists('build'): shutil.rmtree('build') os.mkdir('build') # Try to emit code ctx = CompileCtx(lang_name='Foo', short_name='Foo', lexer=lexer, grammar=grammar, symbol_canonicalizer=symbol_canonicalizer, show_property_logging=show_property_logging, lkt_file=lkt_file) ctx.warnings = warning_set ctx.pretty_print = pretty_print return ctx