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("&"):
|
if obj.startswith("&"):
|
||||||
return HyLambdaListKeyword(obj)
|
return HyLambdaListKeyword(obj)
|
||||||
|
|
||||||
if obj.startswith("*") and obj.endswith("*") and obj not in ("*", "**"):
|
def mangle(p):
|
||||||
obj = obj[1:-1].upper()
|
if p.startswith("*") and p.endswith("*") and p not in ("*", "**"):
|
||||||
|
p = p[1:-1].upper()
|
||||||
|
|
||||||
if "-" in obj and obj != "-":
|
if "-" in p and p != "-":
|
||||||
obj = obj.replace("-", "_")
|
p = p.replace("-", "_")
|
||||||
|
|
||||||
if obj.endswith("?") and obj != "?":
|
if p.endswith("?") and p != "?":
|
||||||
obj = "is_%s" % (obj[:-1])
|
p = "is_%s" % (p[:-1])
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
||||||
|
obj = mangle(obj)
|
||||||
|
|
||||||
return HySymbol(obj)
|
return HySymbol(obj)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user