def _createClassCode(self,
                      inClass,
                      inUserCode
                      ):
     
     scope = Scope()
     self._initClassScope(scope, inClass)
     scope.set_user_code(inUserCode)
             
     parser = Parser(scope)
     
     return parser.parseFile(self._templatePath("class.tmpl"))
 def _createIntfCode(self,
                     inIntf,
                     inUserCode
                     ):
     
     scope = Scope()
     self._initIntfScope(scope, inIntf)
     scope.set_user_code(inUserCode)
             
     parser = Parser(scope)
     
     return parser.parseFile(self._templatePath("intf.tmpl"))
    def _createIntfCode(self, inIntf, inUserCode):

        scope = Scope()
        scope.set_user_code(inUserCode)
        scope.addSymbol("interface", inIntf)
        scope.addSymbol("absName", self._absName)
        scope.addSymbol("argList", self._argList)

        return Parser(scope).parseFile(self._templatePath("intf.tmpl"))
    def _createClassCode(self, inClass, inUserCode):

        scope = Scope()
        scope.set_user_code(inUserCode)
        scope.addSymbol("class", inClass)
        scope.addSymbol("absName", self._absName)
        scope.addSymbol("argList", self._argList)
        scope.addSymbol("hasSuperClass", self._hasSuperClass)
        scope.addSymbol("intfList", self._intfList)
        scope.addSymbol("overwritten", self._overwrittenMethods(inClass))
        scope.addSymbol("propertyType", self._propertyType)

        return Parser(scope).parseFile(self._templatePath("class.tmpl"))
Ejemplo n.º 5
0
                         io_match 
                         ):
        lv_symbol = io_match.group( 1 )
        lo_match = Translator._go_func.search( lv_symbol )
        if not lo_match:
            rv_value = self.__mo_scope.getSymbolStr( lv_symbol )
        else:
            lv_funcname = lo_match.group(1)
            lv_args = self.__replaceSymbols( lo_match.group(2) )
            lt_args = [ lv_arg.strip()
                       for lv_arg in lv_args.split(",")
                       if lv_arg
                       ]
            rv_value = self.__mo_scope.getFuncSymbol( lv_funcname, lt_args )
        return rv_value
    
if __name__ == "__main__":
    
    def lower(io_scope,iv_string):
        return iv_string.lower()
    
    go_scope = Scope()
    go_scope.addSymbol( "class", "Person" )
    go_scope.addSymbol( "lower", lower )
    
    Translator.set_symbol_delimiter( "@" )
    gv_line = "class C@lower( @@class@@ )@: pass"
        
    print Translator(go_scope).translate( gv_line )