Esempio n. 1
0
def parse(input, interpreter=None, ctx=None, out=None, words=None):
	"""\
		Read non-blocking input, run through the tokenizer, pass to the
		parser.
		"""
	if ctx is None: ctx=Context
	if ctx is Context or "filename" not in ctx:
		ctx = ctx(filename=(input if isinstance(input,basestring) else u"‹stdin›"))
	if out is not None:
		ctx.out = out
	else:
		ctx.out = sys.stdout
		if "words" not in ctx:
			if words is None: words = global_words(ctx)
			ctx.words = words

	if interpreter is None:
		from homevent.interpreter import Interpreter
		interpreter = Interpreter
	if isinstance(interpreter,type):
		interpreter = interpreter(ctx)

	if isinstance(input,basestring):
		input = open(input,"rU")

	parser = Parser(interpreter=interpreter, input=input, ctx=ctx)
	parser.run()
Esempio n. 2
0
	def __init__(self, ctx=None):
		super(Interpreter,self).__init__(ctx)
		if "words" not in ctx:
			from homevent.statement import global_words
			self.ctx = ctx(words=global_words(ctx=ctx))
		else:
			self.ctx = ctx
Esempio n. 3
0
	def on_connect(self):
		global conn_seq
		conn_seq += 1
		self.name = self.dest + ("n"+str(conn_seq),)
		self.ctx = Context()
		self.ctx.words = global_words(self.ctx)
		self.workers = set()
		simple_event(self.ctx,"rpc","connect",*self.name)
		Collected.__init__(self)