Commit Graph

442 Commits

Author SHA1 Message Date
Nicolas Dandrimont
e9f7c47663 Do the macro processing in the compiler 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
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
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
John Jacobsen
760774afde Implement import_buffer_to_module 2013-04-24 21:58:42 -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
Julien Danjou
4447ac5f1a Revert wrong changes on temporary_attribute_value
We don't want to ignore any error.

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-24 22:18:45 +02:00
Will Kahn-Greene
08b30e8195 Back-figuring the license/copyright info
I did a git log thing to figure out who touched bin/hy and copied
those people over here since the bulk of the code came from bin/hy.
2013-04-24 09:03:56 -04:00
Will Kahn-Greene
3f7f241097 Fix license header 2013-04-24 08:57:51 -04:00
Will Kahn-Greene
fb8140b6bc Add license to new file 2013-04-24 08:32:03 -04:00
Will Kahn-Greene
4e59af0033 Redid command line code
This supports:

* -h, --help
* --version
* -c cmd
* -i cmd
* file
* -

Plus it's easy to add new options.

Also, now we can do ridiculous things like have projects where
the installation is:

$ curl -s http://example.com/install-hypster-program | hy
2013-04-23 22:02:41 -04: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
Paul Tagliamonte
52ebcfae8c removing the dunder. that was a bad move. 2013-04-22 21:49:19 -04:00
Paul Tagliamonte
109e8cb147 sorting imports by length 2013-04-22 21:47:43 -04:00
Julien Danjou
a9a67e9418 Simplify compile
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-22 22:46:43 +02:00
Julien Danjou
c241236bf5 Remove useless class attribute
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-22 14:58:05 +02:00
Paul Tagliamonte
6cb17a2f14 Merge branch 'master' into pr/149 2013-04-21 20:59:50 -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
Julien Danjou
afd0ba1870 Remove useless variable assignment
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-22 00:30:22 +02:00
John Jacobsen
c65df143b9 Simplify 'take' 2013-04-21 15:47:45 -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
Paul Tagliamonte
55ed7cee62 misc. style fixes 2013-04-21 11:43:33 -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
adecd32897 Merge branch 'master' into pr/144 2013-04-21 11:12:04 -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
Paul Tagliamonte
feabe3ff4a Merge branch 'master' into pr/125 2013-04-21 10:58:08 -04:00
Julien Danjou
c0baea80dc Mangler cosmetic cleanup
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-21 15:58:36 +02:00
Julien Danjou
7f230fdd10 importer: remove useless import
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-20 22:14:08 +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
0efe3d7c49 Removed .format from lex/states.py 2013-04-19 10:49:57 -04: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
Paul R. Tagliamonte
aadf47ed99 documenting hy.core.mangles 2013-04-18 22:50:46 -04:00
Paul R. Tagliamonte
23773a5117 docstrings on the mangle 2013-04-18 22:44:03 -04:00
James King
20b776aeb2 Removed redundant expression from _parse_lambda_list 2013-04-18 22:32:08 -04:00
James King
1080a457b1 Implemented &key and added tests 2013-04-18 22:27:38 -04:00
Julien Danjou
049c019791 Remove useless check
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-18 19:08:19 -07:00
James King
263d7af0fc Added line and column offsets 2013-04-18 18:39:49 -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
Paul R. Tagliamonte
3f362bc318 Merge branch 'unary_minus' of github.com:khinsen/hy 2013-04-16 23:07:32 -04:00
Konrad Hinsen
270a619cf7 Simplify the decorator hy.compiler.builds
Not so much for the efficiency gain, but to save keystrokes in the
debugger when looking at methods with lots of builds decorators.
2013-04-16 17:53:02 +02:00
Konrad Hinsen
41a9ce28f0 Implement unary minus 2013-04-16 17:43:40 +02:00
Paul R. Tagliamonte
4888589f59 Callin' this 0.9.6 2013-04-15 22:36:50 -04:00
Julien Danjou
475c2b6b63 Use HyTypeError to raise else' errors in foreach'
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-15 11:47:11 -07: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
da33f41753 some style fixes for @algernon 2013-04-14 21:54:15 -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
6a09179809 Enhance error handling
We now have a full backtrace if the compiler bugs, and if it's a user
problem we indicate him where he failed.

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-15 02:48:58 +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
Vladimir Gorbunov
f30e7cd99b Fix hyc 2013-04-13 16:28:37 +04: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
d5db2840ad Don't punycode pure unicode strings. 2013-04-12 20:42:40 +02:00
Nicolas Dandrimont
65c08c8c7d Factor str_type into hy.util 2013-04-12 20:42:39 +02:00
Paul Tagliamonte
e4e61a463e Adding in the new models. 2013-04-12 09:18:25 -04:00
Paul Tagliamonte
1f4ed473d3 Style fixes; function declashing. 2013-04-12 09:11:56 -04:00
Paul Tagliamonte
3ec828e660 Merge branch 'float_and_complex' of git://github.com/khinsen/hy into pr-109 2013-04-12 09:09:38 -04: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
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
Paul R. Tagliamonte
eee65f3051 Update to the style. 2013-04-10 23:11:54 -04:00
Paul R. Tagliamonte
b65f78a0c7 Adding in this barf of a hack beacuse it pleases me. 2013-04-10 23:06:55 -04:00
Paul R. Tagliamonte
f6b94b1b40 Avoiding breaking PyPy. Wat. 2013-04-10 23:00:42 -04:00
Paul R. Tagliamonte
d25d354281 Adding in on-the-fly-importing. 2013-04-10 22:51:58 -04:00
Paul R. Tagliamonte
644f2756f3 Fixing the raised Exception. 2013-04-10 21:49:27 -04:00
Paul R. Tagliamonte
1adf64839a Updating travis; exceptions. 2013-04-10 21:44:23 -04:00
Paul R. Tagliamonte
65db83d1ff moving atoms around to make it easier for internals. 2013-04-10 20:04:58 -04:00
James King
484a96abae WIP - Move _parse_lamba_list to the functiondef 2013-04-10 16:52:28 -04:00
James King
160eaaa543 Merge branch 'develop' into feature/lambda-list-keyword 2013-04-10 15:14:45 -04:00
James King
1506ff16ad Added ast pretty printer 2013-04-10 15:08:44 -04:00
Konrad Hinsen
b1f66b6893 Handle float and complex constants in addition to integer 2013-04-10 14:26:16 +02:00
Konrad Hinsen
4f98ea22e8 Allow atoms (integers, booleans, symbols) as top-level expressions 2013-04-10 13:08:32 +02:00
Konrad Hinsen
753460884e Accept strings as top-level expressions 2013-04-10 12:32:39 +02: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
73be6afd3a Initial cut of `eval' 2013-04-09 21:33:09 -04:00
Paul R. Tagliamonte
3f5ce64407 I'm an idiot 2013-04-09 20:44:52 -04:00