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
Paul Tagliamonte
feabe3ff4a
Merge branch 'master' into pr/125
2013-04-21 10:58:08 -04:00
Julien Danjou
3226ecc33f
Fix bin/hy and add a unit test
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-20 22:28:45 +02:00
Julien Danjou
07e99dbd33
importer: doc update, MetaImport refactor
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-20 22:11:53 +02:00
Gergely Nagy
494bf0e8ad
Remove the import-as and import-from builtins
...
The new and improved (import) can handle all cases import-as and
import-from did, so drop the latter two from the language. To do this,
the import builtin had to be changed a little: if there's a single
import statement to return, return it as-is, otherwise return a list of
imports.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-04-20 16:06:32 +02:00
Julien Danjou
74ea8fe5e5
Allow fn to have no body
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-20 05:19:58 -07:00
Julien Danjou
07860b5ce6
Allow variable without value in `let' declaration
...
Fixes issue #138
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-20 05:18:45 -07:00
James King
047956c59b
Clean up based on review
2013-04-19 10:36:51 -04:00
E. Anders Lannerback
18cb7203d3
Added global. Not sure if this is a good idea ...
...
(global foo) => global foo
2013-04-19 08:40:03 +02:00
James King
1080a457b1
Implemented &key and added tests
2013-04-18 22:27:38 -04:00
Paul R. Tagliamonte
f268403d49
Add another small test on this
2013-04-18 21:46:30 -04:00
James King
70e0d88149
WIP - Added &key support
2013-04-18 17:47:08 -04:00
James King
18ed72136f
Merge branch 'master' into feature/lambda-list-keyword
...
Conflicts:
hy/compiler.py
hy/lex/states.py
hy/util.py
tests/compilers/test_ast.py
tests/lex/test_lex.py
2013-04-18 15:17:30 -04:00
Paul R. Tagliamonte
d3a019b3dd
Don't quote things in (quote) - Closes #129
2013-04-17 23:20:56 -04:00
Konrad Hinsen
41a9ce28f0
Implement unary minus
2013-04-16 17:43:40 +02:00
Paul R. Tagliamonte
9d913e92af
removing the pass
2013-04-14 21:58:44 -04:00
Paul R. Tagliamonte
7b4d4fb371
Merge branch 'jd/finally' of git://github.com/jd/hy into pr-94
2013-04-14 21:57:11 -04:00
Paul R. Tagliamonte
a5a54fc7eb
Merge branch 'f/smart-import' of git://github.com/algernon/hy into pr-113
2013-04-14 21:32:22 -04:00
Paul R. Tagliamonte
3b3768853a
Merge branch 'jd/remove-pass' of git://github.com/jd/hy into pr-122
2013-04-14 21:09:47 -04:00
Paul R. Tagliamonte
5d0b1a5e1e
Merge branch 'jd/for-else' of git://github.com/jd/hy into pr-121
2013-04-14 21:05:55 -04:00
Julien Danjou
bbaab58a4c
Implements else' for
foreach' statements
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-15 02:50:26 +02:00
Julien Danjou
c05ae5fcbc
Add AugAssign handling
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-15 02:49:34 +02:00