Move isidentifier
to hy.lex
This commit is contained in:
parent
d7da03be12
commit
5dcb03b64d
@ -2,7 +2,7 @@
|
|||||||
# This file is part of Hy, which is free software licensed under the Expat
|
# This file is part of Hy, which is free software licensed under the Expat
|
||||||
# license. See the LICENSE.
|
# license. See the LICENSE.
|
||||||
|
|
||||||
import sys, keyword
|
import sys
|
||||||
|
|
||||||
PY3 = sys.version_info[0] >= 3
|
PY3 = sys.version_info[0] >= 3
|
||||||
PY36 = sys.version_info >= (3, 6)
|
PY36 = sys.version_info >= (3, 6)
|
||||||
@ -15,11 +15,3 @@ def reraise(exc_type, value, traceback=None):
|
|||||||
raise value.with_traceback(traceback)
|
raise value.with_traceback(traceback)
|
||||||
finally:
|
finally:
|
||||||
traceback = None
|
traceback = None
|
||||||
|
|
||||||
|
|
||||||
def isidentifier(x):
|
|
||||||
if x in ('True', 'False', 'None'):
|
|
||||||
return True
|
|
||||||
if keyword.iskeyword(x):
|
|
||||||
return False
|
|
||||||
return x.isidentifier()
|
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import keyword
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
from hy._compat import isidentifier
|
|
||||||
from hy.lex.exceptions import PrematureEndOfInput, LexException # NOQA
|
from hy.lex.exceptions import PrematureEndOfInput, LexException # NOQA
|
||||||
from hy.models import HyExpression, HySymbol
|
from hy.models import HyExpression, HySymbol
|
||||||
|
|
||||||
@ -191,3 +191,11 @@ def read(from_file=sys.stdin, eof=""):
|
|||||||
|
|
||||||
def read_str(input):
|
def read_str(input):
|
||||||
return read(StringIO(str(input)))
|
return read(StringIO(str(input)))
|
||||||
|
|
||||||
|
|
||||||
|
def isidentifier(x):
|
||||||
|
if x in ('True', 'False', 'None'):
|
||||||
|
return True
|
||||||
|
if keyword.iskeyword(x):
|
||||||
|
return False
|
||||||
|
return x.isidentifier()
|
||||||
|
Loading…
Reference in New Issue
Block a user