Python 2.4- doesn't have condition expresions

This commit is contained in:
rocky
2020-01-06 04:43:52 -05:00
parent 444bab760b
commit 67c047df75
2 changed files with 9 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2017 Rocky Bernstein
# Copyright (c) 2016-2017, 2020 Rocky Bernstein
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
@@ -19,9 +19,6 @@ class Python21Parser(Python22Parser):
for ::= SETUP_LOOP expr for_iter store
l_stmts_opt _jump_back
POP_BLOCK COME_FROM
expr ::= conditional
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
"""
def p_import21(self, args):

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2018 Rocky Bernstein
# Copyright (c) 2016-2018, 2020 Rocky Bernstein
"""
spark grammar differences over Python2.5 for Python 2.4.
"""
@@ -56,6 +56,12 @@ class Python24Parser(Python25Parser):
kv2 ::= DUP_TOP expr expr ROT_THREE STORE_SUBSCR
'''
def remove_rules_24(self):
self.remove_rules("""
expr ::= conditional
""")
def customize_grammar_rules(self, tokens, customize):
self.remove_rules("""
gen_comp_body ::= expr YIELD_VALUE POP_TOP
@@ -72,6 +78,7 @@ class Python24Parser(Python25Parser):
stmt ::= withasstmt
""")
super(Python24Parser, self).customize_grammar_rules(tokens, customize)
self.remove_rules_24()
if self.version == 2.4:
self.check_reduce['nop_stmt'] = 'tokens'