'nimrod pretty': next steps
This commit is contained in:
parent
d640121ce6
commit
e5be2e9f97
2 changed files with 8 additions and 1 deletions
|
|
@ -75,7 +75,7 @@ proc pragmaAsm*(c: PContext, n: PNode): char =
|
||||||
if n != nil:
|
if n != nil:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
if (it.kind == nkExprColonExpr) and (it.sons[0].kind == nkIdent):
|
if it.kind == nkExprColonExpr and it.sons[0].kind == nkIdent:
|
||||||
case whichKeyword(it.sons[0].ident)
|
case whichKeyword(it.sons[0].ident)
|
||||||
of wSubsChar:
|
of wSubsChar:
|
||||||
if it.sons[1].kind == nkCharLit: result = chr(int(it.sons[1].intVal))
|
if it.sons[1].kind == nkCharLit: result = chr(int(it.sons[1].intVal))
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ proc beautifyName(s: string, k: TSymKind): string =
|
||||||
result.add s[i]
|
result.add s[i]
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
|
proc checkStyle*(info: TLineInfo, s: string, k: TSymKind) =
|
||||||
|
let beau = beautifyName(s, k)
|
||||||
|
if s != beau:
|
||||||
|
Message(info, errGenerated,
|
||||||
|
"name does not adhere to naming convention; should be: " & beau)
|
||||||
|
|
||||||
const
|
const
|
||||||
Letters = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
|
Letters = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
|
||||||
|
|
||||||
|
|
@ -103,6 +109,7 @@ proc processSym(c: PPassContext, n: PNode): PNode =
|
||||||
let s = n.sym
|
let s = n.sym
|
||||||
# operators stay as they are:
|
# operators stay as they are:
|
||||||
if s.kind == skTemp or s.name.s[0] notin Letters: return
|
if s.kind == skTemp or s.name.s[0] notin Letters: return
|
||||||
|
if s.kind in {skType, skGenericParam} and sfAnon in s.flags: return
|
||||||
|
|
||||||
if s.id in cannotRename: return
|
if s.id in cannotRename: return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue