Commit Graph

461 Commits

Author SHA1 Message Date
Foxboron
d82636958b added for and with macros
Fixed up anaphoric.hy and added the tests too native_tests/__init__.py

added __init__.hy
2013-12-29 16:50:21 +01:00
Bob Tolbert
55a7ab1667 add nil as synonym for None 2013-12-27 13:50:19 -07:00
Bob Tolbert
b2bb161cb0 Merge pull request #391 from olasd/bugfix/apply-method-call
Fix apply with method calls
2013-12-27 11:46:59 -08:00
Paul Tagliamonte
1dc26148c6 Merge branch 'master' into paultag/ana/if
Conflicts:
	hy/contrib/anaphoric.hy
2013-12-26 17:57:29 -05:00
Abhishek L
c69c14cc7d contrib/anaphoric: More anaphoric macros added
* hy/contrib/anaphoric.hy: The following anaphoric macros have been
  added
  `ap-reject` : Opposite of ap-filter, yields the elements when a `pred`
  evaluates to false
  `ap-dotimes` : Execute body forms (possibly for side-effects) n times
  with `it` bound from 0 to n-1
  `ap-first` : return the first element that passes predicate
  `ap-last`  : return the last element that passes predicate
  `ap-reduce`: anaphoric form of reduce that allows `acc` and `it` to
  create a function that is applied over the list

* docs/contrib/anaphoric.rst: updated docs to reflect these changes

* tests/__init__.py: updated to explicitly include tests for anaphoric
  macros
2013-12-26 05:57:06 +02:00
Paul Tagliamonte
6172b60e75 Add anaphoric if statement 2013-12-25 12:14:26 -05:00
Nicolas Dandrimont
cfbc792957 Fix apply with method calls
Apply didn't work on method calls (i.e. `(apply .foo [bar]) broke).
This slipped through because there were no tests of this behavior. I noticed
it while trying to merge the `meth` fixes.
2013-12-23 21:02:45 +01:00
Foxboron
c9fdd40c9f Hy reader macros #377
Added first iteration of reader macros
Refactored defmacro and defreader
Added test inn hy/tests/lex/test_lex.py
Added new test in hy/tests/native/tests
Added new test in hy/tests/macros.

changed the error given in the dispatch macro and added some handling for missing symbol and invalid characters
2013-12-23 14:33:51 +01:00
Nicolas Dandrimont
1a701d4dc4 Whitespace fix 2013-12-22 20:04:12 +01:00
Nicolas Dandrimont
ec2b5fb7ad Merge branch 'kwapply-macro' of https://github.com/Willyfrog/hy into Willyfrog-kwapply-macro
Conflicts:
	hy/core/language.hy
	hy/core/macros.hy
	tests/native_tests/language.hy
2013-12-22 20:03:00 +01:00
Nicolas Dandrimont
ceb612f385 Merge branch 'fix/arith-identity' of https://github.com/theanalyst/hy into theanalyst-fix/arith-identity 2013-12-22 19:32:10 +01:00
Nicolas Dandrimont
799c39ffad Implement del
Closes #385.
2013-12-22 20:26:57 +02:00
Guillermo Vaya
0109234eb7 Added meth tests by mocking a Flask app 2013-12-20 21:16:56 +01:00
Bob Tolbert
c80e3c75a0 Adding automatic gensym macro
Adding to the manual gensym for macros are 2 new
macros, but very literal from the CL in
letoverlambda.

The first is the (with-gensyms ...) macro that
can generate a small set of syms for a macro. Works
something like:

