Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parser update #1496

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion jac/jaclang/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import sys

from jaclang.utils.helpers import auto_generate_refs
from jaclang.utils.helpers import auto_generate_refs, check_version
from jaclang.vendor.lark.tools import standalone


Expand Down Expand Up @@ -37,6 +37,8 @@ def generate_static_parser(force: bool = False) -> None:

try:
from jaclang.compiler.generated import jac_parser as jac_lark

generate_static_parser(force=check_version())
except ModuleNotFoundError:
generate_static_parser(force=True)
from jaclang.compiler.generated import jac_parser as jac_lark
Expand Down
15 changes: 15 additions & 0 deletions jac/jaclang/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,21 @@ def pretty_print_source_location(
return pretty_dump[:-1] # Get rid of the last newline (of the last line).


def check_version() -> bool:
"""Check if the installed version of JacLang is outdated."""
import tomllib

file_path = os.path.join(os.getcwd(), "..", "..", "Jaseci/jac/pyproject.toml")
file_path = os.path.normpath(file_path)
with open(file_path, "rb") as file:
data = tomllib.load(file)
latest_version = data["tool"]["poetry"]["version"]
from importlib.metadata import version

installed_version = version("jaclang")
return latest_version != installed_version


class Jdb(pdb.Pdb):
"""Jac debugger."""

Expand Down
Loading