Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(622)

Side by Side Diff: Parser/Python.asdl

Issue 4281051: Rewrite of peephole to work on AST Base URL: http://hg.python.org/cpython/
Patch Set: Update Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 -- ASDL's four builtin types are identifier, int, string, object 1 -- ASDL's four builtin types are identifier, int, string, object
2 2
3 module Python 3 module Python
4 { 4 {
5 » mod = Module(stmt* body) 5 » mod = Module(stmt* body, string? docstring)
6 | Interactive(stmt* body) 6 | Interactive(stmt* body)
7 | Expression(expr body) 7 | Expression(expr body)
8 8
9 -- not really an actual node but useful in Jython's typesystem. 9 -- not really an actual node but useful in Jython's typesystem.
10 | Suite(stmt* body) 10 | Suite(stmt* body)
11 11
12 stmt = FunctionDef(identifier name, arguments args,· 12 stmt = FunctionDef(identifier name, arguments args,·
13 stmt* body, expr* decorator_list, expr? returns) 13 stmt* body, expr* decorator_list, expr? returns,
14 string? docstring)
14 | ClassDef(identifier name,· 15 | ClassDef(identifier name,·
15 expr* bases, 16 expr* bases,
16 keyword* keywords, 17 keyword* keywords,
17 expr? starargs, 18 expr? starargs,
18 expr? kwargs, 19 expr? kwargs,
19 stmt* body, 20 stmt* body,
20 » » » expr* decorator_list) 21 » » » expr* decorator_list,
22 string? docstring)
21 | Return(expr? value) 23 | Return(expr? value)
22 24
23 | Delete(expr* targets) 25 | Delete(expr* targets)
24 | Assign(expr* targets, expr value) 26 | Assign(expr* targets, expr value)
25 | AugAssign(expr target, operator op, expr value) 27 | AugAssign(expr target, operator op, expr value)
26 28
27 -- use 'orelse' because else is a keyword in target languages 29 -- use 'orelse' because else is a keyword in target languages
28 | For(expr target, expr iter, stmt* body, stmt* orelse) 30 | For(expr target, expr iter, stmt* body, stmt* orelse)
29 | While(expr test, stmt* body, stmt* orelse) 31 | While(expr test, stmt* body, stmt* orelse)
30 | If(expr test, stmt* body, stmt* orelse) 32 | If(expr test, stmt* body, stmt* orelse)
(...skipping 28 matching lines...) Expand all
59 | SetComp(expr elt, comprehension* generators) 61 | SetComp(expr elt, comprehension* generators)
60 | DictComp(expr key, expr value, comprehension* generators) 62 | DictComp(expr key, expr value, comprehension* generators)
61 | GeneratorExp(expr elt, comprehension* generators) 63 | GeneratorExp(expr elt, comprehension* generators)
62 -- the grammar constrains where yield expressions can occur 64 -- the grammar constrains where yield expressions can occur
63 | Yield(expr? value) 65 | Yield(expr? value)
64 -- need sequences for compare to distinguish between 66 -- need sequences for compare to distinguish between
65 -- x < 4 < 3 and (x < 4) < 3 67 -- x < 4 < 3 and (x < 4) < 3
66 | Compare(expr left, cmpop* ops, expr* comparators) 68 | Compare(expr left, cmpop* ops, expr* comparators)
67 | Call(expr func, expr* args, keyword* keywords, 69 | Call(expr func, expr* args, keyword* keywords,
68 expr? starargs, expr? kwargs) 70 expr? starargs, expr? kwargs)
69 » | Num(object n) -- a number as a PyObject. 71 » | Lit(object v) -- a literal as a PyObject.
70 » | Str(string s) -- need to specify raw, unicode, etc?
71 » | Bytes(string s)
72 » | Ellipsis
73 » -- other literals? bools?
74 72
75 -- the following expression can appear in assignment context 73 -- the following expression can appear in assignment context
76 | Attribute(expr value, identifier attr, expr_context ctx) 74 | Attribute(expr value, identifier attr, expr_context ctx)
77 | Subscript(expr value, slice slice, expr_context ctx) 75 | Subscript(expr value, slice slice, expr_context ctx)
78 | Starred(expr value, expr_context ctx) 76 | Starred(expr value, expr_context ctx)
79 | Name(identifier id, expr_context ctx) 77 | Name(identifier id, expr_context ctx)
80 | List(expr* elts, expr_context ctx)· 78 | List(expr* elts, expr_context ctx)·
81 | Tuple(expr* elts, expr_context ctx) 79 | Tuple(expr* elts, expr_context ctx)
82 80
83 -- col_offset is the byte offset in the utf8 string the parser use s 81 -- col_offset is the byte offset in the utf8 string the parser use s
(...skipping 26 matching lines...) Expand all
110 expr* kw_defaults) 108 expr* kw_defaults)
111 arg = (identifier arg, expr? annotation) 109 arg = (identifier arg, expr? annotation)
112 110
113 -- keyword arguments supplied to call 111 -- keyword arguments supplied to call
114 keyword = (identifier arg, expr value) 112 keyword = (identifier arg, expr value)
115 113
116 -- import name with optional 'as' alias. 114 -- import name with optional 'as' alias.
117 alias = (identifier name, identifier? asname) 115 alias = (identifier name, identifier? asname)
118 } 116 }
119 117
OLDNEW
« no previous file with comments | « PC/os2emx/python33.def ('k') | Parser/asdl_c.py » ('j') | Python/compile.c » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b