diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-07-21 12:55:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-07-21 12:55:57 (GMT) |
commit | dd6a4edc4554cdb808f08a9ade7e40ed5addc94d (patch) | |
tree | accdbab3c1fe2e088a6437d5598bc921f22c10b0 /Lib/lib2to3/pgen2/grammar.py | |
parent | afcd5f36f00d3a368004c574642175f623ce8ad4 (diff) | |
download | cpython-dd6a4edc4554cdb808f08a9ade7e40ed5addc94d.zip cpython-dd6a4edc4554cdb808f08a9ade7e40ed5addc94d.tar.gz cpython-dd6a4edc4554cdb808f08a9ade7e40ed5addc94d.tar.bz2 |
merge 2to3 improvments
Diffstat (limited to 'Lib/lib2to3/pgen2/grammar.py')
-rw-r--r-- | Lib/lib2to3/pgen2/grammar.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/lib2to3/pgen2/grammar.py b/Lib/lib2to3/pgen2/grammar.py index b7f867f..26caeb4 100644 --- a/Lib/lib2to3/pgen2/grammar.py +++ b/Lib/lib2to3/pgen2/grammar.py @@ -97,6 +97,19 @@ class Grammar(object): f.close() self.__dict__.update(d) + def copy(self): + """ + Copy the grammar. + """ + new = self.__class__() + for dict_attr in ("symbol2number", "number2symbol", "dfas", "keywords", + "tokens", "symbol2label"): + setattr(new, dict_attr, getattr(self, dict_attr).copy()) + new.labels = self.labels[:] + new.states = self.states[:] + new.start = self.start + return new + def report(self): """Dump the grammar tables to standard output, for debugging.""" from pprint import pprint |