Mercurial > cpython-lru_cache-weakref
annotate Parser/Python.asdl @ 39678:f87a3e61853d
Remove the UNARY_CONVERT opcode (was used for backticks). Also bumped up the
import MAGIC number.
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Fri, 25 Aug 2006 05:05:30 +0000 |
| parents | f731859e9b3b |
| children | d0b83c4630c0 |
| rev | line source |
|---|---|
|
35871
4ac3fa158927
Thou shalt not lie, there are really 5 types now
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1 -- ASDL's five builtin types are identifier, int, string, object, bool |
| 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, | |
| 13 stmt* body, expr* decorators) | |
| 14 | ClassDef(identifier name, expr* bases, stmt* body) | |
| 15 | Return(expr? value) | |
| 16 | |
| 17 | Delete(expr* targets) | |
| 18 | Assign(expr* targets, expr value) | |
| 19 | AugAssign(expr target, operator op, expr value) | |
| 20 | |
| 21 -- not sure if bool is allowed, can always use int | |
| 22 | Print(expr? dest, expr* values, bool nl) | |
| 23 | |
| 24 -- use 'orelse' because else is a keyword in target languages | |
| 25 | For(expr target, expr iter, stmt* body, stmt* orelse) | |
| 26 | While(expr test, stmt* body, stmt* orelse) | |
| 27 | If(expr test, stmt* body, stmt* orelse) | |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36666
diff
changeset
|
28 | With(expr context_expr, expr? optional_vars, stmt* body) |
| 35742 | 29 |
| 30 -- 'type' is a bad name | |
| 31 | Raise(expr? type, expr? inst, expr? tback) | |
| 32 | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse) | |
| 33 | TryFinally(stmt* body, stmt* finalbody) | |
| 34 | Assert(expr test, expr? msg) | |
| 35 | |
| 36 | Import(alias* names) | |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36703
diff
changeset
|
37 | ImportFrom(identifier module, alias* names, int? level) |
| 35742 | 38 |
| 39 -- Doesn't capture requirement that locals must be | |
| 40 -- defined if globals is | |
| 41 -- still supports use as a function! | |
| 42 | Exec(expr body, expr? globals, expr? locals) | |
| 43 | |
| 44 | Global(identifier* names) | |
| 45 | Expr(expr value) | |
| 46 | Pass | Break | Continue | |
| 47 | |
| 48 -- 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
|
49 -- 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
|
50 attributes (int lineno, int col_offset) |
| 35742 | 51 |
| 52 -- BoolOp() can use left & right? | |
| 53 expr = BoolOp(boolop op, expr* values) | |
| 54 | BinOp(expr left, operator op, expr right) | |
| 55 | UnaryOp(unaryop op, expr operand) | |
| 56 | 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
|
57 | IfExp(expr test, expr body, expr orelse) |
| 35742 | 58 | Dict(expr* keys, expr* values) |
| 59 | ListComp(expr elt, comprehension* generators) | |
| 60 | GeneratorExp(expr elt, comprehension* generators) | |
|
36418
a625e8876407
Improved handling of syntax errors.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
35871
diff
changeset
|
61 -- the grammar constrains where yield expressions can occur |
| 35742 | 62 | Yield(expr? value) |
| 63 -- need sequences for compare to distinguish between | |
| 64 -- x < 4 < 3 and (x < 4) < 3 | |
| 65 | Compare(expr left, cmpop* ops, expr* comparators) | |
| 66 | Call(expr func, expr* args, keyword* keywords, | |
| 67 expr? starargs, expr? kwargs) | |
| 68 | Num(object n) -- a number as a PyObject. | |
| 69 | Str(string s) -- need to specify raw, unicode, etc? | |
| 70 -- other literals? bools? | |
| 71 | |
| 72 -- the following expression can appear in assignment context | |
| 73 | Attribute(expr value, identifier attr, expr_context ctx) | |
| 74 | Subscript(expr value, slice slice, expr_context ctx) | |
| 75 | Name(identifier id, expr_context ctx) | |
| 76 | List(expr* elts, expr_context ctx) | |
| 77 | Tuple(expr *elts, expr_context ctx) | |
| 78 | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
79 -- 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
|
80 attributes (int lineno, int col_offset) |
| 35742 | 81 |
| 82 expr_context = Load | Store | Del | AugLoad | AugStore | Param | |
| 83 | |
| 84 slice = Ellipsis | Slice(expr? lower, expr? upper, expr? step) | |
| 85 | ExtSlice(slice* dims) | |
| 86 | Index(expr value) | |
| 87 | |
| 88 boolop = And | Or | |
| 89 | |
| 90 operator = Add | Sub | Mult | Div | Mod | Pow | LShift | |
| 91 | RShift | BitOr | BitXor | BitAnd | FloorDiv | |
| 92 | |
| 93 unaryop = Invert | Not | UAdd | USub | |
| 94 | |
| 95 cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn | |
| 96 | |
| 97 comprehension = (expr target, expr iter, expr* ifs) | |
| 98 | |
| 99 -- 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
|
100 -- 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
|
101 -- 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
|
102 -- ast is exposed to Python. |
|
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 excepthandler = (expr? type, expr? name, stmt* body, int lineno, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36786
diff
changeset
|
104 int col_offset) |
| 35742 | 105 |
| 106 arguments = (expr* args, identifier? vararg, | |
| 107 identifier? kwarg, expr* defaults) | |
| 108 | |
| 109 -- keyword arguments supplied to call | |
| 110 keyword = (identifier arg, expr value) | |
| 111 | |
| 112 -- import name with optional 'as' alias. | |
| 113 alias = (identifier name, identifier? asname) | |
| 114 } |
