Exemplo n.º 1
0
 def finish_send(self):
     f = self.current_frame
     recipient, message, args = f[0].data, f[1].data, f[2:]
     print recipient, message, args
     recipient = send(self.context, 'lookup', recipient)
     result = send(recipient, message, *args)
     if result is not None:
         self.frame_stack[-1].append(result)
     self.current_frame = self.frame_stack.pop()
Exemplo n.º 2
0
 def finish_send(self):
   f = self.current_frame
   recipient, message, args = f[0].data, f[1].data, f[2:]
   print recipient, message, args
   recipient = send(self.context, 'lookup', recipient)
   result = send(recipient, message, *args)
   if result is not None:
     self.frame_stack[-1].append(result)
   self.current_frame = self.frame_stack.pop()
Exemplo n.º 3
0
 def __init__(self, text, context=None):
     self.stream = iter(text)
     self.advance()
     self.success = True
     self.current_frame = []
     self.frame_stack = []
     if context is None:
         context = send(object_vt, 'delegated')
     else:
         context = send(context, 'delegated')
     send(context, 'addMethod', 'compiler', self)
     send(context, 'addMethod', 'context', context)
     self.context = context
Exemplo n.º 4
0
 def __init__(self, text, context=None):
   self.stream = iter(text)
   self.advance()
   self.success = True
   self.current_frame = []
   self.frame_stack = []
   if context is None:
     context = send(object_vt, 'delegated')
   else:
     context = send(context, 'delegated')
   send(context, 'addMethod', 'compiler', self)
   send(context, 'addMethod', 'context', context)
   self.context = context
Exemplo n.º 5
0
     ( 12 'neato' )


  .'''

    c = Context(source, eval_context)

    little_language(c)
    print
    print c
    print c.context.data.keys()
    print

    for it in c.current_frame:
        send(it, 'eval', print_context)
        print
    print

    c = Context(source, eval_context)
    print 'Parsing...'
    print
    little_language(c)
    print 'Evaluating...'
    print
    for it in c.current_frame:
        send(it, 'eval', c.context)
    print

    send(eval_context, 'addMethod', 'multiply', lambda x, y: y * x)
    send(eval_context, 'addMethod', 'divide', lambda x, y: x / float(y))
Exemplo n.º 6
0
     ( 12 'neato' )


  .'''

  c = Context(source, eval_context)

  little_language(c)
  print
  print c
  print c.context.data.keys()
  print

  for it in c.current_frame:
    send(it, 'eval', print_context)
    print
  print

  c = Context(source, eval_context)
  print 'Parsing...' ; print
  little_language(c)
  print 'Evaluating...' ; print
  for it in c.current_frame:
    send(it, 'eval', c.context)
  print

  send(eval_context, 'addMethod', 'multiply', lambda x, y: y * x)
  send(eval_context, 'addMethod', 'divide', lambda x, y: x / float(y))
  print 'Evaluating...' ; print
  for it in c.current_frame: