bpo-31464: asdl_c.py no longer emits trailing spaces in Python-ast.h. (#3568)

This commit is contained in:
Serhiy Storchaka 2017-09-15 06:28:22 +03:00 committed by Benjamin Peterson
parent b2e5794870
commit 5d84cb368c
2 changed files with 62 additions and 61 deletions

View File

@ -48,19 +48,19 @@ struct _mod {
asdl_seq *body; asdl_seq *body;
string docstring; string docstring;
} Module; } Module;
struct { struct {
asdl_seq *body; asdl_seq *body;
} Interactive; } Interactive;
struct { struct {
expr_ty body; expr_ty body;
} Expression; } Expression;
struct { struct {
asdl_seq *body; asdl_seq *body;
} Suite; } Suite;
} v; } v;
}; };
@ -83,7 +83,7 @@ struct _stmt {
expr_ty returns; expr_ty returns;
string docstring; string docstring;
} FunctionDef; } FunctionDef;
struct { struct {
identifier name; identifier name;
arguments_ty args; arguments_ty args;
@ -92,7 +92,7 @@ struct _stmt {
expr_ty returns; expr_ty returns;
string docstring; string docstring;
} AsyncFunctionDef; } AsyncFunctionDef;
struct { struct {
identifier name; identifier name;
asdl_seq *bases; asdl_seq *bases;
@ -101,108 +101,108 @@ struct _stmt {
asdl_seq *decorator_list; asdl_seq *decorator_list;
string docstring; string docstring;
} ClassDef; } ClassDef;
struct { struct {
expr_ty value; expr_ty value;
} Return; } Return;
struct { struct {
asdl_seq *targets; asdl_seq *targets;
} Delete; } Delete;
struct { struct {
asdl_seq *targets; asdl_seq *targets;
expr_ty value; expr_ty value;
} Assign; } Assign;
struct { struct {
expr_ty target; expr_ty target;
operator_ty op; operator_ty op;
expr_ty value; expr_ty value;
} AugAssign; } AugAssign;
struct { struct {
expr_ty target; expr_ty target;
expr_ty annotation; expr_ty annotation;
expr_ty value; expr_ty value;
int simple; int simple;
} AnnAssign; } AnnAssign;
struct { struct {
expr_ty target; expr_ty target;
expr_ty iter; expr_ty iter;
asdl_seq *body; asdl_seq *body;
asdl_seq *orelse; asdl_seq *orelse;
} For; } For;
struct { struct {
expr_ty target; expr_ty target;
expr_ty iter; expr_ty iter;
asdl_seq *body; asdl_seq *body;
asdl_seq *orelse; asdl_seq *orelse;
} AsyncFor; } AsyncFor;
struct { struct {
expr_ty test; expr_ty test;
asdl_seq *body; asdl_seq *body;
asdl_seq *orelse; asdl_seq *orelse;
} While; } While;
struct { struct {
expr_ty test; expr_ty test;
asdl_seq *body; asdl_seq *body;
asdl_seq *orelse; asdl_seq *orelse;
} If; } If;
struct { struct {
asdl_seq *items; asdl_seq *items;
asdl_seq *body; asdl_seq *body;
} With; } With;
struct { struct {
asdl_seq *items; asdl_seq *items;
asdl_seq *body; asdl_seq *body;
} AsyncWith; } AsyncWith;
struct { struct {
expr_ty exc; expr_ty exc;
expr_ty cause; expr_ty cause;
} Raise; } Raise;
struct { struct {
asdl_seq *body; asdl_seq *body;
asdl_seq *handlers; asdl_seq *handlers;
asdl_seq *orelse; asdl_seq *orelse;
asdl_seq *finalbody; asdl_seq *finalbody;
} Try; } Try;
struct { struct {
expr_ty test; expr_ty test;
expr_ty msg; expr_ty msg;
} Assert; } Assert;
struct { struct {
asdl_seq *names; asdl_seq *names;
} Import; } Import;
struct { struct {
identifier module; identifier module;
asdl_seq *names; asdl_seq *names;
int level; int level;
} ImportFrom; } ImportFrom;
struct { struct {
asdl_seq *names; asdl_seq *names;
} Global; } Global;
struct { struct {
asdl_seq *names; asdl_seq *names;
} Nonlocal; } Nonlocal;
struct { struct {
expr_ty value; expr_ty value;
} Expr; } Expr;
} v; } v;
int lineno; int lineno;
int col_offset; int col_offset;
@ -224,145 +224,145 @@ struct _expr {
boolop_ty op; boolop_ty op;
asdl_seq *values; asdl_seq *values;
} BoolOp; } BoolOp;
struct { struct {
expr_ty left; expr_ty left;
operator_ty op; operator_ty op;
expr_ty right; expr_ty right;
} BinOp; } BinOp;
struct { struct {
unaryop_ty op; unaryop_ty op;
expr_ty operand; expr_ty operand;
} UnaryOp; } UnaryOp;
struct { struct {
arguments_ty args; arguments_ty args;
expr_ty body; expr_ty body;
} Lambda; } Lambda;
struct { struct {
expr_ty test; expr_ty test;
expr_ty body; expr_ty body;
expr_ty orelse; expr_ty orelse;
} IfExp; } IfExp;
struct { struct {
asdl_seq *keys; asdl_seq *keys;
asdl_seq *values; asdl_seq *values;
} Dict; } Dict;
struct { struct {
asdl_seq *elts; asdl_seq *elts;
} Set; } Set;
struct { struct {
expr_ty elt; expr_ty elt;
asdl_seq *generators; asdl_seq *generators;
} ListComp; } ListComp;
struct { struct {
expr_ty elt; expr_ty elt;
asdl_seq *generators; asdl_seq *generators;
} SetComp; } SetComp;
struct { struct {
expr_ty key; expr_ty key;
expr_ty value; expr_ty value;
asdl_seq *generators; asdl_seq *generators;
} DictComp; } DictComp;
struct { struct {
expr_ty elt; expr_ty elt;
asdl_seq *generators; asdl_seq *generators;
} GeneratorExp; } GeneratorExp;
struct { struct {
expr_ty value; expr_ty value;
} Await; } Await;
struct { struct {
expr_ty value; expr_ty value;
} Yield; } Yield;
struct { struct {
expr_ty value; expr_ty value;
} YieldFrom; } YieldFrom;
struct { struct {
expr_ty left; expr_ty left;
asdl_int_seq *ops; asdl_int_seq *ops;
asdl_seq *comparators; asdl_seq *comparators;
} Compare; } Compare;
struct { struct {
expr_ty func; expr_ty func;
asdl_seq *args; asdl_seq *args;
asdl_seq *keywords; asdl_seq *keywords;
} Call; } Call;
struct { struct {
object n; object n;
} Num; } Num;
struct { struct {
string s; string s;
} Str; } Str;
struct { struct {
expr_ty value; expr_ty value;
int conversion; int conversion;
expr_ty format_spec; expr_ty format_spec;
} FormattedValue; } FormattedValue;
struct { struct {
asdl_seq *values; asdl_seq *values;
} JoinedStr; } JoinedStr;
struct { struct {
bytes s; bytes s;
} Bytes; } Bytes;
struct { struct {
singleton value; singleton value;
} NameConstant; } NameConstant;
struct { struct {
constant value; constant value;
} Constant; } Constant;
struct { struct {
expr_ty value; expr_ty value;
identifier attr; identifier attr;
expr_context_ty ctx; expr_context_ty ctx;
} Attribute; } Attribute;
struct { struct {
expr_ty value; expr_ty value;
slice_ty slice; slice_ty slice;
expr_context_ty ctx; expr_context_ty ctx;
} Subscript; } Subscript;
struct { struct {
expr_ty value; expr_ty value;
expr_context_ty ctx; expr_context_ty ctx;
} Starred; } Starred;
struct { struct {
identifier id; identifier id;
expr_context_ty ctx; expr_context_ty ctx;
} Name; } Name;
struct { struct {
asdl_seq *elts; asdl_seq *elts;
expr_context_ty ctx; expr_context_ty ctx;
} List; } List;
struct { struct {
asdl_seq *elts; asdl_seq *elts;
expr_context_ty ctx; expr_context_ty ctx;
} Tuple; } Tuple;
} v; } v;
int lineno; int lineno;
int col_offset; int col_offset;
@ -377,15 +377,15 @@ struct _slice {
expr_ty upper; expr_ty upper;
expr_ty step; expr_ty step;
} Slice; } Slice;
struct { struct {
asdl_seq *dims; asdl_seq *dims;
} ExtSlice; } ExtSlice;
struct { struct {
expr_ty value; expr_ty value;
} Index; } Index;
} v; } v;
}; };
@ -405,7 +405,7 @@ struct _excepthandler {
identifier name; identifier name;
asdl_seq *body; asdl_seq *body;
} ExceptHandler; } ExceptHandler;
} v; } v;
int lineno; int lineno;
int col_offset; int col_offset;

View File

@ -94,8 +94,9 @@ class EmitVisitor(asdl.VisitorBase):
else: else:
lines = [s] lines = [s]
for line in lines: for line in lines:
line = (" " * TABSIZE * depth) + line + "\n" if line:
self.file.write(line) line = (" " * TABSIZE * depth) + line
self.file.write(line + "\n")
class TypeDefVisitor(EmitVisitor): class TypeDefVisitor(EmitVisitor):