diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c106bc6..a635e58 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9.0-rc - 3.9, pypy3] + python-version: [3.6, 3.7, 3.8, 3.9.0-rc - 3.9, pypy3] steps: - uses: actions/checkout@v2 diff --git a/lark/lexer.py b/lark/lexer.py index 77f7090..1b5250e 100644 --- a/lark/lexer.py +++ b/lark/lexer.py @@ -3,7 +3,7 @@ import re from contextlib import suppress -from .utils import classify, get_regexp_width, Py36, Serialize +from .utils import classify, get_regexp_width, Serialize from .exceptions import UnexpectedCharacters, LexError, UnexpectedToken ###{standalone @@ -38,19 +38,10 @@ class Pattern(Serialize): def max_width(self): raise NotImplementedError() - if Py36: - # Python 3.6 changed syntax for flags in regular expression - def _get_flags(self, value): - for f in self.flags: - value = ('(?%s:%s)' % (f, value)) - return value - - else: - def _get_flags(self, value): - for f in self.flags: - value = ('(?%s)' % f) + value - return value - + def _get_flags(self, value): + for f in self.flags: + value = ('(?%s:%s)' % (f, value)) + return value class PatternStr(Pattern): diff --git a/lark/load_grammar.py b/lark/load_grammar.py index cb8856b..d3c310d 100644 --- a/lark/load_grammar.py +++ b/lark/load_grammar.py @@ -9,7 +9,7 @@ from ast import literal_eval from numbers import Integral from contextlib import suppress -from .utils import bfs, Py36, logger, classify_bool, is_id_continue, is_id_start, bfs_all_unique +from .utils import bfs, logger, classify_bool, is_id_continue, is_id_start, bfs_all_unique from .lexer import Token, TerminalDef, PatternStr, PatternRE from .parse_tree_builder import ParseTreeBuilder @@ -475,18 +475,7 @@ class PrepareLiterals(Transformer_InPlace): def _make_joined_pattern(regexp, flags_set): - # In Python 3.6, a new syntax for flags was introduced, that allows us to restrict the scope - # of flags to a specific regexp group. We are already using it in `lexer.Pattern._get_flags` - # However, for prior Python versions, we still need to use global flags, so we have to make sure - # that there are no flag collisions when we merge several terminals. - flags = () - if not Py36: - if len(flags_set) > 1: - raise GrammarError("Lark doesn't support joining terminals with conflicting flags in python <3.6!") - elif len(flags_set) == 1: - flags ,= flags_set - - return PatternRE(regexp, flags) + return PatternRE(regexp, ()) class TerminalTreeToPattern(Transformer): diff --git a/lark/utils.py b/lark/utils.py index 47fe5ca..c210dca 100644 --- a/lark/utils.py +++ b/lark/utils.py @@ -13,8 +13,6 @@ logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.CRITICAL) -Py36 = (sys.version_info[:2] >= (3, 6)) - NO_VALUE = object() diff --git a/tests/test_parser.py b/tests/test_parser.py index ff4e064..ac409b3 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -8,7 +8,7 @@ import os import sys from copy import copy, deepcopy -from lark.utils import Py36, isascii +from lark.utils import isascii from lark import Token, Transformer_NonRecursive, LexError @@ -1545,7 +1545,6 @@ def _make_parser_test(LEXER, PARSER): self.assertEqual( g.parse('"hello"').children, ['"hello"']) self.assertEqual( g.parse("'hello'").children, ["'hello'"]) - @unittest.skipIf(not Py36, "Required re syntax only exists in python3.6+") def test_join_regex_flags(self): g = r""" start: A diff --git a/tox.ini b/tox.ini index ef19e2c..33f9f64 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,12 @@ [tox] -envlist = py27, py34, py35, py36, py37, py38, py39, pypy, pypy3 +envlist = py36, py37, py38, py39, pypy, pypy3 skip_missing_interpreters=true [travis] -2.7 = py27 -3.4 = py34 -3.5 = py35 3.6 = py36 3.7 = py37 3.8 = py38 3.9 = py39 -pypy = pypy pypy3 = pypy3 [testenv]