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
Julien Danjou
60a9003b0c
Add missing bits operator and power
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-15 02:49:34 +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
Nicolas Dandrimont
1756e534ad
The b prefix works since python2.6
2013-04-13 21:46:17 +02:00
Vladimir Gorbunov
0b03733c65
Add tests for pyc compilation
2013-04-13 20:57:54 +04: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 R. Tagliamonte
f295b10f52
Updating yield.
2013-04-12 23:48:58 -04:00
Paul R. Tagliamonte
a71f166610
Merge branch 'future_division' of github.com:khinsen/hy into pr-106
2013-04-12 23:07:40 -04:00
Nicolas Dandrimont
30c0b25512
Add a unicode string handling test
2013-04-12 20:58:56 +02:00
Nicolas Dandrimont
8bc8a4a170
Merge remote-tracking branch 'khinsen/float_and_complex_2' into paultag/master
...
Conflicts:
hy/lex/states.py
tests/lex/test_lex.py
2013-04-12 18:16:43 +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 Tagliamonte
94d2c381a5
Merge branch 'lexer_extensions' of git://github.com/khinsen/hy into pr-98
2013-04-12 08:55:13 -04:00
Konrad Hinsen
0c56885d42
Use __future__.division for all Hy code
...
Fixes #106
Note: This is implemented by replacing all calls to Python's
builtin "compile" function by calls to hy.importer.compile_,
which adds the "future division" flag. Anyone using "compile"
in future work will have to remember this.
2013-04-12 05:23:25 +02:00
Paul R. Tagliamonte
db3e2bd346
updating the nested mangles
2013-04-11 22:25:23 -04:00
James King
9ff3b128b4
Got &rest working, tests pass
...
Did a little house cleaning in lex states.py too and started removing
stupid print() statements.
2013-04-11 12:00:27 -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
Konrad Hinsen
e3a9909a7e
Implement integer division operator
...
Fixes #107
2013-04-11 10:09:15 +02:00
Konrad Hinsen
ac0a597742
Tests for float and complex constants
2013-04-11 09:54:59 +02:00
Konrad Hinsen
fd99f497a4
Fixed typo in test_lex.py
2013-04-11 09:40:57 +02:00
Paul R. Tagliamonte
d25d354281
Adding in on-the-fly-importing.
2013-04-10 22:51:58 -04:00
James King
484a96abae
WIP - Move _parse_lamba_list to the functiondef
2013-04-10 16:52:28 -04:00
Konrad Hinsen
4f98ea22e8
Allow atoms (integers, booleans, symbols) as top-level expressions
2013-04-10 13:08:32 +02: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
Paul R. Tagliamonte
a948cf2870
Merge branch 'master' into feature/quoting
2013-04-09 19:50:25 -04:00
James King
7417789ce0
WIP - Adding Call support and FuncionDef
...
The test is still broken, there are print statements... this is an
ongoing WIP and will get squashed before submitted the PR.
2013-04-09 15:23:50 -04:00
James King
4d90123506
Merge branch 'develop' into feature/lambda-list-keyword
2013-04-09 15:13:25 -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
4ba6ada77b
Merge pull request #92 from jd/jd/raise-0-arg
...
Implements (raise)
2013-04-09 08:23:09 -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
dd90272129
except/catch: check exceptions list type
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-09 16:56:45 +02:00
Paul R. Tagliamonte
997b32e18c
Testing the behavior of (quote "foo")
2013-04-08 22:31:26 -04:00
Paul R. Tagliamonte
eeab56c2b7
Adding a symbol checker.
2013-04-08 20:24:47 -04:00
Paul R. Tagliamonte
93e4bc17eb
Adding some basic testing in; more to come.
2013-04-08 20:23:51 -04: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
Julien Danjou
cd36a1d7eb
Allow empty `do'
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-08 15:17:11 +02: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
Paul R. Tagliamonte
2216a23438
Merge branch 'jd/try' of git://github.com/jd/hy into pr-82
2013-04-07 18:51:08 -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
Julien Danjou
c3cbceca36
Merge pull request #78 from paultag/paultag/bugfix/anon-macros
...
Paultag/bugfix/anon macros
2013-04-07 15:40:52 -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
a81a716420
Be sure errors are raised at by compile, not tokenize
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-08 00:38:55 +02: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
48ae1b1e26
Merge pull request #80 from olasd/bugfix/unbalanced-expressions
...
Correctly handle unbalanced expressions
2013-04-07 15:27:45 -07:00
Nicolas Dandrimont
806f0d900c
Throw an error on unbalanced expressions
2013-04-08 00:25:47 +02: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
Nicolas Dandrimont
1853b7d33c
Correctly balance the brackets in the wrong syntax tests
...
We want to test the compiler, not the lexer.
2013-04-07 19:53:50 +02: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
2fd56e8fa1
catch: uncomment some tests
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-07 18:20:32 +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
123339bfcf
tests: simplify not compiling tests
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 21:28:12 +02:00
Julien Danjou
78133500cb
Fix flake8 errors in tests
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 21:22:35 +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
Paul R. Tagliamonte
6aebc5820f
Merge branch 'jd/if' of git://github.com/jd/hy
2013-04-06 08:18:13 -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
b36018981a
if: emit error on too many args
...
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 10:13:14 +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
Paul R. Tagliamonte
27e4772aa7
Test the function return-o-matic
2013-04-05 19:59:33 -04:00
Paul R. Tagliamonte
936d1bcec7
testing nested things
2013-04-04 21:58:26 -04:00
Paul R. Tagliamonte
b2406a9d72
list flattener
2013-04-04 19:32:56 -04:00
Nicolas Dandrimont
ba021ed7bf
Count the number of expressions executed in do
2013-04-04 11:20:10 +02:00
Nicolas Dandrimont
06511fe303
Add do-in-defn tests
2013-04-04 11:08:18 +02:00
Nicolas Dandrimont
99f62fb8b3
Add some tests for defn
2013-04-04 09:29:21 +02:00
Paul R. Tagliamonte
d421d869af
Fixing the "olasd" bug
2013-04-03 20:18:56 -04:00
Nicolas Dandrimont
d070d3d484
Add while loops to the compiler
2013-04-03 19:55:09 +02:00
James King
dceaad716a
[WIP] Added lambda list keyword parsing step
...
This allows us to translate lisp argument lists to Python ones.
(defun foo (x y &rest z &optional {foo 3} &aux kwargs))
translates roughly to:
def foo(x, y, *z, foo=3, **kwargs):
pass
2013-04-03 11:39:31 -04:00
James King
c200b4e3d1
Added HyLambdaListKeyword tokens to the lexer
...
The name "lambda list keyword" is a historical artifact from the CLHS
and not optimal (http://clhs.lisp.se/Body/26_glo_l.htm ).
The name may change at some point.
2013-04-03 10:19:18 -04:00
Paul Tagliamonte
0eeb5321e1
Merge branch 'jd/if-parsing' of git://github.com/jd/hy
2013-04-03 09:00:53 -04:00
Julien Danjou
1c8d21e3de
Raises TypeError on bad if statements
...
This relates to issue #6 .
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-03 11:25:17 +02:00
Paul R. Tagliamonte
d316a8fde8
covering the new bits
2013-04-02 20:49:42 -04:00
Paul R. Tagliamonte
b1c605cc6a
Updating the tests to not break Python 3.x
2013-04-01 23:06:59 -04:00
Paul R. Tagliamonte
fb6ec426e6
Adding in list comprehensions.
...
Thanks to paroneayea for the syntax brotip.
2013-04-01 22:47:11 -04:00
Paul R. Tagliamonte
b077af9620
more tests
2013-04-01 22:13:45 -04:00
Paul R. Tagliamonte
c4b270a727
test coverage bits
2013-04-01 22:07:05 -04:00
Paul Tagliamonte
025e501b13
cleaning up the tests a bit
2013-04-01 20:00:37 -04:00
Paul Tagliamonte
678ef441e5
Adding in tuple checkingish.
2013-04-01 19:53:04 -04:00
Paul Tagliamonte
6831841699
Adding in some tests for print
2013-04-01 19:51:21 -04:00
Paul Tagliamonte
426c7cd829
Test bad decoration
2013-04-01 19:38:58 -04:00
Christopher Allan Webber
1b60bee8a3
Change all instances of (def foo bar) to (setv foo bar)!
...
I'm in ur base polluting your language with all my opinions!
2013-04-01 16:51:28 -05:00
Christopher Allan Webber
9416422330
Changing cond to be more common lisp / emacs lisp like
...
Instead of:
(cond (condition-1) (body-1)
(condition-2) (body-2))
We now work like:
(cond ((condition-1) (body-1)
(condition-2) (body-2)))
2013-04-01 10:33:45 -05:00
Paul Tagliamonte
0809ef206c
undoing that
2013-03-26 19:14:50 -04:00
Paul Tagliamonte
fee6263b85
Trying to double-import to trigger importer bugs
2013-03-26 19:09:42 -04:00
Paul R. Tagliamonte
ccd26205d7
unbreak py3.3? need to re-add with
2013-03-24 10:00:07 -04:00
Paul R. Tagliamonte
dd6a883060
implmenting with
2013-03-24 02:04:44 -04:00
Amrut Joshi
29f8cecf65
Added test for "import as"
2013-03-19 05:46:00 +00:00
Paul R. Tagliamonte
a94831beac
add mod operator
2013-03-18 21:46:58 -04:00
Paul R. Tagliamonte
83a9bdc87d
adding in rest macros
2013-03-18 19:49:36 -04:00
Paul R. Tagliamonte
a58c813dda
adding in a slice operator
2013-03-18 19:47:48 -04:00
Paul R. Tagliamonte
8f6c77831b
Adding first' /
car'
2013-03-18 16:11:29 -04:00
Paul R. Tagliamonte
4cb4e7384e
holy shit it's 2013
2013-03-18 10:27:14 -04:00
Paul R. Tagliamonte
0c1bdde6e3
doh, my bad
2013-03-17 17:51:09 -04:00
Paul R. Tagliamonte
5321703287
testing the double loop
2013-03-17 17:50:18 -04:00
Paul R. Tagliamonte
3c288519ac
adding in yielding
2013-03-14 20:55:11 -04:00
Paul R. Tagliamonte
9b32506854
Fixing catch a bit to now force a param.
2013-03-14 09:21:03 -04:00
Paul R. Tagliamonte
b5214fb427
Inline comments.
2013-03-13 21:31:23 -04:00
Paul Tagliamonte
57775a95a6
Fiddling with the threading macro
2013-03-13 10:11:14 -04:00
Paul R. Tagliamonte
7f02210ad1
Testing assoc
2013-03-12 22:07:32 -04:00
Paul R. Tagliamonte
daa6443e7c
Adding in a Threading macro (->)
2013-03-12 22:04:51 -04:00
Thomas Mashek
b6eca8dfc0
Earmuff stuff.
2013-03-12 12:46:20 -07:00
Paul R. Tagliamonte
9f057e8c8f
Fixing 3.x AST
2013-03-11 20:17:27 -04:00
Paul Tagliamonte
b12e14b96b
Adding in CodeMirror stuff. Makin' moves.
2013-03-11 19:14:20 -04:00
Paul R. Tagliamonte
4f856c35d4
adding in dotted notation
2013-03-09 22:04:38 -05:00
Paul R. Tagliamonte
44f5035919
reflowing; docstrings
2013-03-09 21:16:28 -05:00