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
|
||||
# license. See the LICENSE.
|
||||
|
||||
import sys, keyword
|
||||
import sys
|
||||
|
||||
PY3 = sys.version_info[0] >= 3
|
||||
PY36 = sys.version_info >= (3, 6)
|
||||
@ -15,11 +15,3 @@ def reraise(exc_type, value, traceback=None):
|
||||
raise value.with_traceback(traceback)
|
||||
finally:
|
||||
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
|
||||
|
||||
import keyword
|
||||
import re
|
||||
import sys
|
||||
import unicodedata
|
||||
|
||||
from hy._compat import isidentifier
|
||||
from hy.lex.exceptions import PrematureEndOfInput, LexException # NOQA
|
||||
from hy.models import HyExpression, HySymbol
|
||||
|
||||
@ -191,3 +191,11 @@ def read(from_file=sys.stdin, eof=""):
|
||||
|
||||
def read_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