From 17d626bc73461a6eab8b101021f66b59a9aa40be Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 13 May 2019 22:23:06 +0200 Subject: [PATCH] Align overlap condition on java implementation --- runtime/Python2/src/antlr4/TokenStreamRewriter.py | 3 +-- runtime/Python3/src/antlr4/TokenStreamRewriter.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/Python2/src/antlr4/TokenStreamRewriter.py b/runtime/Python2/src/antlr4/TokenStreamRewriter.py index 1adf82ef8..4d793aa5c 100644 --- a/runtime/Python2/src/antlr4/TokenStreamRewriter.py +++ b/runtime/Python2/src/antlr4/TokenStreamRewriter.py @@ -157,13 +157,12 @@ class TokenStreamRewriter(object): rewrites[prevRop.instructionIndex] = None continue isDisjoint = any((prevRop.last_index < rop.index, prevRop.index > rop.last_index)) - isSame = all((prevRop.index == rop.index, prevRop.last_index == rop.last_index)) if all((prevRop.text is None, rop.text is None, not isDisjoint)): rewrites[prevRop.instructionIndex] = None rop.index = min(prevRop.index, rop.index) rop.last_index = min(prevRop.last_index, rop.last_index) print('New rop {}'.format(rop)) - elif (not(isDisjoint) and not(isSame)): + elif ( not(isDisjoint) ): raise ValueError("replace op boundaries of {} overlap with previous {}".format(rop, prevRop)) # Walk inserts before diff --git a/runtime/Python3/src/antlr4/TokenStreamRewriter.py b/runtime/Python3/src/antlr4/TokenStreamRewriter.py index bed274c65..d2ee173db 100644 --- a/runtime/Python3/src/antlr4/TokenStreamRewriter.py +++ b/runtime/Python3/src/antlr4/TokenStreamRewriter.py @@ -156,13 +156,12 @@ class TokenStreamRewriter(object): rewrites[prevRop.instructionIndex] = None continue isDisjoint = any((prevRop.last_indexrop.last_index)) - isSame = all((prevRop.index == rop.index, prevRop.last_index == rop.last_index)) if all((prevRop.text is None, rop.text is None, not isDisjoint)): rewrites[prevRop.instructionIndex] = None rop.index = min(prevRop.index, rop.index) rop.last_index = min(prevRop.last_index, rop.last_index) print('New rop {}'.format(rop)) - elif (not(isDisjoint) and not(isSame)): + elif ( not(isDisjoint) ): raise ValueError("replace op boundaries of {} overlap with previous {}".format(rop, prevRop)) # Walk inserts