ยปCore Development>Code coverage>Lib/lib2to3/pygram.py

Python code coverage for Lib/lib2to3/pygram.py

#countcontent
1n/a# Copyright 2006 Google, Inc. All Rights Reserved.
2n/a# Licensed to PSF under a Contributor Agreement.
3n/a
4n/a"""Export the Python grammar and symbols."""
5n/a
6n/a# Python imports
7n/aimport os
8n/a
9n/a# Local imports
10n/afrom .pgen2 import token
11n/afrom .pgen2 import driver
12n/afrom . import pytree
13n/a
14n/a# The grammar file
15n/a_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
16n/a_PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
17n/a "PatternGrammar.txt")
18n/a
19n/a
20n/aclass Symbols(object):
21n/a
22n/a def __init__(self, grammar):
23n/a """Initializer.
24n/a
25n/a Creates an attribute for each grammar symbol (nonterminal),
26n/a whose value is the symbol's type (an int >= 256).
27n/a """
28n/a for name, symbol in grammar.symbol2number.items():
29n/a setattr(self, name, symbol)
30n/a
31n/a
32n/apython_grammar = driver.load_grammar(_GRAMMAR_FILE)
33n/a
34n/apython_symbols = Symbols(python_grammar)
35n/a
36n/apython_grammar_no_print_statement = python_grammar.copy()
37n/adel python_grammar_no_print_statement.keywords["print"]
38n/a
39n/apattern_grammar = driver.load_grammar(_PATTERN_GRAMMAR_FILE)
40n/apattern_symbols = Symbols(pattern_grammar)