Commit Graph

301 Commits

Author SHA1 Message Date
redraiment 2b40dea54d Fixes #1875: parse-args requires values to be representable as Hy models
* Update argument spec parse logic of parse-args function.
* Update test case of parse-args function.
* Update document of parse-args function.
* Describe the change in NEWS file.
2020-03-31 10:44:26 -04:00
Kodi Arfer 80eb27906a Update copyright years 2020-01-09 14:05:12 -05:00
Kodi Arfer 0e55d7d955 Allow more than two arguments to `in` or `not-in` 2020-01-09 14:04:12 -05:00
Adam Porter 0f3d256ebf Add: parse-args function
Closes #1719.
2019-10-30 10:16:45 -05:00
Ryan Gonzalez e1ab140a6e Implement the of macro 2019-10-08 09:40:15 -05:00
Ryan Gonzalez 1865feb7d6 Implement PEP 3107 & 526 annotations (closes #1794) 2019-10-08 09:40:15 -05:00
Kodi Arfer 52c0e4e221 Add explicit checks for HyList 2019-08-18 09:43:02 -04:00
Kodi Arfer 9ddb3b1031 Rewrite `_with` 2019-08-18 09:43:02 -04:00
Kodi Arfer 6cced31738 Rewrite `cond` 2019-08-18 09:43:02 -04:00
Kodi Arfer 9b4178ebd0 Remove undocumented fns `integer` and `string` 2019-06-04 14:01:59 -04:00
Kodi Arfer 6af6a2945a Remove `if-python2` and its uses 2019-06-04 14:01:59 -04:00
Kodi Arfer ecf0352d37 Remove aliases: `builtins`, `FileNotFoundError` 2019-06-04 14:01:59 -04:00
Kodi Arfer 2685b01a4b Remove miscellaneous PY3 checks 2019-06-04 14:01:59 -04:00
Kodi Arfer bba97ab2a6 Remove hy._compat's type aliases 2019-06-04 14:01:59 -04:00
Kodi Arfer e77ce92635 Simplify gensym format 2019-04-29 08:10:51 -04:00
Tristan Cacqueray d793cee90a add `tuple?` function `hy.core`
`tuple?` will test if the argument is an instance of tuple.
2019-04-23 15:25:49 -04:00
Tristan Cacqueray 1c7ca7ac1f update contrib and macro to use the new list? function 2019-04-09 00:07:10 +00:00
Tristan Cacqueray b0ed103931 add `list?` function to `hy.core`
`list?` will test if the argument is an instance of list.
2019-04-09 00:07:10 +00:00
Kodi Arfer cbca711865
Merge pull request #1758 from brandonwillard/fix-decorator-error
Check arguments in with-decorator tag
2019-04-08 14:15:32 -04:00
Kodi Arfer 0fe7f42efc Remove internal checks for Python 3.5 2019-03-17 18:28:39 -04:00
Brandon T. Willard 9203fcaeb5 Check arguments in with-decorator tag
Fixes #1757.
2019-03-16 23:19:49 -05:00
Brandon T. Willard fb6feaf082 Improve correspondence with Python errors and console behavior
Compiler and command-line error messages now reflect their Python counterparts.
E.g. where Python emits a `SyntaxError`, so does Hy; same for `TypeError`s.
Multiple tests have been added that check the format and type of raised
exceptions over varying command-line invocations (e.g. interactive and not).

A new exception type for `require` errors was added so that they can be treated
like normal run-time errors and not compiler errors.

The Hy REPL has been further refactored to better match the class-structured
API.  Now, different error types are handled separately and leverage more base
class-provided functionality.

Closes hylang/hy#1486.
2019-02-07 13:45:41 -05:00
Brandon T. Willard 51c7efe6e8 Retain compiled source and file information for exceptions
This commit refactors the exception/error classes and their handling.
It also retains Hy source strings and their originating file information, when
available, all throughout the core parser and compiler functions.

As well, with these changes, calling code is no longer responsible for providing
source and file details to exceptions,

Closes hylang/hy#657.
2019-02-07 13:43:58 -05:00
Kodi Arfer 62638b44a3 Update copyright years 2019-02-07 08:57:35 -05:00
Brandon T. Willard b8b02c9df9 Handle empty `defmain` args
Closes hylang/hy#1707.
2018-11-29 14:37:52 -06:00
Brandon T. Willard 8b6646d5c9 Remove `hy.core` compilation requirement from `hy` package
Previously, when importing `hy` (and any of its sub-packages/modules), Hy source
compilation for `hy.core.language` was necessarily triggered.  This, in turn,
would trigger compilation of the other standard library source files.

This commit removes that chain of events and allows the `hy` package to be
imported without any Hy compilation.

Furthermore, `read` and `read_str` are now implemented in Python and the Hy
standard library files now handle their own dependencies explicitly (i.e. they
`import` and/or `require` the other standard library files upon which they
depend).

The latter changes were necessary, because the automatically triggered
compilation of `hy.core.language` (and associated standard library files) was
serving--implicitly--as a means of producing bytecode in an order that just
happened to work for any compilation occurring afterward.  This chain of
events/dependencies was extremely cryptic, brittle, and difficult to debug, and
these changes should help to remedy that.

Closes hylang/hy#1697.
2018-11-28 14:12:33 -05:00
Brandon T. Willard 86fda31ab1 Move compilation and parsing functions out of `importer.py`
Functions and variables relating to compilation and parsing have been moved to
`compiler.py` and `lex/__init__.py`, respectively.  Those functions are
  - `hy_parse` from `hy.importer` to `hy.lex`
  - `hy_eval`, `ast_compile`, and `calling_module` from `hy.importer` to
  `hy.compiler`

Closes hylang/hy#1695.
2018-11-28 14:12:33 -05:00
Brandon T. Willard 144a7fa240 Produce Python AST for `require` statements and skip self `require`s
Closes hylang/hy#1211.
2018-11-08 22:57:17 -06:00
Brandon T. Willard 96f99c29d1 Fix missing import in `doc` macro expansion 2018-09-24 16:39:13 -04:00
Brandon T. Willard 87a5b117a1 Implement new importer using PEP-302 semantics
Python 3.x is patched in a way that integrates `.hy` source files into
Pythons default `importlib` machinery.  In Python 2.7, a PEP-302 "importer"
and "loader" is implemented according to the standard `import` logic (via
`pkgutil` and later pure-Python `imp` package code).

In both cases, the entry-point for the loaders is through `sys.path_hooks` only.
As well, the import semantics have been updated all throughout to utilize
`importlib` and follow aspects of PEP-420.  This, along with some light
patches, should allow for basic use of `runpy`, `py_compile` and `reload`.

In all cases, if a `.hy` file is shadowed by a `.py`, Hy will silently use
`.hy`.
2018-08-25 22:50:38 -05:00
Kodi Arfer 734cdcd2fd Delay importing the lexer and parser
This speeds up runs of Hy that never need to parse or compile Hy code (e.g., running a Hy program that's already byte-compiled).
2018-08-18 18:05:40 -04:00
Oskar Kvist edbe8e3b7f Make defmacro! work with optional args 2018-06-25 11:45:23 -07:00
Kodi Arfer cf0dafef9b Update uses of the old comprehension forms 2018-06-13 17:31:08 -07:00
Kodi Arfer e1972c535f Remove `for/a`, `for*`, and `for/a*` 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 e344ac1fd6 Fix the management of _stdlib
_stdlib is a global variable, so core modules could use it, contrary to our intention, so long as they happened to be compiled after a non-core module. I've added a compiler attribute to track whether we can use _stdlib.

This fix exposed some cases where hy.core.shadow tried to use a core function, so I fixed those.

I've also added an `if not _stdlib` to `load_stdlib` so that we only bother to actually load _stdlib once.
2018-05-24 17:51:21 -07:00
Kodi Arfer ec1c92bf4e Allow `for` with an empty body 2018-04-29 19:51:00 -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 4a6b633ad2 Add some missing imports 2018-04-21 12:25:29 -07:00
Kodi Arfer 1f95da2b0b Avoid using a core function name as a variable 2018-04-21 12:25:29 -07:00
Kodi Arfer a605936651 Remove &key
It's redundant with &optional.
2018-04-19 09:26:02 -07:00
Kodi Arfer c93a60ede0 Remove support for cons cells 2018-04-12 16:45:17 -07:00
Simon Gomizelj 291847af15 Make HyKeyword constructor consistent
The colon is now only part of its string representation and no longer
accepted as part of the constructor:

  :foobar == HyKeyword("foobar")
2018-04-07 22:29:20 -07:00
Simon Gomizelj 1b7dfd2839 Make HyKeyword a first class objects
HyKeywords are no longer an instances of string with a particular
prefix, but a completely separate object.

This means keywords no longer trip isinstance str checks, adding a
little bit of type safety to the compiler.

It also means that HyKeywords evaluate to themselves.

Closes #1352
2018-04-07 22:29:20 -07:00
Kodi Arfer 03eab21fbf Avoid a Python 3.7 deprecation warning 2018-03-24 12:34:43 -07:00
gilch e7b21cc0df fix indent 2018-03-23 14:16:06 -07:00
Kodi Arfer ad59fd7ff6 In -> and ->>, don't modify the arguments 2018-03-23 13:57:19 -07:00
Kodi Arfer 6875ae0e3f Replace `hyify` with `unmangle` 2018-03-13 14:56:49 -04:00
Kodi Arfer 85968e70dd Add `mangle` and `unmangle` as core functions 2018-03-13 14:55:55 -04:00