Skip to content

Commit

Permalink
extracted the ast info from the compier... chould not be there!
Browse files Browse the repository at this point in the history
  • Loading branch information
Neppord committed Mar 5, 2011
1 parent 5d4dcfe commit cebdd93
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 85 deletions.
82 changes: 82 additions & 0 deletions ast.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Python grammar, the AST classes contain those arguments as properties.

module Python version "$Revision: 62047 $"
{
mod = Module(stmt* body)
| Interactive(stmt* body)
| Expression(expr body)

stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list)
| ClassDef(identifier name, expr* bases, stmt* body, expr *decorator_list)
| Return(expr? value)

| Delete(expr* targets)
| Assign(expr* targets, expr value)
| AugAssign(expr target, operator op, expr value)

| Print(expr? dest, expr* values, int nl)

| For(expr target, expr iter, stmt* body, stmt* orelse)
| While(expr test, stmt* body, stmt* orelse)
| If(expr test, stmt* body, stmt* orelse)
| With(expr context_expr, expr? optional_vars, stmt* body)

| Raise(expr? type, expr? inst, expr? tback)
| TryExcept(stmt* body, excepthandler* handlers, stmt* orelse)
| TryFinally(stmt* body, stmt* finalbody)
| Assert(expr test, expr? msg)

| Import(alias* names)
| ImportFrom(identifier module, alias* names, int? level)

| Exec(expr body, expr? globals, expr? locals)

| Global(identifier* names)
| Expr(expr value)
| Pass | Break | Continue

expr = BoolOp(boolop op, expr* values)
| BinOp(expr left, operator op, expr right)
| UnaryOp(unaryop op, expr operand)
| Lambda(arguments args, expr body)
| IfExp(expr test, expr body, expr orelse)
| Dict(expr* keys, expr* values)
| ListComp(expr elt, comprehension* generators)
| GeneratorExp(expr elt, comprehension* generators)
| Yield(expr? value)
| Compare(expr left, cmpop* ops, expr* comparators)
| Call(expr func, expr* args, keyword* keywords, expr? starargs, expr? kwargs)
| Repr(expr value)
| Num(object n)
| Str(string s)

| Attribute(expr value, identifier attr, expr_context ctx)
| Subscript(expr value, slice slice, expr_context ctx)
| Name(identifier id, expr_context ctx)
| List(expr* elts, expr_context ctx)
| Tuple(expr* elts, expr_context ctx)

expr_context = Load | Store | Del | AugLoad | AugStore | Param

slice = Ellipsis
| Slice(expr? lower, expr? upper, expr? step)
| ExtSlice(slice* dims)
| Index(expr value)

boolop = And | Or

operator = Add | Sub | Mult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv

unaryop = Invert | Not | UAdd | USub

cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn

comprehension = (expr target, expr iter, expr* ifs)

excepthandler = ExceptHandler(expr? type, expr? name, stmt* body)

arguments = (expr* args, identifier? vararg, identifier? kwarg, expr* defaults)
keyword = (identifier arg, expr value)

alias = (identifier name, identifier? asname)
}
85 changes: 0 additions & 85 deletions py2js.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,5 @@
#! /usr/bin/env python

"""
Python grammar, the AST classes contain those arguments as properties.
module Python version "$Revision: 62047 $"
{
mod = Module(stmt* body)
| Interactive(stmt* body)
| Expression(expr body)
stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list)
| ClassDef(identifier name, expr* bases, stmt* body, expr *decorator_list)
| Return(expr? value)
| Delete(expr* targets)
| Assign(expr* targets, expr value)
| AugAssign(expr target, operator op, expr value)
| Print(expr? dest, expr* values, int nl)
| For(expr target, expr iter, stmt* body, stmt* orelse)
| While(expr test, stmt* body, stmt* orelse)
| If(expr test, stmt* body, stmt* orelse)
| With(expr context_expr, expr? optional_vars, stmt* body)
| Raise(expr? type, expr? inst, expr? tback)
| TryExcept(stmt* body, excepthandler* handlers, stmt* orelse)
| TryFinally(stmt* body, stmt* finalbody)
| Assert(expr test, expr? msg)
| Import(alias* names)
| ImportFrom(identifier module, alias* names, int? level)
| Exec(expr body, expr? globals, expr? locals)
| Global(identifier* names)
| Expr(expr value)
| Pass | Break | Continue
expr = BoolOp(boolop op, expr* values)
| BinOp(expr left, operator op, expr right)
| UnaryOp(unaryop op, expr operand)
| Lambda(arguments args, expr body)
| IfExp(expr test, expr body, expr orelse)
| Dict(expr* keys, expr* values)
| ListComp(expr elt, comprehension* generators)
| GeneratorExp(expr elt, comprehension* generators)
| Yield(expr? value)
| Compare(expr left, cmpop* ops, expr* comparators)
| Call(expr func, expr* args, keyword* keywords, expr? starargs, expr? kwargs)
| Repr(expr value)
| Num(object n)
| Str(string s)
| Attribute(expr value, identifier attr, expr_context ctx)
| Subscript(expr value, slice slice, expr_context ctx)
| Name(identifier id, expr_context ctx)
| List(expr* elts, expr_context ctx)
| Tuple(expr* elts, expr_context ctx)
expr_context = Load | Store | Del | AugLoad | AugStore | Param
slice = Ellipsis
| Slice(expr? lower, expr? upper, expr? step)
| ExtSlice(slice* dims)
| Index(expr value)
boolop = And | Or
operator = Add | Sub | Mult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv
unaryop = Invert | Not | UAdd | USub
cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn
comprehension = (expr target, expr iter, expr* ifs)
excepthandler = ExceptHandler(expr? type, expr? name, stmt* body)
arguments = (expr* args, identifier? vararg, identifier? kwarg, expr* defaults)
keyword = (identifier arg, expr value)
alias = (identifier name, identifier? asname)
}
"""

import ast
import inspect
from optparse import OptionParser
Expand Down

0 comments on commit cebdd93

Please sign in to comment.