summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/transformer.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove uses of string module and stat.ST_MODENeal Norwitz2002-06-061-2/+1
|
* Fix com_arglist() and update grammar fragment.Jeremy Hylton2002-04-191-6/+3
| | | | | | | | | | | | | | | | | SF bug #522264 reported by Evelyn Mitchell. The code included a comment about "STAR STAR" which was translated into the code as the bogus attribute token.STARSTAR. This name never caused an attribute error because it was never retrieved. The code was based on an old version of the grammar that specified kwargs as two tokens ('*' '*'). I checked as far back as 2.1 and didn't find this production. The fix is simple, because token.DOUBLESTAR is the only token allowed. Also update the grammar fragment in com_arglist(). XXX I'll bet lots of other grammar fragments in comments are out of date, probably in this module and in compile.c.
* Patch #522279: transformer.py nodes shadows global.Martin v. Löwis2002-02-281-3/+3
|
* Merge of the release22 branch changes back into the trunk.Barry Warsaw2001-12-211-1/+1
|
* Whitespace normalization.Tim Peters2001-10-181-9/+9
|
* Handle testlist_safe as if it were testlist.Jeremy Hylton2001-10-171-0/+4
|
* API change:Jeremy Hylton2001-09-171-2/+8
| | | | | | | | | | | | | | | | | | compile() becomes replacement for builtin compile() compileFile() generates a .pyc from a .py both are exported in __init__ compiler.parse() gets optional second argument to specify compilation mode, e.g. single, eval, exec Add AbstractCompileMode as parent class and Module, Expression, and Interactive as concrete subclasses. Each corresponds to a compilation mode. THe AbstractCompileMode instances in turn delegate to CodeGeneration subclasses specialized for their particular functions -- ModuleCodeGenerator, ExpressionCodeGeneration, InteractiveCodeGenerator.
* Last set of change to get regression tests to passJeremy Hylton2001-09-171-0/+4
| | | | | | | | | | | Remove the only test in the syntax module. It ends up that the transformer must handle this error case. In the transformer, check for a list compression in com_assign_list() by looking for a list_for node where a comma is expected. In pycodegen.compile() re-raise the SyntaxError rather than catching it and exiting
* Make sure that atoms (Tuple, List, etc.) have lineno attributesJeremy Hylton2001-08-291-2/+4
|
* Add support for // and //=.Jeremy Hylton2001-08-291-5/+16
| | | | | | | | Avoid if/elif/elif/else tests where the final else is supposed to handle exactly one case instead of all other cases. When the list of operators is extended, the catchall else treats all new operators as the last operator in the set of tests. Instead, raise an exception if an unexpected operator occurs.
* Don't include doc string of class in its code childJeremy Hylton2001-08-291-0/+5
|
* Add lookup_name() to optimize use of stack framesJeremy Hylton2001-08-271-5/+21
| | | | | | | | | | | | The use of com_node() introduces a lot of extra stack frames, enough to cause a stack overflow compiling test.test_parser with the standard interpreter recursionlimit. The com_node() is a convenience function that hides the dispatch details, but comes at a very high cost. It is more efficient to dispatch directly in the callers. In these cases, use lookup_node() and call the dispatched node directly. Also handle yield_stmt in a way that will work with Python 2.1 (suggested by Shane Hathaway)
* Add Yield() statement handlerJeremy Hylton2001-08-181-1/+11
| | | | Fix Module() handler to avoid including the doc string in the AST
* Add lineno attributes to Discard nodesJeremy Hylton2001-04-111-1/+3
|
* Fix "import as" (has always skipping the as name)Jeremy Hylton2001-04-091-9/+15
| | | | | | Fix com_NEWLINE() so that is accepts arguments, which occurs for lines like: stmt; # note trailing semicolon Add XXX about checking for assignment to list comps
* a few small optimizations that seem to give a 5-10% speedup; theJeremy Hylton2000-11-061-76/+80
| | | | further optimization of com_node makes the most difference.
* If a function contains a doc string, remove the doc string node fromJeremy Hylton2000-11-061-1/+5
| | | | | | | the function's body. If assert is used without an error message, make the AST node None rather than Name('None').
* Many changes.Jeremy Hylton2000-10-251-220/+145
| | | | | | | | | | | | | | | | | | | | | Reformatting -- long lines, "[ ]" -> "[]", a few indentation nits. Replace calls to Node function (which constructed ast nodes) with calls to actual constructors imported from ast module. Optimize com_node (most frequently used method) for the common case -- the appropriate method is found in _dispatch. Fix com_augassign to use class object's rather than node names (rendered invalid by recent changes to ast) Remove expensive tests for sequence-ness in com_stmt and com_append_stmt. These tests should never fail; if they do, something is really broken and exception will be raised elsewhere. Fix com_stmt and com_append_stmt to use isinstance rather than testing's type slot of ast node (this slot disappeared with recent changes to ast).
* Now supports entire Python 2.0 language and still supports PythonJeremy Hylton2000-10-131-48/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 1.5.2. The compiler generates code for the version of the interpreter it is run under. ast.py: Print and Printnl add dest attr for extended print new node AugAssign for augmented assignments new nodes ListComp, ListCompFor, and ListCompIf for list comprehensions pyassem.py: add work around for string-Unicode comparison raising UnicodeError on comparison of two objects in code object's const table pycodegen.py: define VERSION, the Python major version number get magic number using imp.get_magic() instead of hard coding implement list comprehensions, extended print, and augmented assignment; augmented assignment uses Delegator classes (see doc string) fix import and tuple unpacking for 1.5.2 transformer.py: various changes to support new 2.0 grammar and old 1.5 grammar add debug_tree helper than converts and symbol and token numbers to their names
* Fix SF bug #116263: support for from .. import *Jeremy Hylton2000-10-121-0/+2
| | | | | | transformer.py: return '*', None from com_import_as_name pycodegen.py: special case for name == '*' pyassem.py: fix stack counting for IMPORT_ opcodes
* change 2-space indent to 4-space indentJeremy Hylton2000-09-201-1081/+1079
|
* Update magic number.Jeremy Hylton2000-09-011-7/+25
| | | | | | Fix import support to work with import as variant of Python 2.0. The grammar for import changed, requiring changes in transformer and code generator, even to handle compilation of imports with as.
* update my email addressJeremy Hylton2000-08-041-1/+4
| | | | fix com_call_function to cope with trailing comma in "f(a, b,)"
* add a bit more legal junkGreg Stein2000-08-031-8/+16
| | | | (too lazy to paste in the whole BSD license tho; included by ref)
* patches from Mark HammondJeremy Hylton2000-05-021-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attached is a set of diffs for the .py compiler that adds support for the new extended call syntax. compiler/ast.py: CallFunc node gets 2 new children to support extended call syntax - "star_args" (for "*args") and "dstar_args" (for "**args") compiler/pyassem.py It appear that self.lnotab is supposed to be responsible for tracking line numbers, but self.firstlineno was still hanging around. Removed self.firstlineno completely. NOTE - I didnt actually test that the generated code has the correct line numbers!! Stack depth tracking appeared a little broken - the checks never made it beyond the "self.patterns" check - thus, the custom methods were never called! Fixed this. (XXX Jeremy notes: I think this code is still broken because it doesn't track stack effects across block bounaries.) Added support for the new extended call syntax opcodes for depth calculations. compiler/pycodegen.py Added support for the new extended call syntax opcodes. compiler/transformer.py Added support for the new extended call syntax.
* fix list.append problemsJeremy Hylton2000-03-161-3/+3
|
* change node Classdef to ClassJeremy Hylton2000-03-061-20/+21
| | | | | | | add doc string to transformer module add two helper functions: parse(buf) -> AST parseFile(path) -> AST
* more robust assignment of lineno for keyword argsJeremy Hylton2000-02-161-3/+3
| | | | | | | | get the lineno from the name of the keyword arg example of case that didn't work-- def foo(x, y, a = None, b = None):
* fix creation of Ellipsis nodeJeremy Hylton2000-02-151-1/+1
|
* add line numbers to nodes in the except clause (when possible)Jeremy Hylton2000-02-151-1/+3
|
* (), [], and {} should not be represented as constant expressions, theyJeremy Hylton2000-02-141-3/+3
| | | | should be calls to BUILD_ ops for these types with no arguments
* add spaces to comparison names is not and not in to match disJeremy Hylton2000-02-081-2/+2
|
* move constants out of transformer so that they can be shared with astJeremy Hylton2000-02-081-8/+2
| | | | add varargs and kwargs attributes to Function nodes
* three files from the p2c cvs tree. the message here indicates theJeremy Hylton2000-02-041-0/+1204
revision number the p2c cvs tree. COPYRIGHT: 1.1 ast.py: 1.3 transformer.py: 1.11