Nicolas Dandrimont
26b052c76e
language.hy whitespace fix
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
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
a17dcdbffb
Make with
return the last expression from its branch
...
Thanks @rwtolbert for the bug report
2013-07-19 00:43:12 +02: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
Joe H. Rahme
236ebccc74
Removes setf
in favor of setv
2013-07-10 02:16:49 +02: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
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
4aca7842cd
Add regression test for UTF and escapes.
2013-06-08 20:17:50 -04: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
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
Nicolas Dandrimont
3252af3129
Add tests for expr-in-dict
2013-05-14 12:01:23 +02:00
Nicolas Dandrimont
1e7c90c44e
Test requires from native code
2013-05-11 21:25:21 +02:00
Paul Tagliamonte
2426237916
Add the (require) form.
2013-05-10 23:43:34 -04: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
058197a24f
Allow returning inside a try / except. Closes #163
2013-05-08 20:00:09 -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
6935b7b8c1
Add a test for lambda w/ lambda-list
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
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
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
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
27e74d43b1
Re-indent Hy code using hy-mode
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 16:31:31 +02: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
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
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
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
Paul R. Tagliamonte
d3a019b3dd
Don't quote things in (quote) - Closes #129
2013-04-17 23:20:56 -04: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
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
fdb6bf944c
try: add support for `finally'
...
This fixes #75
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-15 02:48:58 +02:00
Julien Danjou
cb20910d93
Remove `pass' from the language.
...
This also fixes a bug in the pass optimize missing branch where the code is
something like: [stmt, [], stmt]; in such case we want to filter out [], so
if we end up with [] we can optimize it. This fix is needed otherwise (do)
inside (do) are not properly optimized.
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-14 13:56:44 +02:00
Gergely Nagy
5d895c2005
Making (import) a lot smarter
...
With these changes, the import function will become a lot smarter, and
will combine all of import, import-from and import-as in a hyly lispy
syntax:
(import sys os whatever_else)
(import [sys [exit argv]] [os :as real_os]
[whatever_else [some_function :as sf]])
That is, each argument of import can be:
- A plain symbol, which will be imported
- A list, which will be handled specially
If the argument is a list, the first element will always be the module
name to import, the second member can be either of these:
- A list of symbols to import
- The ':as' keyword
- Nothing
If it is the ':as' keyword, the third argument must be an alias. If it
is a list of symbols to import, we'll iterate through that list too. If
any symbol is followed by an ':as' keyword, we'll pick all three, and
treat the third member as an alias. If there is nothing else in the
list, we'll import the module as-is.
All this combined fixes #113 .
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-04-13 15:06:31 +02:00
Paul Tagliamonte
c15d8750e8
Merge branch 'f/hy.models.keyword' of git://github.com/algernon/hy into pr-101
2013-04-12 08:58:38 -04:00
Paul R. Tagliamonte
db3e2bd346
updating the nested mangles
2013-04-11 22:25:23 -04:00
Gergely Nagy
2ea2cd1a8d
tests: Test that keywords do not clash with normal strings
...
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
2013-04-11 15:13:40 +02:00
Gergely Nagy
702811c69a
Implement :keyword support
...
This implements keywords, ":" prefixed symbols that are able to look
themselves up in a collection. They're internally stored as strings that
start with "\ufdd0".
This fixes #22 .
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-04-11 15:13:26 +02:00
Paul R. Tagliamonte
d25d354281
Adding in on-the-fly-importing.
2013-04-10 22:51:58 -04:00
Paul R. Tagliamonte
c98a367495
Merging the two tests.
2013-04-09 21:55:34 -04:00
Paul R. Tagliamonte
6f0e739b31
test hoisted functions too
2013-04-09 21:45:37 -04:00
Paul R. Tagliamonte
8cc26ba1bf
moving to locals; fixing _ast vs ast, adding tests
2013-04-09 21:40:54 -04:00
Julien Danjou
92eaed21e4
Merge pull request #87 from jd/jd/try
...
compiler: add `else' support in `try'
2013-04-09 08:23:41 -07:00
Julien Danjou
b13cc60075
Implements (raise)
...
As in Python, this allows to re-raise the last raised exception.
This fixes #86
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-09 17:00:45 +02:00
Julien Danjou
f8131d3c36
compiler: add else' support in
try'
...
This is a bit tricky, since we'll also have to support `finally' in the end,
I've introduced an Else statement on my own to be able to recognize it.
This fixes #74
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-09 17:00:30 +02:00
Julien Danjou
d7e8dd2a91
compiler: optimize empty tree mangling to ast.Pass
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-08 13:27:50 -04:00
Paul R. Tagliamonte
38a714b5c5
Adding more tests; new entries
2013-04-07 19:44:52 -04:00
Paul R. Tagliamonte
5336b2f71a
Fix early returns. Close #83
2013-04-07 19:29:45 -04:00
Paul R. Tagliamonte
6912f4c4d9
Merge branch 'master' into pr-82
2013-04-07 18:51:18 -04:00
Julien Danjou
2ff3da032c
Merge pull request #81 from paultag/paultag/bugfix/with-syntax-fix
...
Fixing (with)'s syntax to be more hyish.
2013-04-07 15:41:53 -07:00
Paul R. Tagliamonte
e22a0ff73c
Mangle a macro until it stops moving
...
this helps if we use a macro in something that got tree-mangled
back out.
2013-04-07 18:41:41 -04:00
Paul R. Tagliamonte
83d91c3f81
Asserting `fd' exists inside the with
2013-04-07 18:39:30 -04:00
Julien Danjou
0d3500f6e5
try: accept a simpler form
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-08 00:36:08 +02:00
Paul R. Tagliamonte
4db9446197
Fixing (with)'s syntax to be more hyish.
2013-04-07 18:35:36 -04:00
Julien Danjou
a73d460beb
try: allow empty body
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-08 00:14:42 +02:00
Gergely Nagy
1b7d145c65
Implement the (or) function too
...
The (or) function is to be constructed similarly to (and), so refactor
the compile_and_operator function to handle or aswell.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-04-08 00:02:08 +02:00
Gergely Nagy
f03b538787
Implement the (and) function
...
The function takes at least two arguments, and turns it into a pythonic
and statement, which returns the last True-ish value, or False.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-04-07 23:54:56 +02:00
Paul R. Tagliamonte
bfc71e4a60
Add tail threading (->>)
2013-04-07 15:05:30 -04:00
Julien Danjou
bdd07e1251
Alias except' to
catch' and raise' to
throw'
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-07 18:24:01 +02:00
Julien Danjou
6dec894a0c
Better catch syntax
...
The syntax is now changed to:
(catch [] BODY)
(catch [Exception] BODY)
(catch [e Exception] BODY)
(catch [e [Exception1 Exception2]] BODY)
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-07 18:03:43 +02:00
Paul R. Tagliamonte
9d36dab693
Test importing things with dashes
2013-04-07 09:54:53 -04:00
Paul R. Tagliamonte
03dfbde1b8
style voodoo
2013-04-06 23:11:43 -04:00
Paul R. Tagliamonte
5a96089266
Using backslashes for now; punycode soon.
2013-04-06 21:33:52 -04:00
Paul R. Tagliamonte
bac3f6991c
Revert "adding this as testable"
...
This reverts commit 104b9d1636
.
2013-04-06 20:03:14 -04:00
Paul R. Tagliamonte
e0ed7cac40
Revert "Make HySymbol bytes free!"
...
This reverts commit 8b144a4f3d
.
2013-04-06 20:02:08 -04:00
Paul R. Tagliamonte
104b9d1636
adding this as testable
2013-04-06 19:57:59 -04:00
Julien Danjou
8b144a4f3d
Make HySymbol bytes free!
...
We can know use any amount and type of bytes to build a HyString, meaning we
can use Unicode and UTF-8 for our function and variables.
Eat that, snake!
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 23:37:34 +02:00
Julien Danjou
0eb795b4a5
Check the number of arguments for each function
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 19:00:32 +02:00
Paul R. Tagliamonte
4b57fd0a51
Adding in an If mangle
2013-04-06 11:10:33 -04:00
Paul R. Tagliamonte
3ab7153398
Merge branch 'master' of git://github.com/jd/hy
2013-04-06 08:19:23 -04:00
Julien Danjou
3e9a2178c5
Add support for unary operators (not, ~)
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 10:38:41 +02:00
Julien Danjou
9768345a7c
let: add a scope test
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 10:12:03 +02:00
Paul R. Tagliamonte
7abc472336
Implementing `let'
2013-04-05 21:54:04 -04:00
Julien Danjou
fa5ab3b3ad
Tests for a future native-eval. Close #64 .
2013-04-05 20:18:46 -04:00
Paul R. Tagliamonte
3b185250e0
trailing newlines suck
2013-04-05 20:01:37 -04:00