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

9
bin/hy
View File

@ -1,11 +1,18 @@
#!/usr/bin/env python #!/usr/bin/env python
import hy
import sys 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 ast
import code import code
import readline import readline
import hy
from hy.lex.states import Idle, LexException from hy.lex.states import Idle, LexException
from hy.lex.machine import Machine from hy.lex.machine import Machine
from hy.compiler import hy_compile 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 ; 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)) (defn evaluate [f] ((f (lambda [x] (+ x 1))) 0))

View File

@ -271,6 +271,9 @@ class Idle(State):
if char == ";": if char == ";":
return Comment return Comment
if char == "#":
return Hash
if char in WHITESPACE: if char in WHITESPACE:
return return
@ -292,3 +295,21 @@ class Comment(State):
if char == "\n": if char == "\n":
return Idle 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))