Commit Graph

875 Commits

Author SHA1 Message Date
Kodi Arfer
f17a21be63 Use X as the mangle delimiter on Python 3 2018-04-04 10:50:33 -07:00
Yigong Wang
be8537c0cf Add recent REPL results globals *i and most recent error *e
This comment add *1, *2, *3 as globals for recent REPL results.
*e global is also added for the most recent error object.
2018-04-02 00:21:13 -04:00
Yigong Wang
4073c78069 Add -E support for Hy REPL
This commit adds -E support for Hy. Similar to Python, hy will ignore
all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME,
that might be set.
2018-03-31 15:16:40 -07:00
Simon Gomizelj
b27cdfed69 Fix defclass construction
Python Class AST expects a body which is a list of ast.Expr. Force
every entry to be stored as a statement. This means we'll preserve
print statements.

Python also doesn't construct docstrings in classes by setting a
__doc__ attribute, it does it by inspecting the first ast.Expr node of
the class. But this means we can remove the special handler for it.
2018-03-31 02:43:53 -04: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
268eba93fe Update a disassembly test for Python 3.7 2018-03-24 12:34:43 -07:00
Kodi Arfer
cf60dc7a13 Fix a hy-repr test for Python 3.7 2018-03-24 12:34:43 -07:00
Kodi Arfer
e3058b5cf5 Handle module docstrings on Python 3.7 2018-03-24 12:34:43 -07:00
Kodi Arfer
cfb042304c Test module docstrings 2018-03-24 12:34:43 -07:00
Kodi Arfer
ad59fd7ff6 In -> and ->>, don't modify the arguments 2018-03-23 13:57:19 -07:00
Simon Gomizelj
c663d38e33 Add metaclass support, support PEP 3115 and PEP 487 2018-03-22 13:28:22 -07:00
Simon Gomizelj
75af667fa1 Fix test_hy2py not respecting 'only_py36' 2018-03-22 13:27:56 -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
3c97d2982c Use *1 instead of _ for REPL history
`_`, as a variable, is now the shadow subtraction operator.
2018-03-13 14:56:47 -04:00
Kodi Arfer
85968e70dd Add mangle and unmangle as core functions 2018-03-13 14:55:55 -04:00
Kodi Arfer
ebc9bda7ee Remove an obsolete test 2018-03-13 14:55:55 -04:00
Kodi Arfer
0c8c5dc830 Mangle special forms 2018-03-13 14:55:55 -04:00
Kodi Arfer
ccb3ba6092 Mangle macro names 2018-03-13 14:55:55 -04:00
Kodi Arfer
0c816f2e83 Mangle keyword arguments 2018-03-13 14:55:55 -04:00
Kodi Arfer
d252bb0e94 Mangle names that coincide with Python keywords 2018-03-13 14:55:55 -04:00
Kodi Arfer
52edad28e2 Overhaul mangling rules 2018-03-13 14:55:53 -04: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
Kodi Arfer
7fcc7ac4b6 Make unary comparison ops evaluate their argument 2018-03-13 14:38:36 -04:00
Kodi Arfer
9f0911161d Fix tests with =-and-parentheses errors 2018-03-13 14:38:36 -04:00
Simon Gomizelj
e3f4fc8481 Use pytest.raises for asserting compiler exceptions 2018-03-12 01:44:57 -04:00
Kodi Arfer
0574e275b5 Make hy-repr support some collections classes 2018-03-10 18:11:07 -08:00
Kodi Arfer
38f461890d Make hy-repr support DateTime objects 2018-03-10 18:11:07 -08:00
Kodi Arfer
3dbe05302e Make hy-repr support regex match objects 2018-03-10 18:11:07 -08:00
Kodi Arfer
f7ab9a6e7c Make hy-repr support dictionary views 2018-03-10 18:11:07 -08:00
Kodi Arfer
90a09b5b44 Make hy-repr use double spaces for dictionaries 2018-03-10 18:11:07 -08:00
Kodi Arfer
199bb70150 Add a hy-repr test for keyword-like bytes objects 2018-03-10 18:11:07 -08:00
Kodi Arfer
4f2706e18e Test a case where hy-repr shouldn't round-trip 2018-03-10 18:11:07 -08:00
Kodi Arfer
83c4f63bc2 Reimplement hy-repr with registered functions
This removes a lot of hy-reprs that were hard-coded into the hy-repr function itself. It also allows you to add a hy-repr for an existing class without monkey-patching the class.
2018-03-10 18:11:07 -08:00
Simon Gomizelj
db58dacce6 Fix invalid escape sequence \s in test_escapes 2018-02-14 16:05:31 -05:00
Simon Gomizelj
316220b742 Fix AST generation of a naked return 2018-02-14 16:05:31 -05:00
Simon Gomizelj
7b87d42221 Properly teardown subprocesses when testing 2018-02-14 15:38:47 -05:00
Simon Gomizelj
5c40f793a1 Support PEP 328
Add support for proper relative imports
2018-02-06 23:41:12 -05:00
Tuukka Turto
5c720c0110
Merge pull request #1473 from Kodiologist/new-year-2018
Update copyright years
2018-02-05 15:11:59 +02:00
Tuukka Turto
cf87de5cc2
Merge pull request #1483 from vodik/remove-def
Just remove `def`
2018-01-31 08:54:59 +02:00
Simon Gomizelj
0cd4df3898 Remove def and standardize on setv 2018-01-21 00:25:33 -05:00
Tuukka Turto
a9621817f9
Merge pull request #1433 from Kodiologist/while-multistatement
Handle statements in the condition of `while`
2018-01-11 07:45:27 +02:00
Kodi Arfer
64cf7c7437
Merge pull request #1456 from Kodiologist/big-floats
Don't parse large floats as symbols
2018-01-11 00:44:50 -05:00
Kodi Arfer
6de7ddfee5 Update copyright years 2018-01-01 10:38:33 -05:00
Simon Gomizelj
f69ccd2421 Allow coroutines to be decorated 2017-12-31 09:03:39 -05:00
Simon Gomizelj
1e4ad3167b Introduce for/a* and for/a expressions 2017-12-30 19:02:15 -05:00
Simon Gomizelj
783d53ecb7 Introduce with/a* and with/a expressions 2017-12-30 19:02:15 -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
Simon Gomizelj
e3e01d4405 Introduce fn/a and defn/a
Closes #1054
2017-12-30 19:02:15 -05:00
Rob Day
eda78eb81c Allow multiple expressions in a try 2017-12-03 09:47:41 +00:00
Kodi Arfer
a26480a81b Don't parse large floats as symbols 2017-11-11 15:14:28 -08:00
Kodi Arfer
fd64575799 Handle statements in the condition of while 2017-11-02 07:31:58 -07:00
Ryan Gonzalez
e0e664c030
Merge branch 'master' into letmacro 2017-11-01 09:39:18 -05:00
gilch
8f2e80d12e add newlines in disassemble tests for astor 0.6 2017-10-31 21:46:44 -06:00
gilch
6bb997dbea update astor to 0.6 2017-10-31 14:13:41 -06:00
gilch
e90f082baf back let with dict for better defclass behavior 2017-10-30 20:23:57 -06:00
Tuukka Turto
fac87c99d0
Merge pull request #1444 from gilch/xi-tag
change xi macro to #% tag macro
2017-10-29 21:34:56 +02:00
Tuukka Turto
268463c68d
Merge pull request #1432 from Kodiologist/else-detection
Don't treat [else…] or ("else"…) as else clauses
2017-10-29 21:21:32 +02:00
gilch
497e929913 generalize #% to arbitrary expressions 2017-10-26 14:23:25 -06:00
gilch
b5f1136ba5 %* %** parameters for #% tag macro 2017-10-26 13:03:01 -06:00
gilch
f81fb771eb change xi macro to #% tag macro 2017-10-26 12:55:48 -06:00
gilch
2319adcc7f fix whitespace in anaphoric 2017-10-26 12:53:08 -06:00
gilch
c4b3d7bcda fix gensym format to start with _ for import * 2017-09-23 23:41:37 -06:00
gilch
a54f6aa38b add hidden &name parameter to macros
The module name allows macros to preexpand their body in the proper
context.
2017-09-23 14:59:43 -06:00
gilch
5bbf4d9894 fix premature binding in let 2017-09-22 20:07:48 -06:00
Kodi Arfer
1e456c6ced Don't treat [else…] or ("else"…) as else clauses 2017-09-20 16:34:56 -07:00
Kodi Arfer
f8fbcf3f06 Spacing fix in test 2017-09-20 16:31:55 -07:00
Kodi Arfer
39785b4657 Fix a crash in HyTypeError.__str__ 2017-09-20 10:40:52 -07:00
gilch
20b4342d40 support (global) in let 2017-09-18 14:54:08 -06:00
gilch
ba898aa8d8 support (nonlocal) in let 2017-09-18 13:51:32 -06:00
gilch
34038ff433 implement let 2017-09-18 12:21:42 -06: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
907e72681f Let argument destructuring work with docstrings 2017-09-17 21:06:45 +01:00
Rob Day
5a6488e353 Treat _42 etc. as a variable name, not an integer 2017-09-16 16:12:29 -07: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
3f69ed8e8e Merge pull request #1399 from Kodiologist/compiler-refactor 2017-09-15 14:44:32 -05: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
cf7ff802c9 Make hy.compiler.builds more flexible
I removed the "Hypster" error message and the test for it because it can only catch compiler bugs that should themselves be caught by Hy's tests.
2017-09-13 13:30:59 -07:00
Kodi Arfer
277469dfe1 Add xfail test of #1390 (statements in assert) 2017-09-13 13:30:54 -07:00
Kodi Arfer
deb801edab Preserve .brackets in quoted HyStrings 2017-09-08 11:27:34 -07:00
Kodi Arfer
eb23ddc1e2 Add #[DELIM[ … ]DELIM] syntax for string literals 2017-09-08 11:27:34 -07:00
gilch
b23f6e5b59 test hy model reprs 2017-09-08 10:54:24 -07:00
gilch
50c21ca38c disable Popen shell option in test_bin.py
Fix failing tests from #1289 caused by bad quoting for Windows shell
Improve test_bin_hy_builtins and warn that it fails from IPython.
2017-09-05 13:35:22 -06:00
Kodi Arfer
e3e7fa8ce6 Catch exceptions raised by HyREPL.output_fn 2017-08-29 14:54:26 -07:00
Kodi Arfer
0fc96306bc Drop support for Python 3.3 2017-08-26 13:36:51 -07:00
Kodi Arfer
7ed31a18f3 Forbid arguments to break and continue 2017-08-26 11:37:15 -07:00
Kodi Arfer
8b677bb20c Un-xfail a passing test of macroexpand
It seems that #1374 (1faee7ac39) fixed this bug.
2017-08-25 15:25:06 -07:00
Kodi Arfer
2bbf886ceb Make assoc a macro instead of a special form
The new macro evaluates its lvalue only once.
2017-08-25 11:41:28 -07:00
Ryan Gonzalez
dea99c8b76 Merge pull request #1354 from gilch/comment-discard
add #_ discard syntax
2017-08-19 11:29:57 -05:00
Kodi Arfer
8d40a68232 Initialize the return variable of with 2017-08-19 07:35:41 -07:00
Kodi Arfer
f5ee5f4ee5 Whitespace fix 2017-08-19 07:25:00 -07:00
Kodi Arfer
21ea36f277 Add return as a special form 2017-08-11 13:56:44 -07:00
David Schaefer
969fa8d533 Fixes #1350: try form in defmacro 2017-08-11 01:21:01 +02:00
David Schaefer
274f5e9002 Fix copy behaviour of HyComplex 2017-08-09 23:30:16 +02:00
Jordan Danford
c67b8bccb9 Expose read, read_str, and eval in Python
- Expose `read`, `read_str`, and `eval` in Python
- Add string evaluation example to interop section of docs
- Add test for `eval`
- Explain `eof` keyword argument in `read` docstring
2017-08-05 17:29:15 -07:00
gilch
0f81369deb tests for #_ and (comment ...) 2017-08-04 14:35:11 -06:00
David Schaefer
432d560310 No TypeError from multi-arity defn returning None 2017-08-04 17:08:41 +02:00
Kodi Arfer
e8ffd41202 Merge pull request #1349 from woodrush/fix-unquote-splice-none
Allow `unquote-splice` to accept any false value as empty
2017-08-02 19:50:47 -04:00