Exemple #1
0
 def process(self):
     self.response.headers['Content-Type'] = 'text/plain'
     
     waa = SlimCore()
     
     # register required modules
     ping = Ping()
     ping.waa = waa
     waa.register(ping, "mPing")
     
     lang = Lang()
     lang.waa = waa
     waa.register(lang, "mLang")
     
     str_stream = antlr3.ANTLRStringStream(self.request.get('code'))
     lexer = slimLexer(str_stream)
     tokens = antlr3.CommonTokenStream(lexer)
     parser = slimParser(tokens)
     parser.core = waa
     
     old_stdout = sys.stdout
     sys.stdout = myout = StringIO()
     
     parser.start()
     
     sys.stdout = old_stdout
     
     self.response.out.write(myout.getvalue())
Exemple #2
0
def parse(stream, core):
    """ Parses the given stream with the slim grammar for a given core. 
    
    """
    lexer = slimLexer(stream)
    tokens = antlr3.CommonTokenStream(lexer)
    parser = slimParser(tokens)
    parser.core = core
    parser.start()