3.4 while1 bug fix

This commit is contained in:
rocky
2018-03-01 18:56:08 -05:00
parent 8d1c454376
commit 452d17a6c3
4 changed files with 37 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
# From 3.4.4 mailcap.py
# Bug was needing a grammar rule to add POP_BLOCK before the end of the while1.
# 3.3 apparently doesn't add this.
def readmailcapfile(line):
while 1:
if not line: break
if line[0] == '#' or line.strip() == '':
continue
if not line:
continue
for j in range(3):
line[j] = line[j].strip()
if '/' in line:
line['/'].append('a')
else:
line['/'] = 'a'
return

View File

@@ -1,4 +1,17 @@
# Copyright (c) 2017 Rocky Bernstein # Copyright (c) 2017-2018 Rocky Bernstein
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
spark grammar differences over Python 3.3 for Python 3.4 spark grammar differences over Python 3.3 for Python 3.4
""" """
@@ -18,6 +31,9 @@ class Python34Parser(Python33Parser):
expr ::= LOAD_ASSERT expr ::= LOAD_ASSERT
while1stmt ::= SETUP_LOOP l_stmts
COME_FROM JUMP_BACK POP_BLOCK COME_FROM_LOOP
# FIXME the below masks a bug in not detecting COME_FROM_LOOP # FIXME the below masks a bug in not detecting COME_FROM_LOOP
# grammar rules with COME_FROM -> COME_FROM_LOOP already exist # grammar rules with COME_FROM -> COME_FROM_LOOP already exist
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
@@ -30,8 +46,9 @@ class Python34Parser(Python33Parser):
""" """
def customize_grammar_rules(self, tokens, customize): def customize_grammar_rules(self, tokens, customize):
# self.remove_rules(""" self.remove_rules("""
# """) while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
""")
super(Python34Parser, self).customize_grammar_rules(tokens, customize) super(Python34Parser, self).customize_grammar_rules(tokens, customize)
return return