<s> from construct . core import Container <EOL> from construct . adapters import Adapter <EOL> class AstNode ( Container ) : <EOL> def __init__ ( self , nodetype , ** kw ) : <EOL> Container . __init__ ( self ) <EOL> self . nodetype = nodetype <EOL> for k , v in sorted ( kw . iteritems ( ) ) : <EOL> setattr ( self , k , v ) <EOL> def accept ( self , visitor ) : <EOL> return getattr ( visitor , "<STR_LIT>" % ( self . nodetype , ) ) ( self ) <EOL> class AstTransformator ( Adapter ) : <EOL> def _decode ( self , obj , context ) : <EOL> return self . to_ast ( obj , context ) <EOL> def _encode ( self , obj , context ) : <EOL> return self . to_cst ( obj , context ) </s>
