Merge branch 'master' into pr/294
This commit is contained in:
commit
e053157ff1
1
AUTHORS
1
AUTHORS
@ -17,3 +17,4 @@
|
||||
* Bob Tolbert <bob@tolbert.org>
|
||||
* Ralph Möritz <ralph.moeritz@outlook.com>
|
||||
* Josh McLaughlin <josh@phear.cc>
|
||||
* Berker Peksag <berker.peksag@gmail.com>
|
||||
|
@ -2,6 +2,8 @@
|
||||
Hacking on hy
|
||||
===============
|
||||
|
||||
.. highlight:: bash
|
||||
|
||||
Join our hyve!
|
||||
==============
|
||||
|
||||
@ -21,24 +23,39 @@ Hack!
|
||||
|
||||
Do this:
|
||||
|
||||
1. create a `Python virtual environment
|
||||
<https://pypi.python.org/pypi/virtualenv>`_
|
||||
2. (optional) go to https://github.com/paultag/hy and fork it
|
||||
3. get the source code::
|
||||
1. create a `virtual environment
|
||||
<https://pypi.python.org/pypi/virtualenv>`_::
|
||||
|
||||
$ git clone git://github.com/paultag/hy.git
|
||||
$ virtualenv venv
|
||||
|
||||
(or use your fork)
|
||||
4. install for hacking::
|
||||
and activate it::
|
||||
|
||||
$ python setup.py develop
|
||||
$ . venv/bin/activate
|
||||
|
||||
5. install other develop-y requirements::
|
||||
or use `virtualenvwrapper <http://virtualenvwrapper.readthedocs.org/en/latest/#introduction>`_
|
||||
to create and manage your virtual environment::
|
||||
|
||||
$ mkvirtualenv hy
|
||||
$ workon hy
|
||||
|
||||
2. get the source code::
|
||||
|
||||
$ git clone https://github.com/hylang/hy.git
|
||||
|
||||
or use your fork::
|
||||
|
||||
$ git clone git@github.com:<YOUR_USERNAME>/hy.git
|
||||
3. install for hacking::
|
||||
|
||||
$ cd hy/
|
||||
$ pip install -e .
|
||||
|
||||
4. install other develop-y requirements::
|
||||
|
||||
$ pip install -r requirements-dev.txt
|
||||
|
||||
6. do awesome things; make someone shriek in delight/disgust at what
|
||||
you have wrought
|
||||
5. do awesome things; make someone shriek in delight/disgust at what
|
||||
you have wrought.
|
||||
|
||||
|
||||
Test!
|
||||
@ -60,7 +77,7 @@ Document!
|
||||
Documentation is located in ``docs/``. We use `Sphinx
|
||||
<http://sphinx-doc.org/>`_.
|
||||
|
||||
To build the docs in html::
|
||||
To build the docs in HTML::
|
||||
|
||||
$ cd docs
|
||||
$ make html
|
||||
|
@ -24,8 +24,8 @@ languages.
|
||||
|
||||
* UTF-8 entities will be encoded using
|
||||
`punycode <http://en.wikipedia.org/wiki/Punycode>`_ and prefixed with
|
||||
`hy_`. For instance, `⚘` will become `hy_w7h`, and `♥` will become
|
||||
`hy_g6h`.
|
||||
`hy_`. For instance, `⚘` will become `hy_w7h`, `♥` will become `hy_g6h`,
|
||||
and `i♥u` will become `hy_iu_t0x`.
|
||||
|
||||
* Symbols that contain dashes will have them replaced with underscores. For
|
||||
example, `render-template` will become `render_template`.
|
||||
|
@ -19,10 +19,20 @@
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
try:
|
||||
import __builtin__ as builtins
|
||||
except ImportError:
|
||||
import builtins # NOQA
|
||||
import sys
|
||||
|
||||
PY3 = sys.version_info[0] >= 3
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
if PY3:
|
||||
str_type = str
|
||||
else:
|
||||
str_type = unicode # NOQA
|
||||
|
||||
if PY3:
|
||||
long_type = int
|
||||
else:
|
||||
long_type = long # NOQA
|
@ -41,11 +41,7 @@ from hy.models.expression import HyExpression
|
||||
from hy.models.string import HyString
|
||||
from hy.models.symbol import HySymbol
|
||||
|
||||
|
||||
try:
|
||||
import __builtin__ as builtins
|
||||
except ImportError:
|
||||
import builtins
|
||||
from hy._compat import builtins
|
||||
|
||||
|
||||
class HyQuitter(object):
|
||||
|
@ -37,7 +37,7 @@ from hy.models.list import HyList
|
||||
from hy.models.dict import HyDict
|
||||
|
||||
from hy.macros import require, process
|
||||
from hy.util import str_type
|
||||
from hy._compat import str_type
|
||||
import hy.importer
|
||||
|
||||
import traceback
|
||||
@ -610,7 +610,7 @@ class HyASTCompiler(object):
|
||||
level)
|
||||
imports.update(f_imports)
|
||||
if splice:
|
||||
to_add = f_contents
|
||||
to_add = HyExpression([HySymbol("list"), f_contents])
|
||||
else:
|
||||
to_add = HyList([f_contents])
|
||||
|
||||
@ -966,31 +966,6 @@ class HyASTCompiler(object):
|
||||
col_offset=expression.start_column)
|
||||
return ret
|
||||
|
||||
@builds("print")
|
||||
def compile_print_expression(self, expr):
|
||||
call = expr.pop(0) # print
|
||||
values, ret = self._compile_collect(expr)
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
call = self.compile(call)
|
||||
ret += call
|
||||
ret += ast.Call(func=call.expr,
|
||||
args=values,
|
||||
keywords=[],
|
||||
starargs=None,
|
||||
kwargs=None,
|
||||
lineno=expr.start_line,
|
||||
col_offset=expr.start_column)
|
||||
else:
|
||||
ret += ast.Print(
|
||||
lineno=expr.start_line,
|
||||
col_offset=expr.start_column,
|
||||
dest=None,
|
||||
values=values,
|
||||
nl=True)
|
||||
|
||||
return ret
|
||||
|
||||
@builds("break")
|
||||
def compile_break_expression(self, expr):
|
||||
ret = ast.Break(lineno=expr.start_line,
|
||||
|
@ -43,15 +43,11 @@ except ImportError:
|
||||
import hy.macros
|
||||
import hy.compiler
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
except ImportError:
|
||||
import builtins as __builtin__ # NOQA
|
||||
|
||||
from hy._compat import builtins
|
||||
|
||||
PATH = [hy.compiler._compile_table,
|
||||
hy.macros._hy_macros,
|
||||
__builtin__.__dict__]
|
||||
builtins.__dict__]
|
||||
|
||||
|
||||
class Completer(object):
|
||||
|
@ -32,17 +32,15 @@ import ast
|
||||
import os
|
||||
import __future__
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
long_type = int
|
||||
else:
|
||||
import __builtin__
|
||||
long_type = long # NOQA
|
||||
from hy._compat import builtins, long_type
|
||||
|
||||
|
||||
def ast_compile(ast, filename, mode):
|
||||
"""Compile AST.
|
||||
Like Python's compile, but with some special flags."""
|
||||
return compile(ast, filename, mode, __future__.CO_FUTURE_DIVISION)
|
||||
flags = (__future__.CO_FUTURE_DIVISION |
|
||||
__future__.CO_FUTURE_PRINT_FUNCTION)
|
||||
return compile(ast, filename, mode, flags)
|
||||
|
||||
|
||||
def import_buffer_to_hst(buf):
|
||||
@ -127,10 +125,7 @@ def write_hy_as_pyc(fname):
|
||||
code = ast_compile(_ast, fname, "exec")
|
||||
cfile = "%s.pyc" % fname[:-len(".hy")]
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
open_ = open
|
||||
else:
|
||||
open_ = __builtin__.open
|
||||
open_ = builtins.open
|
||||
|
||||
with open_(cfile, 'wb') as fc:
|
||||
if sys.version_info[0] >= 3:
|
||||
|
@ -26,7 +26,7 @@ from hy.models.integer import HyInteger
|
||||
from hy.models.float import HyFloat
|
||||
from hy.models.complex import HyComplex
|
||||
from hy.models.dict import HyDict
|
||||
from hy.util import str_type
|
||||
from hy._compat import str_type
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
|
@ -24,7 +24,6 @@ class HyObject(object):
|
||||
Generic Hy Object model. This is helpful to inject things into all the
|
||||
Hy lexing Objects at once.
|
||||
"""
|
||||
pass
|
||||
|
||||
def replace(self, other):
|
||||
if isinstance(other, HyObject):
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from hy.models import HyObject
|
||||
from hy.util import str_type
|
||||
from hy._compat import str_type
|
||||
|
||||
|
||||
class HyKeyword(HyObject, str_type):
|
||||
|
@ -19,7 +19,7 @@
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from hy.models import HyObject
|
||||
from hy.util import str_type
|
||||
from hy._compat import str_type
|
||||
|
||||
|
||||
class HyString(HyObject, str_type):
|
||||
|
@ -26,7 +26,6 @@ from hy.compiler import hy_compile, HyCompileError, HyTypeError
|
||||
from hy.lex import tokenize
|
||||
|
||||
import ast
|
||||
import sys
|
||||
|
||||
|
||||
def _ast_spotcheck(arg, root, secondary):
|
||||
@ -369,10 +368,7 @@ def test_ast_lambda_lists():
|
||||
def test_ast_print():
|
||||
code = can_compile("(print \"foo\")").body[0]
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
assert type(code.value) == ast.Call
|
||||
return
|
||||
assert type(code) == ast.Print
|
||||
assert type(code.value) == ast.Call
|
||||
|
||||
|
||||
def test_ast_tuple():
|
||||
|
@ -82,3 +82,14 @@
|
||||
(setv opt (quote &optional))
|
||||
(assert (isinstance opt hy.HyLambdaListKeyword))
|
||||
(assert (= (str opt) "&optional")))
|
||||
|
||||
(defmacro doodle [&rest body]
|
||||
`(do ~@body))
|
||||
|
||||
(defn test-unquote-splice []
|
||||
"NATIVE: test unquote-splice does what's intended"
|
||||
(assert (=
|
||||
(doodle
|
||||
[1 2 3]
|
||||
[4 5 6])
|
||||
[4 5 6])))
|
||||
|
Loading…
Reference in New Issue
Block a user