Commits

Marko Tasic committed 347c93f

added uast

  • Participants
  • Parent commits bad1f45

Comments (0)

Files changed (2)

uco/emu/compiler.py

 import itertools
 from collections import OrderedDict as odict
 
+from . import uast
+
 logging.basicConfig(
     # format='%(asctime)s %(levelname)s %(funcName)s: %(message)s', 
     # format='%(levelname)s %(message)s %(funcName)s', 
+import os
+import sys
+
+class UAST(object):
+    def __init__(self, **kwargs):
+        for k, v in kwargs.items():
+            setattr(self, k, v)
+    
+    def group(self):
+        raise NotImplementedError('')
+    
+    def compile(self, expect=None, indent=0):
+        raise NotImplementedError('')
+
+class Module(UAST):
+    '''
+    Module(stmt* body)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Interactive(UAST):
+    '''
+    Interactive(stmt* body)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Expression(UAST):
+    '''
+    Expression(expr body)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class FunctionDef(UAST):
+    '''
+    FunctionDef(identifier name, arguments args, 
+        stmt* body, expr* decorator_list, expr? returns)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class ClassDef(UAST):
+    '''
+    ClassDef(identifier name, 
+        expr* bases,
+        keyword* keywords,
+        expr? starargs,
+        expr? kwargs,
+        stmt* body,
+        expr* decorator_list)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Return(UAST):
+    '''
+    Return(expr? value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Delete(UAST):
+    '''
+    Delete(expr* targets)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Assign(UAST):
+    '''
+    Assign(expr* targets, expr value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class AugAssign(UAST):
+    '''
+    AugAssign(expr target, operator op, expr value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class For(UAST):
+    '''
+    For(expr target, expr iter, stmt* body, stmt* orelse)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class While(UAST):
+    '''
+    While(expr test, stmt* body, stmt* orelse)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class If(UAST):
+    '''
+    If(expr test, stmt* body, stmt* orelse)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class With(UAST):
+    '''
+    With(withitem* items, stmt* body)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Raise(UAST):
+    '''
+    Raise(expr? exc, expr? cause)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Try(UAST):
+    '''
+    Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Assert(UAST):
+    '''
+    Assert(expr test, expr? msg)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Import(UAST):
+    '''
+    Import(alias* names)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class ImportFrom(UAST):
+    '''
+    ImportFrom(identifier? module, alias* names, int? level)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Global(UAST):
+    '''
+    Global(identifier* names)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Nonlocal(UAST):
+    '''
+    Nonlocal(identifier* names)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Expr(UAST):
+    '''
+    Expr(expr value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Pass(UAST):
+    '''
+    Pass
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Break(UAST):
+    '''
+    Break
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Continue(UAST):
+    '''
+    Continue
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class BoolOp(UAST):
+    '''
+    BoolOp(boolop op, expr* values)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class BinOp(UAST):
+    '''
+    BinOp(expr left, operator op, expr right)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class UnaryOp(UAST):
+    '''
+    UnaryOp(unaryop op, expr operand)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Lambda(UAST):
+    '''
+    Lambda(arguments args, expr body)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class IfExp(UAST):
+    '''
+    IfExp(expr test, expr body, expr orelse)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Dict(UAST):
+    '''
+    Dict(expr* keys, expr* values)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Set(UAST):
+    '''
+    Set(expr* elts)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class ListComp(UAST):
+    '''
+    ListComp(expr elt, comprehension* generators)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class SetComp(UAST):
+    '''
+    SetComp(expr elt, comprehension* generators)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class DictComp(UAST):
+    '''
+    DictComp(expr key, expr value, comprehension* generators)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class GeneratorExp(UAST):
+    '''
+    GeneratorExp(expr elt, comprehension* generators)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Yield(UAST):
+    '''
+    Yield(expr? value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class YieldFrom(UAST):
+    '''
+    YieldFrom(expr? value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Compare(UAST):
+    '''
+    Compare(expr left, cmpop* ops, expr* comparators)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Call(UAST):
+    '''
+    Call(expr func, expr* args, keyword* keywords,
+        expr? starargs, expr? kwargs)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Num(UAST):
+    '''
+    Num(object n)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Str(UAST):
+    '''
+    Str(string s)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Bytes(UAST):
+    '''
+    Bytes(bytes s)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Ellipsis(UAST):
+    '''
+    Ellipsis
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Attribute(UAST):
+    '''
+    Attribute(expr value, identifier attr, expr_context ctx)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Subscript(UAST):
+    '''
+    Subscript(expr value, slice slice, expr_context ctx)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Starred(UAST):
+    '''
+    Starred(expr value, expr_context ctx)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Name(UAST):
+    '''
+    Name(identifier id, expr_context ctx)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class List(UAST):
+    '''
+    List(expr* elts, expr_context ctx) 
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Tuple(UAST):
+    '''
+    Tuple(expr* elts, expr_context ctx)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Load(UAST):
+    '''
+    Load
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Store(UAST):
+    '''
+    Store
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Del(UAST):
+    '''
+    Del
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class AugLoad(UAST):
+    '''
+    AugLoad
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class AugStore(UAST):
+    '''
+    AugStore
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Param(UAST):
+    '''
+    Param
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Slice(UAST):
+    '''
+    Slice(expr? lower, expr? upper, expr? step)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class ExtSlice(UAST):
+    '''
+    ExtSlice(slice* dims)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Index(UAST):
+    '''
+    Index(expr value) 
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class And(UAST):
+    '''
+    And
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Or(UAST):
+    '''
+    Or
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Add(UAST):
+    '''
+    Add
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Sub(UAST):
+    '''
+    Sub
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Mult(UAST):
+    '''
+    Mult
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Div(UAST):
+    '''
+    Div
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Mod(UAST):
+    '''
+    Mod
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Pow(UAST):
+    '''
+    Pow
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class LShift(UAST):
+    '''
+    LShift
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class RShift(UAST):
+    '''
+    RShift
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class BitOr(UAST):
+    '''
+    BitOr
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class BitXor(UAST):
+    '''
+    BitXor
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class BitAnd(UAST):
+    '''
+    BitAnd
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class FloorDiv(UAST):
+    '''
+    FloorDiv
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Invert(UAST):
+    '''
+    Invert
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Not(UAST):
+    '''
+    Not
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class UAdd(UAST):
+    '''
+    UAdd
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class USub(UAST):
+    '''
+    USub
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Eq(UAST):
+    '''
+    Eq
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class NotEq(UAST):
+    '''
+    NotEq
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Lt(UAST):
+    '''
+    Lt
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class LtE(UAST):
+    '''
+    LtE
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Gt(UAST):
+    '''
+    Gt
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class GtE(UAST):
+    '''
+    GtE
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Is(UAST):
+    '''
+    Is
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class IsNot(UAST):
+    '''
+    IsNot
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class In(UAST):
+    '''
+    In
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class NotIn(UAST):
+    '''
+    NotIn
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Comprehension(UAST):
+    '''
+    comprehension = (expr target, expr iter, expr* ifs)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class ExceptHandler(UAST):
+    '''
+    ExceptHandler(expr? type, identifier? name, stmt* body)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Arguments(UAST):
+    '''
+    arguments = (arg* args, identifier? vararg, expr? varargannotation,
+        arg* kwonlyargs, identifier? kwarg,
+        expr? kwargannotation, expr* defaults,
+        expr* kw_defaults)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Arg(UAST):
+    '''
+    arg = (identifier arg, expr? annotation)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Keyword(UAST):
+    '''
+    keyword = (identifier arg, expr value)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class Alias(UAST):
+    '''
+    alias = (identifier name, identifier? asname)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass
+
+class WithItem(UAST):
+    '''
+    withitem = (expr context_expr, expr? optional_vars)
+    '''
+    def group(self):
+        pass
+    
+    def compile(self, expect=None, indent=0):
+        pass