diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3065514a1..213772d96 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,7 +7,6 @@ jobs: matrix: python-version: - '2.7' - - '3.5' - '3.6' - '3.7' - '3.8' @@ -15,6 +14,7 @@ jobs: - '3.10' - '3.11' - '3.12' + - '3.13' - 'pypy-2.7' - 'pypy-3.6' - 'pypy-3.7' @@ -24,9 +24,9 @@ jobs: fail-fast: false name: Python ${{ matrix.python-version }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup python - uses: MatteoH2O1999/setup-python@v2 + uses: MatteoH2O1999/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: pip diff --git a/coconut/compiler/util.py b/coconut/compiler/util.py index 1f8f1297d..196e98350 100644 --- a/coconut/compiler/util.py +++ b/coconut/compiler/util.py @@ -624,18 +624,24 @@ def with_start_marker(self): internal_assert(not CPYPARSING, "StartOfStrGrammar.with_start_marker() should only be necessary without cPyparsing") return self.start_marker + self.grammar + def apply(self, grammar_transformer): + """Apply a function to transform the grammar.""" + self.grammar = grammar_transformer(self.grammar) + @property def name(self): return get_name(self.grammar) -def prep_grammar(grammar, for_scan, streamline=False): +def prep_grammar(grammar, for_scan, streamline=False, unpack=False): """Prepare a grammar item to be used as the root of a parse.""" if isinstance(grammar, StartOfStrGrammar): if for_scan: grammar = grammar.with_start_marker() else: grammar = grammar.grammar + if unpack: + grammar = add_action(grammar, unpack) grammar = trace(grammar) if streamline: grammar.streamlined = False @@ -701,7 +707,7 @@ def transform(grammar, text, inner=None): grammar = grammar.grammar kwargs["maxStartLoc"] = 0 with parsing_context(inner): - result = prep_grammar(add_action(grammar, unpack), for_scan=True).transformString(text, **kwargs) + result = prep_grammar(grammar, unpack=True, for_scan=True).transformString(text, **kwargs) if result == text: result = None return result diff --git a/coconut/root.py b/coconut/root.py index e5b901fca..5060cca35 100644 --- a/coconut/root.py +++ b/coconut/root.py @@ -26,7 +26,7 @@ VERSION = "3.1.0" VERSION_NAME = None # False for release, int >= 1 for develop -DEVELOP = 12 +DEVELOP = 13 ALPHA = False # for pre releases rather than post releases assert DEVELOP is False or DEVELOP >= 1, "DEVELOP must be False or an int >= 1"