diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-10-25 17:59:17 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-10-25 17:59:17 (GMT) |
commit | 821eee3321f36562e45aa97e25746ad0b6cad31e (patch) | |
tree | a294b9507e47122c7c3202f0437fd5608319308f /Tools/compiler/ast.txt | |
parent | 6caae14fbd186cf6f677c5b73d68d3c5899bd953 (diff) | |
download | cpython-821eee3321f36562e45aa97e25746ad0b6cad31e.zip cpython-821eee3321f36562e45aa97e25746ad0b6cad31e.tar.gz cpython-821eee3321f36562e45aa97e25746ad0b6cad31e.tar.bz2 |
Support for generation of ast.py from simple description of node
structure (ast.txt). Usage is python astgen.py > ast.py.
Diffstat (limited to 'Tools/compiler/ast.txt')
-rw-r--r-- | Tools/compiler/ast.txt | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Tools/compiler/ast.txt b/Tools/compiler/ast.txt new file mode 100644 index 0000000..1ca13f2 --- /dev/null +++ b/Tools/compiler/ast.txt @@ -0,0 +1,77 @@ +Module: doc, node +Stmt: nodes +Function: name, argnames, defaults, flags, doc, code +Lambda: argnames, defaults, flags, code +Class: name, bases, doc, code +Pass: +Break: +Continue: +For: assign, list, body, else_ +While: test, body, else_ +If: tests, else_ +Exec: expr, locals, globals +From: modname, names +Import: names +Raise: expr1, expr2, expr3 +TryFinally: body, final +TryExcept: body, handlers, else_ +Return: value +Const: value +Print: nodes, dest +Printnl: nodes, dest +Discard: expr +AugAssign: node, op, expr +Assign: nodes, expr +AssTuple: nodes +AssList: nodes +AssName: name, flags +AssAttr: expr, attrname, flags +ListComp: expr, quals +ListCompFor: assign, list, ifs +ListCompIf: test +List: nodes +Dict: items +Not: expr +Compare: expr, ops +Name: name +Global: names +Backquote: expr +Getattr: expr, attrname +CallFunc: node, args, star_args = None, dstar_args = None +Keyword: name, expr +Subscript: expr, flags, subs +Ellipsis: +Sliceobj: nodes +Slice: expr, flags, lower, upper +Assert: test, fail +Tuple: nodes +Or: nodes +And: nodes +Bitor: nodes +Bitxor: nodes +Bitand: nodes +LeftShift: (left, right) +RightShift: (left, right) +Add: (left, right) +Sub: (left, right) +Mul: (left, right) +Div: (left, right) +Mod: (left, right) +Power: (left, right) +UnaryAdd: expr +UnarySub: expr +Invert: expr + +init(Function): + self.varargs = self.kwargs = None + if flags & CO_VARARGS: + self.varargs = 1 + if flags & CO_VARKEYWORDS: + self.kwargs = 1 + +init(Lambda): + self.varargs = self.kwargs = None + if flags & CO_VARARGS: + self.varargs = 1 + if flags & CO_VARKEYWORDS: + self.kwargs = 1 |