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,12 +87,13 @@ 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
self.state.nodes.append(nodes[0]) if nodes != []:
self.state.nodes.append(nodes[0])
continue continue
new = self.state.process(char) new = self.state.process(char)

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
(catch LexException (err "Incomplete Code.")) (hy-to-py (get request.form "code"))
(catch HyError (err "Generic error during processing.")) (catch LexException (err "Incomplete Code."))
(catch Exception (err "Erm, you broke something.")))) (catch HyError (err "Generic error during processing."))
(catch Exception (err "Erm, you broke something."))))