From 9b7bda28db0200b628e5f6eb7021a5a717db2e73 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 14 Dec 2025 19:59:18 +0100 Subject: Initial grammar --- bindings/python/tree_sitter_wmap/__init__.py | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 bindings/python/tree_sitter_wmap/__init__.py (limited to 'bindings/python/tree_sitter_wmap/__init__.py') diff --git a/bindings/python/tree_sitter_wmap/__init__.py b/bindings/python/tree_sitter_wmap/__init__.py new file mode 100644 index 0000000..fa35926 --- /dev/null +++ b/bindings/python/tree_sitter_wmap/__init__.py @@ -0,0 +1,43 @@ +"""Parser for wmap Formatted Wardley Maps""" + +from importlib.resources import files as _files + +from ._binding import language + + +def _get_query(name, file): + try: + query = _files(f"{__package__}") / file + globals()[name] = query.read_text() + except FileNotFoundError: + globals()[name] = None + return globals()[name] + + +def __getattr__(name): + if name == "HIGHLIGHTS_QUERY": + return _get_query("HIGHLIGHTS_QUERY", "queries/highlights.scm") + if name == "INJECTIONS_QUERY": + return _get_query("INJECTIONS_QUERY", "queries/injections.scm") + if name == "LOCALS_QUERY": + return _get_query("LOCALS_QUERY", "queries/locals.scm") + if name == "TAGS_QUERY": + return _get_query("TAGS_QUERY", "queries/tags.scm") + + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + + +__all__ = [ + "language", + "HIGHLIGHTS_QUERY", + "INJECTIONS_QUERY", + "LOCALS_QUERY", + "TAGS_QUERY", +] + + +def __dir__(): + return sorted(__all__ + [ + "__all__", "__builtins__", "__cached__", "__doc__", "__file__", + "__loader__", "__name__", "__package__", "__path__", "__spec__", + ]) -- cgit