Mercurial > cpython-lru_cache-weakref
annotate Parser/Python.asdl @ 41226:19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
The compiler package hasn't been updated yet; test_compiler.py fails.
Otherwise all tests seem to be passing now. There are no occurrences
of __metaclass__ left in the standard library.
Docs have not been updated.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 18 Mar 2007 15:41:51 +0000 |
| parents | 30e5cb3a55ac |
| children | 060c79f6d919 |
| rev | line source |
|---|---|
|
40940
1853cf06e36b
bool is no longer required, it was only used for the print statement
Neal Norwitz <nnorwitz@gmail.com>
parents:
40895
diff
changeset
|
1 -- ASDL's five builtin types are identifier, int, string, object |
| 35742 | 2 |
|
36703
9f3e58dbea63
Add support for version field on Modules
Martin v. Löwis <martin@v.loewis.de>
parents:
36695
diff
changeset
|
3 module Python version "$Revision$" |
| 35742 | 4 { |
| 5 mod = Module(stmt* body) | |
| 6 | Interactive(stmt* body) | |
| 7 | Expression(expr body) | |
| 8 | |
| 9 -- not really an actual node but useful in Jython's typesystem. | |
| 10 | Suite(stmt* body) | |
| 11 | |
| 12 stmt = FunctionDef(identifier name, arguments args, | |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
13 stmt* body, expr* decorators, expr? returns) |
|
41226
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
14 | ClassDef(identifier name, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
15 expr* bases, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
16 keyword* keywords, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
17 expr? starargs, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
18 expr? kwargs, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
19 stmt* body) |
| 35742 | 20 | Return(expr? value) |
| 21 | |
| 22 | Delete(expr* targets) | |
| 23 | Assign(expr* targets, expr value) | |
| 24 | AugAssign(expr target, operator op, expr value) | |
| 25 | |
| 26 -- use 'orelse' because else is a keyword in target languages | |
| 27 | For(expr target, expr iter, stmt* body, stmt* orelse) | |
| 28 | While(expr test, stmt* body, stmt* orelse) | |
| 29 | If(expr test, stmt* body, stmt* orelse) | |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36666
diff
changeset
|
30 | With(expr context_expr, expr? optional_vars, stmt* body) |
| 35742 | 31 |
| 32 -- 'type' is a bad name | |
| 33 | Raise(expr? type, expr? inst, expr? tback) | |
| 34 | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse) | |
| 35 | TryFinally(stmt* body, stmt* finalbody) | |
| 36 | Assert(expr test, expr? msg) | |
| 37 | |
| 38 | Import(alias* names) | |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36703
diff
changeset
|
39 | ImportFrom(identifier module, alias* names, int? level) |
| 35742 | 40 |
| 41 | Global(identifier* names) | |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40940
diff
changeset
|
42 | Nonlocal(identifier* names) |
| 35742 | 43 | Expr(expr value) |
| 44 | Pass | Break | Continue | |
| 45 | |
| 46 -- XXX Jython will be different | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
47 -- col_offset is the byte offset in the utf8 string the parser uses |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
48 attributes (int lineno, int col_offset) |
| 35742 | 49 |
| 50 -- BoolOp() can use left & right? | |
| 51 expr = BoolOp(boolop op, expr* values) | |
| 52 | BinOp(expr left, operator op, expr right) | |
| 53 | UnaryOp(unaryop op, expr operand) | |
| 54 | Lambda(arguments args, expr body) | |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36418
diff
changeset
|
55 | IfExp(expr test, expr body, expr orelse) |
| 35742 | 56 | Dict(expr* keys, expr* values) |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39678
diff
changeset
|
57 | Set(expr* elts) |
| 35742 | 58 | ListComp(expr elt, comprehension* generators) |
| 59 | GeneratorExp(expr elt, comprehension* generators) | |
|
36418
a625e8876407
Improved handling of syntax errors.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
35871
diff
changeset
|
60 -- the grammar constrains where yield expressions can occur |
| 35742 | 61 | Yield(expr? value) |
| 62 -- need sequences for compare to distinguish between | |
| 63 -- x < 4 < 3 and (x < 4) < 3 | |
| 64 | Compare(expr left, cmpop* ops, expr* comparators) | |
| 65 | Call(expr func, expr* args, keyword* keywords, | |
| 66 expr? starargs, expr? kwargs) | |
| 67 | Num(object n) -- a number as a PyObject. | |
| 68 | Str(string s) -- need to specify raw, unicode, etc? | |
| 40894 | 69 | Bytes(string s) |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
70 | Ellipsis |
| 35742 | 71 -- other literals? bools? |
| 72 | |
| 73 -- the following expression can appear in assignment context | |
| 74 | Attribute(expr value, identifier attr, expr_context ctx) | |
| 75 | Subscript(expr value, slice slice, expr_context ctx) | |
| 76 | Name(identifier id, expr_context ctx) | |
| 77 | List(expr* elts, expr_context ctx) | |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40788
diff
changeset
|
78 | Tuple(expr* elts, expr_context ctx) |
| 35742 | 79 |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
80 -- col_offset is the byte offset in the utf8 string the parser uses |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
81 attributes (int lineno, int col_offset) |
| 35742 | 82 |
| 83 expr_context = Load | Store | Del | AugLoad | AugStore | Param | |
| 84 | |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
85 slice = Slice(expr? lower, expr? upper, expr? step) |
| 35742 | 86 | ExtSlice(slice* dims) |
| 87 | Index(expr value) | |
| 88 | |
| 89 boolop = And | Or | |
| 90 | |
| 91 operator = Add | Sub | Mult | Div | Mod | Pow | LShift | |
| 92 | RShift | BitOr | BitXor | BitAnd | FloorDiv | |
| 93 | |
| 94 unaryop = Invert | Not | UAdd | USub | |
| 95 | |
| 96 cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn | |
| 97 | |
| 98 comprehension = (expr target, expr iter, expr* ifs) | |
| 99 | |
| 100 -- not sure what to call the first argument for raise and except | |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36786
diff
changeset
|
101 -- TODO(jhylton): Figure out if there is a better way to handle |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36786
diff
changeset
|
102 -- lineno and col_offset fields, particularly when |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36786
diff
changeset
|
103 -- ast is exposed to Python. |
|
40588
4bab65fcca8e
Some more changes related to the new except syntax and semantics,
Guido van Rossum <guido@python.org>
parents:
40529
diff
changeset
|
104 excepthandler = (expr? type, identifier? name, stmt* body, int lineno, |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36786
diff
changeset
|
105 int col_offset) |
| 35742 | 106 |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
107 arguments = (arg* args, identifier? vararg, expr? varargannotation, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
108 arg* kwonlyargs, identifier? kwarg, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
109 expr? kwargannotation, expr* defaults, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
110 expr* kw_defaults) |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
111 arg = SimpleArg(identifier arg, expr? annotation) |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
112 | NestedArgs(arg* args) |
| 35742 | 113 |
| 114 -- keyword arguments supplied to call | |
| 115 keyword = (identifier arg, expr value) | |
| 116 | |
| 117 -- import name with optional 'as' alias. | |
| 118 alias = (identifier name, identifier? asname) | |
| 119 } | |
|
40895
bd1419e94773
Touch file to regenerate Python-ast.[ch]
Thomas Wouters <thomas@python.org>
parents:
40894
diff
changeset
|
120 |
