Adding in #! as a comment

This commit is contained in:
Paul R. Tagliamonte 2013-03-14 21:03:33 -04:00
parent 3c288519ac
commit 7741b2e1dd
4 changed files with 33 additions and 7 deletions

5
TODO
View File

@ -12,8 +12,6 @@
- New Builtins:
+ While
+ Pass
- New macros:
+ loop
@ -26,7 +24,6 @@
- Better Exception handling
+ linenos in the dump
+ except IOError as E: # <-- implement
- Tuples
@ -36,8 +33,6 @@
- car / cdr / first / rest
- hyrepl
- pyc compiler
- core tests (odd? even? true? false?) which

9
bin/hy
View File

@ -1,11 +1,18 @@
#!/usr/bin/env python
import hy
import sys
if len(sys.argv) > 1:
from hy.importer import import_file_to_module
import_file_to_module("__main__", sys.argv[1])
sys.exit(0) # right?
import ast
import code
import readline
import hy
from hy.lex.states import Idle, LexException
from hy.lex.machine import Machine
from hy.compiler import hy_compile

5
eg/nonfree/halting-problem/halting.hy Normal file → Executable file
View File

@ -1,5 +1,8 @@
#!/usr/bin/env hy
; Very much a knockoff (straight port) of Dan Gulotta's 2013 MIT Mystery Hunt
; puzzle "The Halting Problem".
; puzzle "The Halting Problem". His Copyright terms are unclear, so presume
; that this is distributable, but not free.
(defn evaluate [f] ((f (lambda [x] (+ x 1))) 0))

View File

@ -271,6 +271,9 @@ class Idle(State):
if char == ";":
return Comment
if char == "#":
return Hash
if char in WHITESPACE:
return
@ -292,3 +295,21 @@ class Comment(State):
if char == "\n":
return Idle
class Hash(State):
"""
Hash state
"""
def process(self, char):
"""
State transitions:
- ! - Comment
"""
if char == "!":
return Comment
raise LexException("Unknown char (Hash state): `%s`" % (char))