def run_poodle_lex(self, language): output_dir = tempfile.mkdtemp() rules_file_path = os.path.join(base_directory, "Example", "CLexer", "CLexer.rules") rules_file = RulesFile.Parser.parse(rules_file_path, "utf-8") rules_file.accept(RulesFile.Traverser(RulesFile.Validator())) nfa_ir = RulesFile.NonDeterministicIR(rules_file) dfa_ir = RulesFile.DeterministicIR(nfa_ir) plugin_file_path = os.path.join(base_directory, "Plugins/Plugins.json") language_plugins, default_language = LanguagePlugins.load(plugin_file_path, 'utf-8') language_plugins[language].load() language_plugin = language_plugins[language] representation = dfa_ir if language_plugin.default_form == LanguagePlugins.PluginOptions.NFA_IR: representation = nfa_ir plugin_options = LanguagePlugins.PluginOptions() emitter = language_plugin.create(representation, plugin_options) executor = LanguagePlugins.Executor(emitter, language_plugin.plugin_files_directory, output_dir) executor.execute() return output_dir
print(" default Use the default specified for the language") # Check minimizer if arguments.minimizer not in minimizers: print("Minimizer '%s' not recognized\n" % arguments.minimizer, file=sys.stderr) sys.exit(1) minimizer_description, minimizer = minimizers[arguments.minimizer] # Load language plug-ins file and list languages if requested language_plugins = None default_language = None plugin_file = os.path.join(this_folder, "Plugins/Plugins.json") try: if arguments.plugin_file is not None: plugin_file = arguments.plugin_file language_plugins, default_language = LanguagePlugins.load(plugin_file, 'utf-8') except Exception as e: print("Unable to load plug-in file: %s\n" % str(e), file=sys.stderr) sys.exit(1) # Load language plug-in language = arguments.language if language is None: language = default_language try: if language not in language_plugins: raise Exception("Plugin not found") language_plugins[language].load() language_plugin = language_plugins[language] except Exception as e: print("Unable to load language plug-in '%s': %s\n" % (language, str(e)), file=sys.stderr)