Commit Graph

40 Commits

Author SHA1 Message Date
Kodi Arfer 80eb27906a Update copyright years 2020-01-09 14:05:12 -05:00
Ryan Gonzalez 0579561b83 Drop clint for colors in favor of colorama
Closes #1820.
2019-10-08 09:50:15 -05:00
Kodi Arfer cc8948d9b9 Return plain lists from HyDict.keys, .values 2019-08-18 09:43:02 -04:00
Kodi Arfer 8576d00ce8 Implement HySequence with tuples instead of lists 2019-08-18 09:43:02 -04:00
Kodi Arfer bba97ab2a6 Remove hy._compat's type aliases 2019-06-04 14:01:59 -04:00
Kodi Arfer 5bfc140b4d Implement format strings 2019-02-26 14:04:24 -05:00
Kodi Arfer 997321d31c Fix .end_line and .end_column of single-token models 2019-02-24 10:13:17 -05:00
Brandon T. Willard 9e62903d8a Add special exception and handling for wrapper errors 2019-02-07 13:45:41 -05:00
Brandon T. Willard cadfa4152b Make colored output configurable
Colored exception output is now disabled by default and configurable through
`hy.errors._hy_colored_errors` and the environment variable
`HY_COLORED_ERRORS`.

Likewise, Hy model/AST color printing is now configurable and disabled by
default.  The corresponding variables are `hy.models._hy_colored_ast_objects`
and `HY_COLORED_AST_OBJECTS`.

Closes hylang/hy#1429, closes hylang/hy#1510.
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 010986e8ca Implement minimal macro namespacing and add tests
This commit adds just enough namespacing to resolve a macro first in the macro's
defining module's namespace (i.e. the module assigned to the `HyASTCompiler`),
then in the namespace/module it's evaluated in.  Namespacing is accomplished by
adding a `module` attribute to `HySymbol`, so that `HyExpression`s can be
checked for this definition namespace attribute and their car symbol resolved
per the above.

As well, a couple tests have been added that cover
- the loading of module-level macros
  - e.g. that only macros defined in the `require`d module are added
- the AST generated for `require`
  - using macros loaded from modules imported via bytecode
- the non-local macro namespace resolution described above
  - a `require`d macro that uses a macro `require` exclusively in its
    module-level namespace
- and that (second-degree `require`d) macros can reference variables within
  their module-level namespaces.

Closes hylang/hy#1268, closes hylang/hy#1650, closes hylang/hy#1416.
2018-11-08 22:57:17 -06:00
Kodi Arfer 1d2c73165d Make HyKeyword callable
Co-authored-by: Simon Gomizelj <simon@vodik.xyz>
2018-07-24 09:19:37 -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 38fdcc2114 Don't let HySymbol inherit from HyString 2018-05-20 14:11:35 -07:00
Kodi Arfer 9368e4bc4e Use model patterns for `import` and `require`
In the process, I've banned the syntax `(import [foo])` in favor of `(import foo)`.
2018-05-20 14:07:44 -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
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
Tuukka Turto af89fd68b0 Report objects when raising type error (#1554)
Give better error report when replacing non-hy objects
2018-03-28 21:45:49 -05:00
Kodi Arfer d501d4d806 Mangle symbols at compile-time instead of parse-time
This means that a HySymbol remembers its original name. That is, `a-b` and `a_b` are different symbols although `(setv a-b 1)` and `(setv a_b 1)` set the same variable (namely, `a_b`).

Most of the edits in this commit are to switch underscores to hyphens in places where mangling hasn't happened yet.

I removed some lexer tests since the lexer no longer does any mangling.
2018-03-13 14:55:15 -04:00
Tuukka Turto 5c720c0110
Merge pull request #1473 from Kodiologist/new-year-2018
Update copyright years
2018-02-05 15:11:59 +02:00
Kodi Arfer 6de7ddfee5 Update copyright years 2018-01-01 10:38:33 -05:00
Kodi Arfer a26480a81b Don't parse large floats as symbols 2017-11-11 15:14:28 -08:00
Ryan Gonzalez db210929d0 Merge pull request #1360 from gilch/model-repr
proper reprs for Hy models
2017-09-18 08:45:28 -05:00
gilch d38956fb9e remove trailing commas in HyDict reprs 2017-09-18 01:03:00 -06:00
Rob Day 5a6488e353 Treat _42 etc. as a variable name, not an integer 2017-09-16 16:12:29 -07:00
Kodi Arfer deb801edab Preserve .brackets in quoted HyStrings 2017-09-08 11:27:34 -07:00
gilch 2d8a318e0c color compound hy model reprs 2017-09-07 11:50:22 -07:00
gilch 021204af13 make HyCons __repr__ iterative 2017-09-07 11:50:22 -07:00
gilch 860431b2a5 make HyCons repr indented and multi-line 2017-09-07 11:50:22 -07:00
gilch 7674bf3267 proper reprs for Hy models 2017-09-07 11:50:16 -07:00
David Schaefer 274f5e9002 Fix copy behaviour of HyComplex 2017-08-09 23:30:16 +02:00
Kodi Arfer bb91b57dca Require capitalizing NaN and Inf like so 2017-07-10 08:50:49 -07:00
Kodi Arfer 55986b2033 Auto-promote values to HyObjects in the compiler 2017-07-03 17:01:12 -07:00
Kodi Arfer 2eb81864df Make all files comply with license-header policy 2017-04-27 14:16:57 -07:00
Kodi Arfer 45b7a4ac9d Add bytestring literals 2017-02-19 09:04:45 +02:00
Kodi Arfer 62e5d8e3e3 In hy.models, factor out strip_digit_separators 2017-02-16 19:43:16 -08:00
Kodi Arfer bebcbbeba6 Change KEYWORD_PREFIX to HyKeyword.PREFIX 2017-02-16 19:43:16 -08:00
Kodi Arfer ace125ee9b Consolidate hy.models.* and tests/models/* into one file apiece
They were a lot of similar, tiny files.
2017-02-16 19:43:00 -08:00