Commit Graph

170 Commits

Author SHA1 Message Date
Kodi Arfer
271f2846dc Minor cleanup in test_ast 2018-07-24 09:37:19 -07:00
Kodi Arfer
03aafad657 Make empty expressions illegal at the top level 2018-07-24 08:59:52 -07:00
Kodi Arfer
7abd8ffc2a Make importing a dotted name a syntax error, per Python 2018-06-27 10:24:22 -07:00
Kodi Arfer
14979edcab Remove tests of the old comprehension forms 2018-06-13 17:31:08 -07:00
Kodi Arfer
3256932b13 Add a version of for parallel to lfor etc. 2018-06-13 17:31:08 -07:00
Kodi Arfer
3204a9e8a3 Streamline auto-promotion and position spoofing
Auto-promotion now occurs in only two cases: when we start the compiler and when we expand a macro. It's fully recursive so even a non-model nested in a model will be promoted.

This change fixes some regressions induced by the stricter type checks of the pattern-matching compiler.
2018-06-05 09:23:21 -07:00
Kodi Arfer
a38c948ed2 Fix a regression with mangling module names 2018-06-03 15:38:49 -07:00
Kodi Arfer
57b5fa49b1 Unify illegal special forms 2018-05-20 14:11:31 -07:00
Kodi Arfer
45e8783997 Use model patterns for fn 2018-05-20 14:07:44 -07:00
Kodi Arfer
79c02514b9 Introduce the use of model patterns 2018-05-20 14:07:44 -07:00
Kodi Arfer
a2aeca2338 Remove tuple unpacking in lambda lists 2018-05-04 10:40:22 -07:00
Simon Gomizelj
7c3477e738 Fix a bug where the compiler doesn't properly handle unquote-splice
Added test coverage as well
2018-04-30 09:38:57 -07:00
Kodi Arfer
ec1c92bf4e Allow for with an empty body 2018-04-29 19:51:00 -07:00
Kodi Arfer
b7e5c5f17a Allow while with an empty body 2018-04-29 19:51:00 -07:00
Kodi Arfer
87aced2370 Don't let HyExpression etc. inherit from HyList
This means the compiler no longer allows e.g. `(fn (x) ...)` in place of `(fn [x] ...)`.
2018-04-29 19:17:47 -07:00
Simon Gomizelj
032247e380
Merge pull request #1588 from Kodiologist/no-amp-key
Remove &key
2018-04-27 00:21:11 -04:00
Kodi Arfer
a605936651 Remove &key
It's redundant with &optional.
2018-04-19 09:26:02 -07:00
Kodi Arfer
7bf2901364 Ban (except)
It's rarely useful, because it catches all exceptions, but it doesn't let you do anything other than return `None`. You can still get the same effect with `(except [])`.
2018-04-16 19:34:50 -07:00
Kodi Arfer
097647bf6f Remove tests of cons cells 2018-04-12 16:45:17 -07:00
Simon Gomizelj
84e1c65bcd Improve checks inside defclass
We need to make sure we're looking at HyExpression when trying to
determine if we're rewriting an __init__ expression.

