m2isar.frontends.coredsl2.importer

Classes to recursively import files of a CoreDSL model.

Classes

Importer

ANTLR listener based importer. Bad on performance, as it traverses

VisitImporter

Importer class based on an ANTLR Visitor. Only traverses the model tree

ImportPathExtender

ANTLR visitor to resolve relative import paths. Replaces all import URIs

Functions

recursive_import(tree, search_path)

Helper method to recursively process all import statements of a given

Module Contents

class Importer(search_path)[source]

Bases: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Listener

Inheritance diagram of m2isar.frontends.coredsl2.importer.Importer

ANTLR listener based importer. Bad on performance, as it traverses the entire parse tree when it only has to look for import statements.

imported[source]
new_children = [][source]
new_defs = [][source]
got_new = True[source]
search_path[source]
enterImport_file(ctx: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Parser.Import_fileContext)[source]

The actual import functionality. Extracts the filename to import, constructs a new parser and parses the next file.

recursive_import(tree, search_path)[source]

Helper method to recursively process all import statements of a given parse tree. The search path should be set to the directory of the root document.

class VisitImporter(search_path)[source]

Bases: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Visitor

Inheritance diagram of m2isar.frontends.coredsl2.importer.VisitImporter

Importer class based on an ANTLR Visitor. Only traverses the model tree to the import statements and stops traversion after that.

imported[source]
new_children = [][source]
new_imports = [][source]
new_defs = [][source]
got_new = True[source]
search_path[source]
logger[source]
visitDescription_content(ctx: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Parser.Description_contentContext)[source]
visitImport_file(ctx: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Parser.Import_fileContext)[source]

The actual import functionality. Extracts the filename to import, constructs a new parser and parses the next file.

class ImportPathExtender(search_path: pathlib.Path)[source]

Bases: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Visitor

Inheritance diagram of m2isar.frontends.coredsl2.importer.ImportPathExtender

ANTLR visitor to resolve relative import paths. Replaces all import URIs with their equivalent absolute path, relative to search_path.

search_path[source]
visitDescription_content(ctx: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Parser.Description_contentContext)[source]
visitImport_file(ctx: m2isar.frontends.coredsl2.parser_gen.CoreDSL2Parser.Import_fileContext)[source]