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>
This commit is contained in:
parent
d34c22eeac
commit
ceb615d010
@ -242,14 +242,19 @@ def t_identifier(p):
|
||||
if obj.startswith("&"):
|
||||
return HyLambdaListKeyword(obj)
|
||||
|
||||
if obj.startswith("*") and obj.endswith("*") and obj not in ("*", "**"):
|
||||
obj = obj[1:-1].upper()
|
||||
def mangle(p):
|
||||
if p.startswith("*") and p.endswith("*") and p not in ("*", "**"):
|
||||
p = p[1:-1].upper()
|
||||
|
||||
if "-" in obj and obj != "-":
|
||||
obj = obj.replace("-", "_")
|
||||
if "-" in p and p != "-":
|
||||
p = p.replace("-", "_")
|
||||
|
||||
if obj.endswith("?") and obj != "?":
|
||||
obj = "is_%s" % (obj[:-1])
|
||||
if p.endswith("?") and p != "?":
|
||||
p = "is_%s" % (p[:-1])
|
||||
|
||||
return p
|
||||
|
||||
obj = mangle(obj)
|
||||
|
||||
return HySymbol(obj)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user