Commit Graph

110 Commits

Author SHA1 Message Date
Kodi Arfer
6de7ddfee5 Update copyright years 2018-01-01 10:38:33 -05: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
Kodi Arfer
98fb33d0a3 Simplify string parsing with unicode_literals
I switched from `ast.literal_eval` back to `eval` because the former doesn't respect `unicode_literals`.
2017-08-28 10:28:19 -07:00
gilch
203965d0fa add #_ discard syntax 2017-08-02 16:55:14 -06:00
Kodi Arfer
28ce83524b Don't try to lex tag-macro calls as shebangs 2017-07-23 11:43:19 -07:00
Kodi Arfer
2d863abc85 Implement #* and #** unpacking 2017-07-17 13:34:39 -07:00
Kodi Arfer
26d1b3f72e Don't parse 5.attr or :foo.attr as symbols 2017-06-23 08:30:37 -07:00
gilch
6cd3201421 rename sharp macros to tag macros 2017-06-22 22:48:46 -06:00
gilch
20c26a52e4 make sharp macros take arbitrary identifiers
Previously, only a single character was allowed.
2017-06-22 22:46:24 -06:00
Kodi Arfer
2eb81864df Make all files comply with license-header policy 2017-04-27 14:16:57 -07:00
Kodi Arfer
4c38e2c9dd Rename reader macros to "sharp macros" (#1282)
They're not actually reader macros, since their arguments are parsed s-expressions, like a regular macro, not pre-parsed source text.
2017-04-21 10:07:48 -05:00
Kodi Arfer
286d568959 Fix a crash when tokenizing a single quote 2017-04-07 21:12:17 +03:00
Kodi Arfer
45b7a4ac9d Add bytestring literals 2017-02-19 09:04:45 +02: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
Kodi Arfer
5b85990d87 Add a module for getting reserved words (#1171)
This is helpful for writing syntax highlighters (e.g., https://github.com/hylang/hy/pull/1170).
2016-12-12 10:11:42 +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
Gergely Nagy
26f342d580 Teach apply about symbol mangling
apply now mangles strings and keywords according to the Hy mangling
rules (by using the same function, now imported from
hy.lex.parser). With this change, if the dict passed to apply has
keywords, strings or quoted symbols, they'll get mangled, to turn them
into proper keys.

This only works for the cases where the keys are directly in the apply
params. A previously deffed dict, or key through a variable will not be
mangled.

This closes #219.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-09-24 09:47:12 +02:00
Ryan Gonzalez
73ace37678 Fix #831
Blame dot not matching newlines
2015-08-22 15:13:46 -05:00
gilch
a22e2ca4cc purged null from Hy
we already have `nil`, and `null` was barely ever used.
2015-08-11 16:22:13 -06:00
Gergely Nagy
73f8a47f65
Mangle trailing bangs on symbols
Postfixing functions with a bang, like set!, get!, etc are relatively
common. However, those names are not valid in python, so in the name of
python interoperability, lets mangle them to set_bang and get_bang,
respectively.

Closes #536.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2015-08-10 14:37:17 +02:00
Ryan Gonzalez
016d25d104 Add one-argument division and rationals (closes #825 and #826) 2015-07-29 13:30:24 -05:00
Gregor Best
0ba620fc73 Explicitly set missing source on LexExceptions
This fixes the following code:

    (import [hy.lex [tokenize]])
    (tokenize "(foo))")
2015-07-28 16:46:26 +02:00
Ryan Gonzalez
c94c0e8b50 Add set literals (closes #827) 2015-07-14 23:59:29 +03:00
Adam Schwalm
f1df108b31 Add support for multi-line strings in interpreter 2014-12-28 23:38:38 -06:00
James King
277028cdd5 Remove HyLambdaListKeyword from the parser
It's not a syntactic element and doesn't belong in the parser. Parsing
lambda lists is now handled by the compiler alone.
2014-06-03 21:36:49 -04:00
Nicolas Dandrimont
52144820ca Add a cons object and related mechanisms
Closes: #183
2014-01-23 23:08:52 +01:00
Nicolas Dandrimont
eedebd12b3 Merge branch 'master' into pr/443 2014-01-17 20:25:09 +01:00
Foxboron
a35ecc41bd Fix reader macros to actually be macros 2014-01-17 01:07:47 +01:00
Gergely Nagy
8ef02a54b5 hy/lex/parser.py: Add support for sub-object mangling
With this patch, every identifier is split up along dots, each part gets
separately mangled, and then it is all joined back together. This allows
for fun stuff like (.foo? (Foo)), and even more contrived examples.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-01-16 16:23:35 +01:00
Gergely Nagy
ceb615d010 hy/lex/parser.py: Move most of the identifier mangling into a def
As a refactoring step, move the identifier mangling done in t_identifier
into a separate def.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-01-16 16:20:51 +01:00
Nicolas Dandrimont
a44e53f4de Comments end when the input ends or a newline occurs
This fixes #382, which occured because the REPL doesn't use trailing newlines.
2014-01-02 03:09:18 +01:00
Bob Tolbert
f6160c755a Much better version of new error messages.
This version is much simpler.

At the point that the exception is raised, we don't have access to
the actual source, just the current expression. but as the
exception percolates up, we can intercept it, add the source and
the re-raise it.

Then at the final point, in the cmdline handler, we can choose to
let the entire traceback print, or just the simpler, direct error
message.

And even with the full traceback, the last bit is nicely formatted
just like the shorter, simpler message.

The error message is colored if clint is installed, but to avoid
yet another dependency, you get monochrome without clint.

I'm sure there is a better way to do the markup, the current method
is kludgy but works.

I wish there was more shared code between HyTypeError and LexException
but they are kind of different in some fundamental ways.

This doesn't work (yet) with runtime errors generated from Python,
like NameError, but I have a method that can catch NameError and turn it
into a more pleasing output.

Finally, there is no obvious way to raise HyTypeError from pure Hy code,
so methods in core/language.hy throw ugly TypeError/ValueError.
2013-12-31 09:56:03 -07:00
Bob Tolbert
55a7ab1667 add nil as synonym for None 2013-12-27 13:50:19 -07:00
Foxboron
c9fdd40c9f Hy reader macros #377
Added first iteration of reader macros
Refactored defmacro and defreader
Added test inn hy/tests/lex/test_lex.py
Added new test in hy/tests/native/tests
Added new test in hy/tests/macros.

changed the error given in the dispatch macro and added some handling for missing symbol and invalid characters
2013-12-23 14:33:51 +01:00
Paul Tagliamonte
fd60a864eb Translate all foo? -> is_foo. Close #334
The fancypants Hy award goes to Nick for coming up with the quoted
symbol hack for exports. This broke with foo?, since the export string
needs to be is_foo, but using a quoted string will pick up the change
due to it being a Symbol.

Mad clown love for that, @olasd.
2013-12-01 15:03:31 -05:00
Nicolas Dandrimont
81af09d002 Wire the rply parser
Amend the tests to account for the changes
2013-07-28 17:36:36 +02:00
Nicolas Dandrimont
2ed299676f Add a rply-based parser 2013-07-28 17:36:36 +02:00
Nicolas Dandrimont
c8605feaea Add an rply-based lexer 2013-07-28 17:36:36 +02:00
Thomas Ballinger
00da0468e6 larger kludge for escaped characters 2013-06-07 17:07:22 -04:00
Nicolas Dandrimont
9e03e0e6ec Modify HyDict semantics to allow nesting expressions
HyDicts are now HyLists, that get compiled down to dicts
only by the compiler.
2013-05-14 11:43:17 +02:00
Nicolas Dandrimont
b7f92bd915 Don't lex "j" as a complex number.
This fixes #143
2013-05-04 10:27:30 +02:00
James King
0efe3d7c49 Removed .format from lex/states.py 2013-04-19 10:49:57 -04:00
James King
18ed72136f Merge branch 'master' into feature/lambda-list-keyword
Conflicts:
	hy/compiler.py
	hy/lex/states.py
	hy/util.py
	tests/compilers/test_ast.py
	tests/lex/test_lex.py
2013-04-18 15:17:30 -04: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
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
Paul Tagliamonte
c15d8750e8 Merge branch 'f/hy.models.keyword' of git://github.com/algernon/hy into pr-101 2013-04-12 08:58:38 -04:00
James King
9ff3b128b4 Got &rest working, tests pass
Did a little house cleaning in lex states.py too and started removing
stupid print() statements.
2013-04-11 12:00:27 -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