diff --git a/docs/language/syntax.rst b/docs/language/syntax.rst index deed2cb..fa1e7b6 100644 --- a/docs/language/syntax.rst +++ b/docs/language/syntax.rst @@ -99,7 +99,7 @@ Python-legal names. The rules are: - Convert all hyphens (``-``) to underscores (``_``). Thus, ``foo-bar`` becomes ``foo_bar``. -- If the name ends with ``?``, remove it and prepend ``is``. Thus, ``tasty?`` +- If the name ends with ``?``, remove it and prepend ``is_``. Thus, ``tasty?`` becomes ``is_tasty``. - If the name still isn't Python-legal, make the following changes. A name could be Python-illegal because it contains a character that's never legal in @@ -107,13 +107,13 @@ Python-legal names. The rules are: it's equal to a Python reserved word. - Prepend ``hyx_`` to the name. - - Replace each illegal character with ``ΔfooΔ`` (or on Python 2, ``XfooX``), - where ``foo`` is the the Unicode character name in lowercase, with spaces - replaced by underscores and hyphens replaced by ``H``. Replace ``Δ`` itself - (or on Python 2, ``X``) the same way. If the character doesn't have a name, - use ``U`` followed by its code point in lowercase hexadecimal. + - Replace each illegal character with ``XfooX``, where ``foo`` is the Unicode + character name in lowercase, with spaces replaced by underscores and + hyphens replaced by ``H``. Replace ``X`` itself the same way. If the + character doesn't have a name, use ``U`` followed by its code point in + lowercase hexadecimal. - Thus, ``green☘`` becomes ``hyx_greenΔshamrockΔ`` and ``if`` becomes + Thus, ``green☘`` becomes ``hyx_greenXshamrockX`` and ``if`` becomes ``hyx_if``. - Finally, any added ``hyx_`` or ``is_`` is added after any leading diff --git a/hy/lex/parser.py b/hy/lex/parser.py index 1287d91..d4814f5 100755 --- a/hy/lex/parser.py +++ b/hy/lex/parser.py @@ -23,7 +23,7 @@ pg = ParserGenerator( cache_id="hy_parser" ) -mangle_delim = 'Δ' if PY3 else 'X' +mangle_delim = 'X' def unicode_to_ucs4iter(ustr): # Covert a unicode string to an iterable object, diff --git a/tests/native_tests/mangling.hy b/tests/native_tests/mangling.hy index 032e205..e009ab6 100644 --- a/tests/native_tests/mangling.hy +++ b/tests/native_tests/mangling.hy @@ -40,70 +40,49 @@ (setv # "no comment") (assert (= # "no comment")) - (if PY3 - (assert (= hyx_Δnumber_signΔ "no comment")) - (assert (= hyx_Xnumber_signX "no comment"))) + (assert (= hyx_Xnumber_signX "no comment")) (setv $ "dosh") (assert (= $ "dosh")) - (if PY3 - (assert (= hyx_Δdollar_signΔ "dosh")) - (assert (= hyx_Xdollar_signX "dosh")))) + (assert (= hyx_Xdollar_signX "dosh"))) (defn test-basic-multilingual-plane [] (setv ♥ "love" ⚘ab "flower") (assert (= (+ ⚘ab ♥) "flowerlove")) - (if PY3 - (assert (= (+ hyx_ΔflowerΔab hyx_Δblack_heart_suitΔ) "flowerlove")) - (assert (= (+ hyx_XflowerXab hyx_Xblack_heart_suitX) "flowerlove"))) + (assert (= (+ hyx_XflowerXab hyx_Xblack_heart_suitX) "flowerlove")) (setv ⚘-⚘ "doubleflower") (assert (= ⚘-⚘ "doubleflower")) - (if PY3 - (assert (= hyx_ΔflowerΔ_ΔflowerΔ "doubleflower")) - (assert (= hyx_XflowerX_XflowerX "doubleflower"))) + (assert (= hyx_XflowerX_XflowerX "doubleflower")) (setv ⚘? "mystery") (assert (= ⚘? "mystery")) - (if PY3 - (assert (= hyx_is_ΔflowerΔ "mystery")) - (assert (= hyx_is_XflowerX "mystery")))) + (assert (= hyx_is_XflowerX "mystery"))) (defn test-higher-unicode [] (setv 😂 "emoji") (assert (= 😂 "emoji")) (if PY3 - (assert (= hyx_Δface_with_tears_of_joyΔ "emoji")) + (assert (= hyx_Xface_with_tears_of_joyX "emoji")) (assert (= hyx_XU1f602X "emoji")))) (defn test-nameless-unicode [] (setv  "private use") (assert (=  "private use")) - (if PY3 - (assert (= hyx_ΔUe000Δ "private use")) - (assert (= hyx_XUe000X "private use")))) + (assert (= hyx_XUe000X "private use"))) (defn test-charname-with-hyphen [] (setv a