Fixes #1533
2018-03-31 02:43:53 -04:00
Kodi Arfer
e3058b5cf5 Handle module docstrings on Python 3.7 2018-03-24 12:34:43 -07:00
Simon Gomizelj
c663d38e33 Add metaclass support, support PEP 3115 and PEP 487 2018-03-22 13:28:22 -07:00
Tuukka Turto
cb72a8c155
Merge pull request #1530 from vodik/pytest-cleanups
Use pytest.raises for asserting compiler exceptions
2018-03-15 08:14:09 +02:00
Kodi Arfer
d252bb0e94 Mangle names that coincide with Python keywords 2018-03-13 14:55:55 -04:00
Simon Gomizelj
e3f4fc8481 Use pytest.raises for asserting compiler exceptions 2018-03-12 01:44:57 -04:00
Simon Gomizelj
316220b742 Fix AST generation of a naked return 2018-02-14 16:05:31 -05:00
Kodi Arfer
6de7ddfee5 Update copyright years 2018-01-01 10:38:33 -05:00
Simon Gomizelj
2ffaa8e5be Fix yield-from to prevent it from accepting no arguments
Closes #1472
2017-12-30 19:02:15 -05:00
gilch
e43d6f5e2f Merge pull request #1419 from rkday/else_multiple_statements
Allow multiple statements in the else branch of for
2017-09-16 14:10:28 -06:00
Rob Day
be35b09e5d Allow multiple statements in the else branch of a for loop 2017-09-16 20:41:22 +01:00
Ryan Gonzalez
44e5ded522 Merge pull request #1379 from Kodiologist/lua-str-literal
Add #[DELIM[ … ]DELIM] syntax for string literals
2017-09-15 14:36:08 -05:00
Rob Day
567fa14f1d Allow else after a while loop 2017-09-14 20:55:29 +01:00
Kodi Arfer
eb23ddc1e2 Add #[DELIM[ … ]DELIM] syntax for string literals 2017-09-08 11:27:34 -07:00
Kodi Arfer
7ed31a18f3 Forbid arguments to break and continue 2017-08-26 11:37:15 -07:00
David Schaefer
969fa8d533 Fixes #1350: try form in defmacro 2017-08-11 01:21:01 +02:00
Kodi Arfer
ecc974de1e Implement Python 2 exec
The implementation of `hy.core.language.exec` draws code from the `exec_` function in commit f574c7be6ebc80041ef58ca29588f310248ebed4 of the library Six, which is copyright 2010–2017 Benjamin Peterson and licensed under the Expat license.
2017-08-02 13:33:59 -04:00
Kodi Arfer
33052f4180 Test compiling a lot of comment lines 2017-07-12 14:07:42 -07:00
Kodi Arfer
55986b2033 Auto-promote values to HyObjects in the compiler 2017-07-03 17:01:12 -07:00
Kodi Arfer
4be37b358b Make lists no longer magical for the compiler 2017-07-03 17:01:12 -07:00
Kodi Arfer
5bf9ecfc5a Forbid (try) and (try BODY) 2017-05-25 20:48:09 -05:00
Kodi Arfer
81d89c9d12 Enforce the standard order of try elements 2017-05-25 20:48:09 -05:00
Kodi Arfer
2eb81864df Make all files comply with license-header policy 2017-04-27 14:16:57 -07:00
Kodi Arfer
5eb928356a Overhaul semantics of binary operators (#1261)
I've added shadow versions of many operators that didn't have one. And, I've changed the behavior of various binary operators with more or fewer than 2 arguments to make the shadow and real versions more consistent and to make the behavior more logical in either case. For details, see the additions to NEWS and the new file tests/native_tests/operators.hy, which simultaneously tests shadow and real operators.

Although there are a lot of changes, I've put them all in one commit because they're interdependent.
2017-04-13 19:42:01 -05:00
Kodi Arfer
e4a7b317e1 Make fn work like lambda and remove lambda (#1228)
* with-decorator: Allow a `setv` form as the form to be decorated

This feature is of dubious value by itself, but it's necessary to allow `defn` to create a lambda instead of a `def`.

* Make `fn` work the same as `lambda`

That is, allow it to generate a `lambda` instead of a `def` statement if the function body is just an expression.

I've removed two uses of with_decorator in hy.compiler because they'd require adding another case to HyASTCompiler.compile_decorate_expression and they have no ultimate effect, anyway.

In a few tests, I've added a meaningless statement in `fn` bodies to force generation of a `def`.

I've removed `test_fn_compiler_empty_function` rather than rewrite it because it seems like a pain to maintain and not very useful.

* Remove `lambda`, now that `fn` does the same thing
2017-02-22 17:36:52 -06:00
Kodi Arfer
45b7a4ac9d Add bytestring literals 2017-02-19 09:04:45 +02:00
Kodi Arfer
0336ff3c68 Don't put redundant names in _stdlib (#1221)
This prevents pointless imports of hy.core, like importing `map` in Python 3.
2017-02-16 21:14:06 -07:00
Kodi Arfer
31f3a55a26 Remove tests of let 2017-02-13 09:12:13 -08:00
Ryan Gonzalez
24ebbc611e Give an error on empty attributes (#1138)
Give an error on empty attributes

closes #1137
2016-11-30 07:00:48 +02:00
Kodi Arfer
ed8e37da62 Burninate the synonyms true, false, and nil
Per the straw poll in #908, as an alternative to #1147.

Now you must use `True`, `False`, and `None`, as in Python. Or just assign `true` to `True`, etc.; the old synonyms aren't reserved words anymore.
2016-11-23 18:35:17 -08:00
Kodi Arfer
14fddbe6c3 Give require the same features as import (#1142)
Give `require` the same features as `import`

You can now do (require foo), (require [foo [a b c]]), (require [foo [*]]), and (require [foo :as bar]). The first and last forms get you macros named foo.a, foo.b, etc. or bar.a, bar.b, etc., respectively. The second form only gets the macros in the list.

Implements #1118 and perhaps partly addresses #277.

N.B. The new meaning of (require foo) will cause all existing code that uses macros to break. Simply replace these forms with (require [foo [*]]) to get your code working again.

There's a bit of a hack involved in the forms (require foo) or (require [foo :as bar]). When you call (foo.a ...) or (bar.a ...), Hy doesn't actually look inside modules. Instead, these (require ...) forms give the macros names that have periods in them, which happens to work fine with the way Hy finds and interprets macro calls.

* Make `require` syntax stricter and add tests

* Update documentation for `require`

* Documentation wording improvements

* Allow :as in `require` name lists
2016-11-03 09:35:58 +02:00