| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Thanks Thomas Herve
|
| |
|
|
|
|
|
|
|
| |
happy with the output as-is. This incidentally also
gets rid of "an extra" blank line at the end of the output
block that probably wasn't intended (although it doesn't
matter one way or the other).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was started by Mike Bland and completed by Guido
(with help from Neal).
This still needs a __future__ statement added;
Thomas is working on Michael's patch for that aspect.
There's a small amount of code cleanup and refactoring
in ast.c, compile.c and ceval.c (I fixed the lltrace
behavior when EXT_POP is used -- however I had to make
lltrace a static global).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.
The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
SF patch #1015989
The basic idea of this patch is to compute lineno attributes for all AST nodes. The actual
implementation lead to a lot of restructing and code cleanup.
The generated AST nodes now have an optional lineno argument to constructor. Remove the
top-level asList(), since it didn't seem to serve any purpose. Add an __iter__ to ast nodes.
Use isinstance() instead of explicit type tests.
Change transformer to use the new lineno attribute, which replaces three lines of code with one.
Use universal newlines so that we can get rid of special-case code for line endings. Use
lookup_node() in a few more frequently called, but simple com_xxx methods(). Change string
exception to class exception.
|
|
|
|
|
| |
"@ seems the syntax that everybody can hate equally"
Implementation by Mark Russell, from SF #979728.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(Code contributed by Jiwon Seo.)
The documentation portion of the patch is being re-worked and will be
checked-in soon. Likewise, PEP 289 will be updated to reflect Guido's
rationale for the design decisions on binding behavior (as described in
in his patch comments and in discussions on python-dev).
The test file, test_genexps.py, is written in doctest format and is
meant to exercise all aspects of the the patch. Further additions are
welcome from everyone. Please stress test this new feature as much as
possible before the alpha release.
|
|
|
|
| |
From SF patch #852334.
|
|
|
|
|
| |
Weinberg). This changes all uses of deprecated tempfile functions to
the recommended ones.
|
| |
|
| |
|
|
|
|
|
|
| |
library.
Update README.
|
| |
|
|
|
|
| |
Remove all these files. All except astgen.py are moved to Lib/compiler.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
The argument properties are ordered from easiest to hardest. The
harder the arg, the more complicated that code that must be generated
to return it from getChildren() and/or getChildNodes(). The old
calculation routine was bogus, because it always set hardest_arg to
the hardness of the last argument. Now use max() to always set it to
the hardness of the hardest argument.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
| |
If passed a .py file as an argument, try to find its accompanying
.pyc.
|
|
|
|
|
|
|
|
| |
Invoke compiler.syntax.check() after building AST. If a SyntaxError
occurs, print the error and exit without generating a .pyc file.
Refactor code to use compiler.misc.set_filename() rather than passing
filename argument around to each CodeGenerator instance.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove the option to have nested scopes or old LGB scopes. This has a
large impact on the code base, by removing the need for two variants
of each CodeGenerator.
Add a get_module() method to CodeGenerator objects, used to get the
future features for the current module.
Set CO_GENERATOR, CO_GENERATOR_ALLOWED, and CO_FUTURE_DIVISION flags
as appropriate.
Attempt to fix the value of nlocals in newCodeObject(), assuming that
nlocals is 0 if CO_NEWLOCALS is not defined.
|
|
|
|
|
|
|
| |
bound.
When a Yield() node is visited, assign to the generator attribute of
the scope, not the visitor.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Fix list comp code generation -- emit GET_ITER instead of Const(0)
after the list.
Add CO_GENERATOR flag to generators.
Get CO_xxx flags from the new module
|
| |
|
|
|
|
|
|
|
|
| |
try/except or try/finally.
Previous versions had only track SETUP_LOOP blocks and ignored the
exception part. This meant that it allowed continue inside a
try/except but generated buggy code. Now it does the right thing.
|
|
|
|
| |
Add CONTINUE_LOOP to the list of unconditional transfers
|
| |
|
|
|
|
|
|
|
| |
starts a new line.
Also fix undetected typo in visitDict() -- uncovered by recent change
to add lineno attrs to atoms.
|
| |
|
|
|
|
|
| |
XXX The code is still widely inaccurate, but most (all?) of the time
it's an overestimate.
|
|
|
|
|
|
|
|
|
|
| |
As the doc string for _lookupName() explains:
This routine uses a list instead of a dictionary, because a
dictionary can't store two different keys if the keys have the
same value but different types, e.g. 2 and 2L. The compiler
must treat these two separately, so it does an explicit type
comparison before comparing the values.
|
| |
|
|
|
|
|
|
|
| |
Generate SET_LINENO for del statements.
Define klass=1 for PyFlowGraph constructor for a class statement. A
class has no varnames.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Fix bug in handling of statements like "l[x:y] = 2". The visitor was
treating this as assignments to l, x, and y!
|