(defmacro adder2 [A B]
  (with-gensyms [a b]
    `(let [[~a ~A] [~b ~B]]
       (+ ~a ~b))))

and ~a and ~b will be replaced with (gensym "a") and
(gensym "b") respectively.

Then the final macro is a new defmacro that will automatically
replace symbols prefaced with "g!" with a new gensym based on the
rest of the symbol. So in this final version of 'nif':

(defmacro/g! nif4 (expr pos zero neg)
  `(let [[~g!result ~expr]]
     (cond [(pos? ~g!result) ~pos]
           [(zero? ~g!result) ~zero]
           [(neg? ~g!result) ~neg])))

all uses of ~g!result will be replaced with (gensym "result").
2013-12-15 18:47:46 -07:00
Bob Tolbert
f5d88bb108 gensym in Hy
Simple implementation of gensym in Hy.

Returns a new HySymbol.

Usable in macros like:

(defmacro nif [expr pos zero neg]
  (let [[g (gensym)]]
    `(let [[~g ~expr]]
       (cond [(pos? ~g) ~pos]
             [(zero? ~g) ~zero]
             [(neg? ~g) ~neg]))))

This addresses all the general comments about (gensym), and doesn't
try to implement "auto-gensym" yet. But clearly the macro approach
instead of the pre-processor approach (as described in the
letoverlambda (http://letoverlambda.com/index.cl/guest/chap3.html#sec_5)
is the way to go
2013-12-15 12:36:36 -07:00
Abhishek L
f72ff53f41 Operators + and * work without args, fixes #372
Like other lisps, operators `+` and `*` return their identity values
when called with no arguments. Also with a single operand they return
the operand.

This fixes #372
2013-12-16 00:04:43 +05:30
Morten Linderud
c11b231c1c Merge pull request #328 from berkerpeksag/add-astor
Add astor to install_requires.
2013-12-11 08:13:03 -08:00
Berker Peksag
e674eb4b56 Explicitly skip the skipped test in test_bin. 2013-12-10 19:43:56 +02:00
Berker Peksag
3e8941cdde Convert stdout and stderr to UTF-8 properly in the run_cmd helper. 2013-12-10 18:59:06 +02:00
Berker Peksag
870c136469 Add astor to install_requires.
`hy --spy` fails on hy 0.9.11.

    $ hy --spy
    hy 0.9.11
    => (type "hy")
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/hy/cmdline.py", line 68, in print_python_code
        import astor.codegen
    ImportError: No module named astor.codegen
2013-12-10 17:46:45 +02:00
Abhishek L
948e6d34c7 Merge branch master onto pr/284
Conflicts:
	hy/core/language.hy
2013-12-06 20:07:39 +05:30
Morten Linderud
699396b5a3 Merge pull request #358 from theanalyst/feature/macros-none
Allow macros to return None, fixes #357
2013-12-06 03:53:44 -08:00
Abhishek L
f1c68bd51a Allow macros to return None, fixes #357
Allows Hy macros to return None, to test this

  (defmacro foo [])
  (foo)

Should work now
2013-12-06 00:27:45 +05:30
Nicolas Dandrimont
cc147512fc Merge branch 'paultag/feature/support-question-marks' of https://github.com/paultag/hy into paultag-paultag/feature/support-question-marks
Conflicts:
	hy/core/language.hy
2013-12-05 19:28:59 +01:00
Nicolas Dandrimont
f0a9149383 Merge branch 'string-cast' of https://github.com/Willyfrog/hy into Willyfrog-string-cast 2013-12-05 19:04:22 +01:00
Paul Tagliamonte
fd60a864eb Translate all foo? -> is_foo. Close #334
The fancypants Hy award goes to Nick for coming up with the quoted
symbol hack for exports. This broke with foo?, since the export string
needs to be is_foo, but using a quoted string will pick up the change
due to it being a Symbol.

Mad clown love for that, @olasd.
2013-12-01 15:03:31 -05:00
Paul Tagliamonte
c255607205 don't test the halting problem anymore. 2013-12-01 09:48:16 -05:00
agentultra
179017b9bd Move anaphoric macros to contrib module 2013-11-28 23:53:02 -05:00
agentultra
20df6a5532 Make --map-when accept a predicate function instead of a form
This makes it look a little cleaner:

    (list (--map-when odd? (* it 3) [1 2 3 4 5]))
2013-11-28 16:45:07 -05:00
agentultra
8e44cc3d9a Add --each-while and --map-when
A couple of more macros:

    hy> (--each-while [1 2 3 4 5] (< it 3) (print it))
    1
    2
    3
    hy>

```--each-while``` continues to evaluate the body form while the
predicate form is true for each element in the list.

```--map-when``` uses a predicate form to determine when to apply the
map form upon the element in the list:

    hy> (list (--map-when (even? it) (* it 3) [1 2 3 4]))
    [1, 6, 3, 12]
2013-11-28 16:15:23 -05:00
agentultra
2106a0e5d4 Add anaphoric versions of map, filter, and foreach
Anaphoric macros reduce the need to specify a lambda by binding a
special name in a form passed as a parameter to the macro. This allows
you to write more concise code:

    (= (list (--filter (even? it) [1 2 3 4])) [2 4])

This patch just adds a few basic ones. Other forms that can be
converted to anaphoric versions include reduce, remove, enumerate,
etc.
2013-11-28 13:23:09 -05:00
Nicolas Dandrimont
26b052c76e language.hy whitespace fix 2013-11-02 20:50:21 +01:00
Nicolas Dandrimont
b8406dd920 Bootstrap a macro error-reporting test file 2013-11-02 20:50:21 +01:00
Nicolas Dandrimont
59e51166fb Allow calling kwapply with mixed names and dicts 2013-11-02 20:50:21 +01:00
Nicolas Dandrimont
83bb1513db Make apply api-compatible with python (args is not mandatory) 2013-11-02 20:50:20 +01:00
Guillermo Vaya
f5754b404e Define kwapply as a macro
Define apply if python3
Added apply tests
2013-11-02 18:18:16 +01:00
Sean B. Palmer
defccc6853 Added macroexpand-1 2013-10-11 13:50:10 +01:00
Sean B. Palmer
2e60d6b47b Added a simple test for macroexpand 2013-10-11 12:03:52 +01:00
Guillermo Vaya
34275fab60 Added type coercing to the right integer for the platform 2013-10-11 08:35:32 +02:00
Guillermo Vaya
f61d702788 Int conversion to long in py2.x
Updated to current master
    Droped HyInt/HyLong commit
2013-10-11 01:49:42 +02:00
Guillermo Vaya
25bf3dec42 Add a method for casting into byte string or unicode depending on python version 2013-10-03 23:39:17 +02:00
Nicolas Dandrimont
875d5f2ff5 Rewrite the bootstrap macros in hy
This gets rid of the dichotomy between bootstrap.py and macros.hy,
by making both files hy modules.

I added some error checking to make the macros more resilient. The
biggest (user-visible) change is the change in cond, which now only
accepts lists as arguments. Tests updated accordingly.

Closes: #176 (whoops, no more bootstrap)
2013-09-29 18:13:28 +02:00
Nicolas Dandrimont
d5bf328aa7 Cleanup the hy.macros module
Add comments to the functions, reorder, make the file clearer
2013-09-29 18:13:28 +02:00
Tuukka Turto
203dc4e6b2 Merge pullrequest #296 2013-09-29 08:49:52 +03:00
Nicolas Dandrimont
f6aa7e953d Always import __future__.print_statement in hy code
This allows us to drop the print special-casing in the
compiler, and makes behavior consistent in Python2/3.
2013-09-22 15:31:15 +02:00
Nicolas Dandrimont
6a7d97c286 Add test for unquote-splice behavior 2013-09-22 15:12:59 +02:00
Bob Tolbert
399ea1889a Second (smaller) set of native core functions
This rounds out the first pass at a set of core functions, adding
some that were not in the first PR.

From here I'm working on a contrib.seq and contrib.io module to
hold less obvious but maybe interesting native functions that can
move to core if desired.

This should also close out issure #150 asking for some core
functions like these.
2013-09-03 13:52:00 -06:00
Paul Tagliamonte
b2c51d0130 Merge branch 'master' into pr/287 2013-09-02 22:55:31 -04:00
kaizoku
b892ec4e66 Add zero? predicate to check if an object is zero 2013-09-02 02:28:21 -07:00
Konrad Hinsen
b11f2fcf49 Macro if-python2 for compile-time choice between Python 2 and Python 3 code branches 2013-09-02 09:58:35 +02:00
Bob Tolbert
b5b2ec4896 Merge pull request #266 from paultag/paultag/feature/yield-from
Paultag/feature/yield from
2013-08-24 07:15:42 -07:00
Julien Danjou
e158fba865 Merge pull request #265 from rwtolbert/hyc_args_fix
Add CL handling to hyc
2013-08-20 01:10:44 -07:00
Paul Tagliamonte
1c12b2870e Add yield from via macro magic.
This will let us use (basic) yield from behavior from Python 2. This
 isn't complete, and is low-hanging fruit for others willing to hack
 on hy.

 I've also changed the macrosystem to allow for proper bootstrapping.
 This is similar to how it's done elsewhere in the codebase (stdlib
 stuff).
2013-08-17 11:37:48 -04:00
Paul Tagliamonte
b2951349b2 Merge branch 'master' into pr/232 2013-08-10 17:05:50 -04:00
Bob Tolbert
41ae4f4d2c Update:
Updated most methods to replace While with For, and added tons of new tests
    for things like (cycle []) and lists with None's in them.

    thanks @olasd

Add set of new core functions

Add set of new core functions to the stdlib.

Moved the auto-import code from compile_expression to
HySymbol so that "even?' in this style expression will
be found and imported.

(list (filter even? [1 2 3 4 5]))

The core functions are documented in 2 sections, one
for basic functions like (even?..) and (nth ...) and
one for all the sequence functions.

Update: This removes all the caching decorators, misnamed as
'lazy-seq' from the core. All sequence methods now just use
yield to return a generator, so they are Python-lazy

Further refinements of core functions

Cleaned up the docs to use 'iterator' instead of 'generator'

Fixed drop to just return the iterator instead of an extra
yield loop. But also added a test to catch dropping too
many.
2013-07-29 08:52:28 -06:00
Nicolas Dandrimont
81af09d002 Wire the rply parser
Amend the tests to account for the changes
2013-07-28 17:36:36 +02:00
Nicolas Dandrimont
9278b24318 Allow quoting lambda list keywords.
This fixes an obvious bug where LambdaListKeywords couldn't be quoted.
2013-07-28 00:38:16 +02:00
Paul Tagliamonte
acfc5c6aa5 Merge branch 'master' into pr/236 2013-07-27 10:22:38 -04:00
Bob Tolbert
d960dc963f Add CL handling to hyc
This adds real command line handling to 'hyc' for issue #256

This fix catches missing/unreadable files and prints a nice
error message instead of a nasty stack trace when trying to
compile a non-existent file.

Also add this non-existent file check to hy to prevent the
current stack trace from something like "hy foobarbaz" when
"foobarbaz" doesn't exist.

also changes the failure return value to 2 to match Python.
2013-07-26 08:40:56 -06:00
Nicolas Dandrimont
a17dcdbffb Make with return the last expression from its branch
Thanks @rwtolbert for the bug report
2013-07-19 00:43:12 +02:00
Paul Tagliamonte
ad86dff754 Merge branch 'master' into pr/254 2013-07-18 00:00:42 -04:00
rwtolbert
348eaaa0f4 Merge pull request #243 from paultag/paultag/bugfix/fix-yield
Fix yielding to not suck (#151)

yay team
2013-07-16 18:27:14 -07:00
Paul Tagliamonte
3dde930ede Merge branch 'master' into pr/236 2013-07-16 20:57:29 -04:00
Guillermo Vaya
6778e9b2e1 added @tuturto sugesstions and flake8 errors 2013-07-16 20:41:56 +02:00
Guillermo Vaya
dda291cfb5 make assoc accept multiple values, also added a even/odd check for checkargs 2013-07-16 14:35:57 +02:00
Bob Tolbert
c42492ad84 Fix missing docstrings from defclass issue #248
Added ability to parse doc strings set in defclass declarations,
likei:

(defclass Foo [object]
  "this is the doc string"
  [[x 1]])
2013-07-15 06:58:08 -06:00
Paul Tagliamonte
7c91913122 Fix yielding to not suck (#151)
This adds a class to avoid returning when we have a Yieldable
 expression contained in the body of the function. This breaks Python
 2.x, and ought to break Python 3.x, but doesn't.

 We need this fo' context managers, etc.

 This commit also has work from @rwtolbert adding new testcases and
 fixes for yielded entries behind a while / for.
2013-07-14 13:11:27 -04:00
Bob Tolbert
df7bb1d29a Provide bin scripts for both Windows and *nix
Summary: This update does away with the scripts in bin and changes
setup.py to use entry_points in cmdline.py for the scripts 'hy' and
'hyc'.

This fixes installing and running on Windows.

The tests are updated to run the 'hy' script produced by setup.py
and not from bin/hy. This is more correct and makes the tox tests
run on both Window and *nix.

For running hy or nosetests directly in the source tree, you do have
to run 'python setup.py develop' first. But since tox runs and builds
dists, all tox tests pass on all platforms.

Also, since there is no built-in readline on Windows, the setup.py
only on Windows requires 'pyreadline' as a replacement.

Switched from optparse to argparse in cmdline.py

Instead of trying to manually separate args meant for
hy from args meant for a hy script, this switches from
optparse to argparse for the CLI.

argparse automatically peels out args meant for hy and leaves
the rest, including the user hy script in options.args.

This fixes the issue @paultag found running "hy foo" where
foo is not a real file. Also added a test that makes sure
trying to run a non-existent script exits instead of dropping
the user into the REPL.

Added argparse as setup.py resource (and removed from tox.ini) as well as removed uses of deprecated setf
2013-07-14 09:06:42 -06:00
Bob Tolbert
62f1f40830 Add set of new core functions
Add set of new core functions to the stdlib.

Moved the auto-import code from compile_expression to
HySymbol so that "even?' in this style expression will
be found and imported.

(list (filter even? [1 2 3 4 5]))

The core functions are documented in 2 sections, one
for basic functions like (even?..) and (nth ...) and
one for all the sequence functions.

Update: This removes all the caching decorators, misnamed as
'lazy-seq' from the core. All sequence methods now just use
yield to return a generator, so they are Python-lazy

Further refinements of core functions

Cleaned up the docs to use 'iterator' instead of 'generator'

Fixed drop to just return the iterator instead of an extra
yield loop. But also added a test to catch dropping too
many.
2013-07-13 09:55:16 -06:00
Joe H. Rahme
236ebccc74 Removes setf in favor of setv 2013-07-10 02:16:49 +02:00
Nicolas Dandrimont
1cb8db1cb2 Fix flake error 2013-07-06 20:39:02 +02:00
Morten Linderud
e4ae9880f4 Don't leave cruft around in sys.modules when an import fails.
Closes: #214, #225

Squashed from a bunch of commits by @olasd
2013-07-06 20:37:44 +02:00
Paul Tagliamonte
b78be9a594 Jank @olasd's hack, clean up core.
The core shall from now on be only for the core language bits. Macro
 bits shall live in hy.macros and in hy.compiler. This cleans up
 garbage.
2013-07-06 14:00:11 -04:00
Paul Tagliamonte
86af7eacf1 Add in a new core language file.
This will let us implement common functions seen in other lisps,
 and allow them to be importable, without explicit imports. The goal
 is to keep this as small as we can; we don't want too much magic.

 I've added `take' and `drop' as examples of what we can do.
2013-06-29 18:51:11 -04:00
Nicolas Dandrimont
b65c2a4596 whitespace fix 2013-06-26 08:50:37 +02:00
Guillermo Vaya
7b7b953410 set the value of empty hy expression to [] 2013-06-26 08:50:37 +02:00
Paul Tagliamonte
59550c9abd tell flake8 to shut up 2013-06-25 19:23:44 -04:00
Paul Tagliamonte
2f16ad6e78 Merge branch 'master' into pr/208 2013-06-25 19:20:58 -04:00
Morten Linderud
42468051f5 Builtins fix for 2 and 3, tests aswell 2013-06-25 17:02:02 +02:00
Morten Linderud
73c1f218e2 fixed a bug and added tests 2013-06-24 03:26:40 +02:00
Paul Tagliamonte
289586b340 Adding back in keywords.
Yes, I'm your hero, @algernon
2013-06-18 22:57:51 -04:00
Paul Tagliamonte
b00f181e1e Merge branch 'master' into pr/187 2013-06-18 21:17:13 -04:00
Paul Tagliamonte
4aca7842cd Add regression test for UTF and escapes. 2013-06-08 20:17:50 -04:00
Konrad Hinsen
2674016d3d More tests 2013-06-07 16:36:04 +02:00
Konrad Hinsen
6eacf63b53 Provide both eval-and-compile and eval-when-compile 2013-06-07 16:36:04 +02:00
Konrad Hinsen
80105d9731 eval-when-compile permits compile-time definitions that can be used from macros 2013-06-07 16:36:04 +02:00
Konrad Hinsen
12abef5ed5 Forgot boolean constants.. 2013-06-07 16:35:28 +02:00
Konrad Hinsen
e47bac1f96 Permit macros to return constants 2013-06-05 12:19:06 +02:00
Paul Tagliamonte
9c28e0292d Merge branch 'master' into pr/185
Conflicts:
	hy/macros.py
	tests/compilers/test_compiler.py

Hoodoggy!
2013-05-17 11:17:51 -04:00
Paul Tagliamonte
c0fd41620f Merge branch 'master' into pr/182 2013-05-17 11:09:37 -04:00
Paul Tagliamonte
5a1b004bfb Merge branch 'master' into pr/179 2013-05-17 11:08:30 -04:00
Konrad Hinsen
269da19d76 Make macros module-specific.
A macro is available in the module where it was defined and
in any module that does a require of the defining module.
Only macros defined in hy.core are globally available.
Fixes #181
2013-05-16 15:34:14 +02:00
Konrad Hinsen
b7c5ff2991 Refactor test_ast.py to eliminate the lots of hy_compile(tokenize(...)) calls 2013-05-16 15:30:44 +02:00
Nicolas Dandrimont
f939ae9544 Test quoting dicts 2013-05-14 12:10:29 +02:00
Nicolas Dandrimont
3252af3129 Add tests for expr-in-dict 2013-05-14 12:01:23 +02:00
Nicolas Dandrimont
9e03e0e6ec Modify HyDict semantics to allow nesting expressions
HyDicts are now HyLists, that get compiled down to dicts
only by the compiler.
2013-05-14 11:43:17 +02:00
Julien Danjou
66e5af4a82 Write a test for builds() check
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-14 11:03:13 +02:00
Julien Danjou
4e202aa1a5 Check that compiler error are user always user friendly
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-13 18:14:39 +02:00
Nicolas Dandrimont
1e7c90c44e Test requires from native code 2013-05-11 21:25:21 +02:00
Nicolas Dandrimont
bd478590fa Make that test macro more lispy 2013-05-11 21:25:21 +02:00
Nicolas Dandrimont
31c14e4167 Merge remote-tracking branch 'paultag/feature/native-macros' into feature/native-macros
Conflicts:
	hy/compiler.py
	tests/__init__.py
2013-05-11 20:18:40 +02:00
Paul Tagliamonte
636eec8f51 style fixes 2013-05-11 13:59:19 -04:00
Nicolas Dandrimont
0bbce2a819 Add a native macros test 2013-05-11 19:40:48 +02:00
Nicolas Dandrimont
0986f9001e Change macros to be called with separate arguments
This provides free argument-length checking for macros.
2013-05-11 09:09:34 +02:00
Paul Tagliamonte
2426237916 Add the (require) form. 2013-05-10 23:43:34 -04:00
Nicolas Dandrimont
2860ef6ff7 Don't macro-expand inside quotes 2013-05-11 00:29:42 +02:00
Nicolas Dandrimont
68399b9fc3 Make sure splicing works at all times 2013-05-11 00:26:37 +02:00
Nicolas Dandrimont
e039c73abd Add tests for quasiquoting 2013-05-10 23:42:38 +02:00
Paul Tagliamonte
9811b7514e Merge branch 'master' into pr/171 2013-05-09 20:39:49 -04:00
Paul Tagliamonte
1fa53f9255 Try/Except: Ensure that we return properly
From both inside a try and in an exception handler.
2013-05-08 20:41:16 -04:00
Nicolas Dandrimont
488fa89e09 Add some tests for kwapplying expressions 2013-05-09 02:33:14 +02:00
Paul Tagliamonte
98134e7396 Merge branch 'master' into bugfix/paultag/fix-try-except 2013-05-08 20:22:51 -04:00
Paul Tagliamonte
066c9781c7 Merge branch 'master' into pr/170 2013-05-08 20:11:57 -04:00
Paul Tagliamonte
72461a5cdb style tweak 2013-05-08 20:07:38 -04:00
Paul Tagliamonte
058197a24f Allow returning inside a try / except. Closes #163 2013-05-08 20:00:09 -04:00
Paul Tagliamonte
ceedc69b7d Correct existing tests for future try / except work. 2013-05-08 19:58:36 -04:00
Nicolas Dandrimont
4e3f842972 Add &optional arguments.
Python doesn't really have that concept, so make them clash with &key arguments.
2013-05-08 21:11:33 +02:00
Nicolas Dandrimont
5dbf6c6ca9 Add tests for &key arguments in functions 2013-05-08 21:11:33 +02:00
Nicolas Dandrimont
772927c53d Drop the bare names that were sprinkled everywhere in the generated AST.
This closes #162

We make sure not to drop *explicitly written* bare names.
2013-05-08 18:49:07 +02:00
Nicolas Dandrimont
c7176c05c0 Merge branch 'jd/defclass' of https://github.com/jd/hy into jd-jd/defclass 2013-05-08 15:30:20 +02:00
Nicolas Dandrimont
2b1b11a129 Fixup comment 2013-05-08 15:01:08 +02:00
Julien Danjou
a823aca0c8 Run unit tests against hy2py
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-08 14:39:38 +02:00
Julien Danjou
ad7e110af4 Implements defclass
This fixes issue #156

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-08 12:38:57 +02:00
Nicolas Dandrimont
6935b7b8c1 Add a test for lambda w/ lambda-list 2013-05-07 20:07:15 +02:00
Nicolas Dandrimont
1e24dde153 Merge fn and lambda
We actually only generate an ast.Lambda if (lambda) was called, as a lot of code
expect ast.FunctionDefs (most notably with_decorator).

This allows empty lambdas too.

This fixes #165.
2013-05-07 20:07:15 +02:00
Julien Danjou
8e9a16cc61 Add test case for issue #137
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-06 15:48:00 +02:00
Julien Danjou
6948fff112 Add a first test for the compiler
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-05 20:42:48 +02:00
Julien Danjou
9d8accb93a compiler: do not optimize Name
The optimization is wrong; they can't have side effects, but they can
raise errors.

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-05-05 20:42:48 +02:00
Nicolas Dandrimont
126e7ac531 Remove some unused code 2013-05-05 20:42:48 +02:00
Nicolas Dandrimont
6b2c635cfa Add some more eval tests 2013-05-05 20:42:48 +02:00
Nicolas Dandrimont
4387b947b3 Add a test for subscript assignment 2013-05-05 20:42:48 +02:00
Nicolas Dandrimont
3d8a3d589c Refactor compiler using a result carrying object
This object allows to coerce statements to an expression, if we need to use
them that way, which, with a lisp, is often.

This was collaborative work that has been rebased to make it bisectable.

Helped-by: Paul Tagliamonte <paultag@debian.org>
Helped-by: Julien Danjou <julien@danjou.info>
2013-05-05 20:42:48 +02:00
Nicolas Dandrimont
b7f92bd915 Don't lex "j" as a complex number.
This fixes #143
2013-05-04 10:27:30 +02:00
Julien Danjou
2ef9a0fdaf Rename decorate-with' to with-decorator'
Fixes #158

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:14:22 +02:00
Julien Danjou
08fbd754b6 Update indentation for `if'
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:08:00 +02:00
Julien Danjou
f25177e9a6 Add a `unless' macro
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:04:35 +02:00
Julien Danjou
f68e3b972b Add a `when' macro
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:04:35 +02:00
Julien Danjou
9b261a5004 Make HyList add returns HyList
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:04:33 +02:00
Julien Danjou
27e74d43b1 Re-indent Hy code using hy-mode
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 16:31:31 +02:00
Will Kahn-Greene
07dec18dc3 Fix "hy -c CMD" to show lex errors; add tests
* tells you there's a lex error, but doesn't tell you much else
* adds tests for all new bin/hy functionality
2013-04-24 22:23:12 -04:00
Julien Danjou
50daf1b4c8 Make temp attribute more solid and add unit test on regression
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-24 22:36:49 +02:00
Paul Tagliamonte
ada946fca8 style cleanup 2013-04-23 19:25:02 -04:00
Paul Tagliamonte
a1cf9e50eb Merge branch 'master' into pr/141 2013-04-23 19:23:37 -04:00
John Jacobsen
8d8dd62168 Move take and drop from AST impl. in compiler.py to macros in core/bootstrap.py 2013-04-21 19:08:30 -05:00
John Jacobsen
f69c6243e8 Fix 'direction' of 'drop' function 2013-04-21 15:46:31 -05:00
John Jacobsen
fef571855b Added 'take' and 'drop' functions (as AST elements) 2013-04-21 15:41:20 -05:00
Paul Tagliamonte
6f7f402c19 Merge branch 'master' into pr/140
Conflicts:
	hy/compiler.py
	tests/native_tests/language.hy
2013-04-21 12:29:09 -04:00
Julien Danjou
7066d53b02 Introduce a context manager for compiler.returnable
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-21 17:14:26 +02:00
Paul Tagliamonte
47b2709c47 Merge branch 'master' into pr/145 2013-04-21 11:04:36 -04:00
Paul Tagliamonte
36a7f91014 Merge branch 'master' into pr/146 2013-04-21 11:03:32 -04:00