Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed May 27, 2024
1 parent 9a38ac8 commit dfbd5b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
matrix:
python-version:
- '2.7'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- 'pypy-2.7'
- 'pypy-3.6'
- 'pypy-3.7'
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions coconut/compiler/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion coconut/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit dfbd5b6

Please sign in to comment.