Go over grammars..

* Reduce duplication
* Remove unused grammar rules
* Add grammar checking when parsers run as standalone
This commit is contained in:
rocky
2016-06-17 22:59:17 -04:00
parent c4912be570
commit 724faf9a3a
5 changed files with 61 additions and 86 deletions

View File

@@ -1,7 +1,7 @@
# Copyright (c) 1999 John Aycock
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2015, 2016 Rocky Bernstein
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
# Copyright (c) 1999 John Aycock
#
# See LICENSE for license
"""
@@ -111,23 +111,6 @@ class Python3Parser(PythonParser):
else_suitec ::= c_stmts
else_suitec ::= return_stmts
designList ::= designator designator
designList ::= designator DUP_TOP designList
designator ::= STORE_FAST
designator ::= STORE_NAME
designator ::= STORE_GLOBAL
designator ::= STORE_DEREF
designator ::= expr STORE_ATTR
designator ::= expr STORE_SLICE+0
designator ::= expr expr STORE_SLICE+1
designator ::= expr expr STORE_SLICE+2
designator ::= expr expr expr STORE_SLICE+3
designator ::= store_subscr
store_subscr ::= expr expr STORE_SUBSCR
designator ::= unpack
designator ::= unpack_list
stmt ::= classdef
stmt ::= call_stmt
@@ -170,7 +153,6 @@ class Python3Parser(PythonParser):
stmt ::= ifelsestmt
stmt ::= whilestmt
stmt ::= whilenotstmt
stmt ::= while1stmt
stmt ::= whileelsestmt
stmt ::= while1elsestmt
@@ -646,3 +628,8 @@ class Python34ParserSingle(Python34Parser, PythonParserSingle):
class Python35onParserSingle(Python35onParser, PythonParserSingle):
pass
if __name__ == '__main__':
# Check grammar
p = Python3Parser()
p.checkGrammar()