mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 08:34:20 +00:00
Restructure branching slighty. Fix error message.
This commit is contained in:
@@ -140,7 +140,8 @@ proc isKeyword*(kind: TTokType): bool =
|
||||
proc isNimIdentifier*(s: string): bool =
|
||||
if s[0] in SymStartChars:
|
||||
var i = 1
|
||||
while i < s.len:
|
||||
var sLen = s.len
|
||||
while i < sLen:
|
||||
if s[i] == '_':
|
||||
inc(i)
|
||||
elif isMagicIdentSeparatorRune(cstring s, i):
|
||||
@@ -637,7 +638,7 @@ proc getSymbol(L: var TLexer, tok: var TToken) =
|
||||
buf[pos+1] == '\128' and
|
||||
buf[pos+2] == '\147': # It's a 'magic separator' en-dash Unicode
|
||||
if buf[pos + magicIdentSeparatorRuneByteWidth] notin SymChars:
|
||||
lexMessage(L, errInvalidToken, "·")
|
||||
lexMessage(L, errInvalidToken, "–")
|
||||
break
|
||||
inc(pos, magicIdentSeparatorRuneByteWidth)
|
||||
else:
|
||||
|
||||
@@ -130,14 +130,13 @@ proc hashIgnoreStyle*(x: string): THash =
|
||||
var c = x[i]
|
||||
if c == '_':
|
||||
inc(i)
|
||||
continue # skip _
|
||||
if isMagicIdentSeparatorRune(cstring(x), i):
|
||||
elif isMagicIdentSeparatorRune(cstring(x), i):
|
||||
inc(i, magicIdentSeparatorRuneByteWidth)
|
||||
continue # skip '·' (unicode middle dot)
|
||||
if c in {'A'..'Z'}:
|
||||
c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
|
||||
h = h !& ord(c)
|
||||
inc(i)
|
||||
else:
|
||||
if c in {'A'..'Z'}:
|
||||
c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
|
||||
h = h !& ord(c)
|
||||
inc(i)
|
||||
|
||||
result = !$h
|
||||
|
||||
|
||||
Reference in New Issue
Block a user