diff options
author | Araq <rumpf_a@web.de> | 2013-07-30 21:10:45 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-07-30 21:10:45 +0200 |
commit | e5be2e9f97b12021b38da75e3d2a0f348b3da023 (patch) | |
tree | 171f115a2c4c2a9e19543eb7d06bee44f026007a /compiler | |
parent | d640121ce62adfae4506e1d980b3920ebd1a7168 (diff) | |
download | Nim-e5be2e9f97b12021b38da75e3d2a0f348b3da023.tar.gz |
'nimrod pretty': next steps
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/pragmas.nim | 2 | ||||
-rw-r--r-- | compiler/pretty.nim | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 30478c9ee..c4f23c504 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -75,7 +75,7 @@ proc pragmaAsm*(c: PContext, n: PNode): char = if n != nil: for i in countup(0, sonsLen(n) - 1): 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) of wSubsChar: if it.sons[1].kind == nkCharLit: result = chr(int(it.sons[1].intVal)) diff --git a/compiler/pretty.nim b/compiler/pretty.nim index 07f547837..d69c9c8f4 100644 --- a/compiler/pretty.nim +++ b/compiler/pretty.nim @@ -75,6 +75,12 @@ proc beautifyName(s: string, k: TSymKind): string = result.add s[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 Letters = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'} @@ -103,6 +109,7 @@ proc processSym(c: PPassContext, n: PNode): PNode = let s = n.sym # operators stay as they are: 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 |