Skip to content

Commit 4d8c72a

Browse files
committed
Drop support for Python <= 3.5
This also switches tests from Travis CI to Github Actions.
1 parent 5279385 commit 4d8c72a

File tree

10 files changed

+161
-143
lines changed

10 files changed

+161
-143
lines changed

.flake8

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[flake8]
2+
ignore = E121,E126,E127,E226,W504
23
exclude = .git,__pycache__,build,dist,.eggs,.tox

.github/workflows/test.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- ci
8+
- "releases/*"
9+
pull_request:
10+
branches:
11+
- '*'
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-rc.1]
19+
20+
env:
21+
PIP_DISABLE_PIP_VERSION_CHECK: 1
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Test
30+
run: |
31+
python -m pip install -e .[test]
32+
python -m unittest -v parsing.tests.suite

.travis.yml

-12
This file was deleted.

parsing/__init__.py

+38-41
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@
125125
"Precedence", "Spec", "Token", "Lr", "Glr",
126126
"ModuleSpecSource"]
127127

128-
from six import print_
129-
from six.moves import range
130-
131128
from parsing.errors import (ParsingError, SpecError, # noqa
132129
UnexpectedToken, AnyException) # noqa
133130
from parsing.grammar import (Precedence, Production, SymbolSpec, # noqa
@@ -216,7 +213,7 @@ def eoi(self):
216213
assert self._stack[-1][0] == token # <$>.
217214
if self._verbose:
218215
self._printStack()
219-
print_(" --> accept")
216+
print(" --> accept")
220217
self._stack.pop()
221218

222219
self._start = [self._stack[1][0]]
@@ -225,7 +222,7 @@ def eoi(self):
225222
def _act(self, sym, symSpec):
226223
if self._verbose:
227224
self._printStack()
228-
print_("INPUT: %r" % sym)
225+
print("INPUT: %r" % sym)
229226

230227
while True:
231228
top = self._stack[-1]
@@ -237,7 +234,7 @@ def _act(self, sym, symSpec):
237234
action = actions[0]
238235

239236
if self._verbose:
240-
print_(" --> %r" % action)
237+
print(" --> %r" % action)
241238
if type(action) == ShiftAction:
242239
self._stack.append((sym, action.nextState))
243240
break
@@ -249,16 +246,16 @@ def _act(self, sym, symSpec):
249246
self._printStack()
250247

251248
def _printStack(self):
252-
print_("STACK:", end=' ')
249+
print("STACK:", end=' ')
253250
for node in self._stack:
254-
print_("%r" % node[0], end=' ')
255-
print_()
256-
print_(" ", end=' ')
251+
print("%r" % node[0], end=' ')
252+
print()
253+
print(" ", end=' ')
257254
for node in self._stack:
258-
print_("%r%s" % (
255+
print("%r%s" % (
259256
node[1], (" " * (len("%r" % node[0]) - len("%r" % node[1])))),
260257
end=' ')
261-
print_()
258+
print()
262259

263260
def _reduce(self, production):
264261
nRhs = len(production.rhs)
@@ -411,8 +408,8 @@ def token(self, token):
411408
Feed a token to the parser.
412409
"""
413410
if self._verbose:
414-
print_("%s" % ("-" * 80))
415-
print_("INPUT: %r" % token)
411+
print("%s" % ("-" * 80))
412+
print("INPUT: %r" % token)
416413
tokenSpec = self._spec._sym2spec[type(token)]
417414
self._act(token, tokenSpec)
418415
if len(self._gss) == 0:
@@ -431,7 +428,7 @@ def eoi(self):
431428
for path in top.paths():
432429
assert len(path) == 5
433430
if self._verbose:
434-
print_(" --> accept %r" % path)
431+
print(" --> accept %r" % path)
435432
edge = path[1]
436433
assert isinstance(edge.value, Nonterm)
437434
assert edge.value.symSpec == self._spec._userStartSym
@@ -441,8 +438,8 @@ def eoi(self):
441438
raise UnexpectedToken("Unexpected end of input")
442439

443440
if self._verbose:
444-
print_("Start: %r" % self._start)
445-
print_("%s" % ("-" * 80))
441+
print("Start: %r" % self._start)
442+
print("%s" % ("-" * 80))
446443

447444
def _act(self, sym, symSpec):
448445
self._reductions(sym, symSpec)
@@ -477,37 +474,37 @@ def _reductions(self, sym, symSpec):
477474
epsilons[action.production] = [top]
478475
workQ.append((path, action.production))
479476
if self._verbose:
480-
print_(" --> enqueue(a) %r" %
477+
print(" --> enqueue(a) %r" %
481478
action.production)
482-
print_(" %r" % path)
479+
print(" %r" % path)
483480
elif top not in epsilons[action.production]:
484481
assert len(
485482
[path for path in top.paths(0)]) == 1
486483
path = [p for p in top.paths(0)][0]
487484
epsilons[action.production].append(top)
488485
workQ.append((path, action.production))
489486
if self._verbose:
490-
print_(" --> enqueue(b) %r" %
487+
print(" --> enqueue(b) %r" %
491488
action.production)
492-
print_(" %r" % path)
489+
print(" %r" % path)
493490
else:
494491
# Iterate over all reduction paths through stack
495492
# and enqueue them.
496493
for path in top.paths(len(action.production.rhs)):
497494
workQ.append((path, action.production))
498495
if self._verbose:
499-
print_(" --> enqueue(c) %r" %
496+
print(" --> enqueue(c) %r" %
500497
action.production)
501-
print_(" %r" % path)
498+
print(" %r" % path)
502499
i += 1
503500

504501
# Process the work queue.
505502
while len(workQ) > 0:
506503
(path, production) = workQ.pop(0)
507504

508505
if self._verbose:
509-
print_(" --> reduce %r" % production)
510-
print_(" %r" % path)
506+
print(" --> reduce %r" % production)
507+
print(" %r" % path)
511508
nReduces += 1
512509

513510
self._reduce(workQ, epsilons, path, production, symSpec)
@@ -538,14 +535,14 @@ def _reduce(self, workQ, epsilons, path, production, symSpec):
538535
# There is already a below<--top link, so merge
539536
# competing interpretations.
540537
if self._verbose:
541-
print_(" --> merge %r <--> %r" % (edge.value, r))
538+
print(" --> merge %r <--> %r" % (edge.value, r))
542539
value = production.lhs.nontermType.merge(edge.value, r)
543540
if self._verbose:
544541
if value == edge.value:
545-
print_(" %s" %
542+
print(" %s" %
546543
("-" * len("%r" % edge.value)))
547544
else:
548-
print_(" %s %s" %
545+
print(" %s %s" %
549546
((" " * len("%r" % edge.value)),
550547
"-" * len("%r" % r)))
551548
edge.value = value
@@ -555,7 +552,7 @@ def _reduce(self, workQ, epsilons, path, production, symSpec):
555552
# Create a new below<--top link.
556553
edge = Gsse(below, top, r)
557554
if self._verbose:
558-
print_(" --> shift(b) %r" % top)
555+
print(" --> shift(b) %r" % top)
559556

560557
# Enqueue reduction paths that were created as a result of
561558
# the new link.
@@ -569,7 +566,7 @@ def _reduce(self, workQ, epsilons, path, production, symSpec):
569566
below, r, self._spec._goto[below.nextState][production.lhs])
570567
self._gss.append(top)
571568
if self._verbose:
572-
print_(" --> shift(c) %r" %
569+
print(" --> shift(c) %r" %
573570
self._spec._goto[below.nextState][production.lhs])
574571
self._enqueueLimitedReductions(workQ, epsilons, top.edge, symSpec)
575572

@@ -593,27 +590,27 @@ def _enqueueLimitedReductions(self, workQ, epsilons, edge, symSpec):
593590
epsilons[action.production] = [top]
594591
workQ.append((path, action.production))
595592
if self._verbose:
596-
print_(" --> enqueue(d) %r" %
593+
print(" --> enqueue(d) %r" %
597594
action.production)
598-
print_(" %r" % path)
595+
print(" %r" % path)
599596
elif top not in epsilons[action.production]:
600597
path = [top]
601598
epsilons[action.production].append(top)
602599
workQ.append((path, action.production))
603600
if self._verbose:
604-
print_(" --> enqueue(e) %r" %
601+
print(" --> enqueue(e) %r" %
605602
action.production)
606-
print_(" %r" % path)
603+
print(" %r" % path)
607604
else:
608605
# Iterate over all reduction paths through stack
609606
# and enqueue them if they incorporate edge.
610607
for path in top.paths(len(action.production.rhs)):
611608
if edge in path[1::2]:
612609
workQ.append((path, action.production))
613610
if self._verbose:
614-
print_(" --> enqueue(f) %r" %
611+
print(" --> enqueue(f) %r" %
615612
action.production)
616-
print_(" %r" % path)
613+
print(" %r" % path)
617614

618615
def _shifts(self, sym, symSpec):
619616
prevGss = self._gss
@@ -636,7 +633,7 @@ def _shifts(self, sym, symSpec):
636633
top = Gssn(topA, sym, action.nextState)
637634
self._gss.append(top)
638635
if self._verbose:
639-
print_(" --> shift(a) %d" % action.nextState)
636+
print(" --> shift(a) %d" % action.nextState)
640637
nShifts += 1
641638
if self._verbose:
642639
if nShifts > 0:
@@ -647,10 +644,10 @@ def _printStack(self):
647644
for top in self._gss:
648645
for path in top.paths():
649646
if i == 0:
650-
print_("STK 0:", end=' ')
647+
print("STK 0:", end=' ')
651648
else:
652-
print_(" %d:" % i, end=' ')
649+
print(" %d:" % i, end=' ')
653650
for elm in path:
654-
print_("%r" % elm, end=' ')
655-
print_()
651+
print("%r" % elm, end=' ')
652+
print()
656653
i += 1

0 commit comments

Comments
 (0)