Commit Graph

140 Commits

Author SHA1 Message Date
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
049c019791 Remove useless check
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-18 19:08:19 -07: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
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
Paul R. Tagliamonte
f295b10f52 Updating yield. 2013-04-12 23:48:58 -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
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
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
Konrad Hinsen
b1f66b6893 Handle float and complex constants in addition to integer 2013-04-10 14:26:16 +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
Paul R. Tagliamonte
c0b34181bc futzing with alignment 2013-04-09 20:44:05 -04:00
Paul R. Tagliamonte
b71d5c597e Fixing a bug @jd noticed. 2013-04-09 20:34:46 -04:00
Paul R. Tagliamonte
a948cf2870 Merge branch 'master' into feature/quoting 2013-04-09 19:50: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
181a22be93 Merge pull request #91 from jd/jd/better-error-reporting
Enhance error reporting
2013-04-09 08:23:27 -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
48d5a0abc0 catch: use the right symbol name in errors
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-09 16:58:32 +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
Julien Danjou
ed5a0455b6 Enhance error reporting
We're now able to make the difference between a compiler bug and a user
trying to compile wrong thing, and report this correctly on the console.

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-09 16:09:06 +02:00
Paul R. Tagliamonte
f27378e57a Adding in some prototype bits for quoted forms. 2013-04-08 20:18:15 -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
5336b2f71a Fix early returns. Close #83 2013-04-07 19:29:45 -04:00