Tweaking out the machine voodoo.

This commit is contained in:
Paul R. Tagliamonte 2013-03-13 21:30:17 -04:00
parent 1a9e2f66d8
commit 36bc16211e
3 changed files with 13 additions and 6 deletions

View File

@ -87,11 +87,12 @@ class Machine(object):
if self.submachine: if self.submachine:
self.submachine.process([char]) self.submachine.process([char])
if type(self.submachine.state) == Idle: if type(self.submachine.state) == Idle:
if len(self.submachine.nodes) != 1: if len(self.submachine.nodes) > 1:
raise LexException("Funky Submachine stuff") raise LexException("Funky Submachine stuff")
nodes = self.submachine.nodes nodes = self.submachine.nodes
self.submachine = None self.submachine = None
if nodes != []:
self.state.nodes.append(nodes[0]) self.state.nodes.append(nodes[0])
continue continue

View File

@ -153,6 +153,11 @@ class ListeyThing(State):
self.machine.sub(String) self.machine.sub(String)
return return
if char == ";":
self.commit()
self.machine.sub(Comment)
return
if char == self.end_char: if char == self.end_char:
return Idle return Idle

View File

@ -26,7 +26,8 @@
(route "/" [] (render-template "repl.html")) (route "/" [] (render-template "repl.html"))
(post-route "/hy2py" [] (post-route "/hy2py" []
(try (hy-to-py (get request.form "code")) (try
(hy-to-py (get request.form "code"))
(catch LexException (err "Incomplete Code.")) (catch LexException (err "Incomplete Code."))
(catch HyError (err "Generic error during processing.")) (catch HyError (err "Generic error during processing."))
(catch Exception (err "Erm, you broke something.")))) (catch Exception (err "Erm, you broke something."))))