--- /home/docs/checkouts/readthedocs.org/user_builds/restrictedpython/checkouts/latest/docs/contributing/ast/python3_7.ast
+++ /home/docs/checkouts/readthedocs.org/user_builds/restrictedpython/checkouts/latest/docs/contributing/ast/python3_8.ast
@@ -1,15 +1,13 @@
--- Python 3.7 AST
--- ASDL's 7 builtin types are:
--- identifier, int, string, bytes, object, singleton, constant
---
--- singleton: None, True or False
--- constant can be None, whereas None means "no value" for object.
+-- Python 3.8 AST
+-- ASDL's 5 builtin types are:
+-- identifier, int, string, object, constant
-module Python version "3.7"
+module Python version "3.8"
{
- mod = Module(stmt* body)
+ mod = Module(stmt* body, type_ignore *type_ignores)
| Interactive(stmt* body)
| Expression(expr body)
+ | FunctionType(expr* argtypes, expr returns)
-- not really an actual node but useful in Jython's typesystem.
| Suite(stmt* body)
@@ -18,12 +16,14 @@
arguments args,
stmt* body,
expr* decorator_list,
- expr? returns)
+ expr? returns,
+ string? type_comment)
| AsyncFunctionDef(identifier name,
arguments args,
stmt* body,
expr* decorator_list,
- expr? returns)
+ expr? returns,
+ string? type_comment)
| ClassDef(identifier name,
expr* bases,
@@ -33,18 +33,18 @@
| Return(expr? value)
| Delete(expr* targets)
- | Assign(expr* targets, expr value)
+ | Assign(expr* targets, expr value, string? type_comment)
| AugAssign(expr target, operator op, expr value)
-- 'simple' indicates that we annotate simple name without parens
| AnnAssign(expr target, expr annotation, expr? value, int simple)
-- use 'orelse' because else is a keyword in target languages
- | For(expr target, expr iter, stmt* body, stmt* orelse)
- | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse)
+ | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)
+ | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)
| While(expr test, stmt* body, stmt* orelse)
| If(expr test, stmt* body, stmt* orelse)
- | With(withitem* items, stmt* body)
- | AsyncWith(withitem* items, stmt* body)
+ | With(withitem* items, stmt* body, string? type_comment)
+ | AsyncWith(withitem* items, stmt* body, string? type_comment)
| Raise(expr? exc, expr? cause)
| Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)
@@ -62,10 +62,11 @@
-- XXX Jython will be different
-- col_offset is the byte offset in the utf8 string the parser uses
- attributes (int lineno, int col_offset)
+ attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
-- BoolOp() can use left & right?
expr = BoolOp(boolop op, expr* values)
+ | NamedExpr(expr target, expr value)
| BinOp(expr left, operator op, expr right)
| UnaryOp(unaryop op, expr operand)
| Lambda(arguments args, expr body)
@@ -86,14 +87,9 @@
| Call(expr func,
expr* args,
keyword* keywords)
- | Num(object n) -- a number as a PyObject.
- | Str(string s) -- need to specify raw, unicode, etc?
| FormattedValue(expr value, int? conversion, expr? format_spec)
| JoinedStr(expr* values)
- | Bytes(bytes s)
- | NameConstant(singleton value)
- | Ellipsis
- | Constant(constant value)
+ | Constant(constant value, string? kind)
-- the following expression can appear in assignment context
| Attribute(expr value, identifier attr, expr_context ctx)
@@ -104,7 +100,7 @@
| Tuple(expr* elts, expr_context ctx)
-- col_offset is the byte offset in the utf8 string the parser uses
- attributes (int lineno, int col_offset)
+ attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
expr_context = Load
| Store
@@ -153,17 +149,18 @@
comprehension = (expr target, expr iter, expr* ifs, int is_async)
excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)
- attributes (int lineno, int col_offset)
+ attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
- arguments = (arg* args,
+ arguments = (arg* posonlyargs,
+ arg* args,
arg? vararg,
arg* kwonlyargs,
expr* kw_defaults,
arg? kwarg,
expr* defaults)
- arg = (identifier arg, expr? annotation)
- attributes (int lineno, int col_offset)
+ arg = (identifier arg, expr? annotation, string? type_comment)
+ attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
-- keyword arguments supplied to call (NULL identifier for **kwargs)
keyword = (identifier? arg, expr value)
@@ -172,4 +169,6 @@
alias = (identifier name, identifier? asname)
withitem = (expr context_expr, expr? optional_vars)
+
+ type_ignore = TypeIgnore(int lineno, string tag)
}