Restructure branching slighty. Fix error message.
This commit is contained in:
parent
d35887e492
commit
dd30bab480
2 changed files with 9 additions and 9 deletions
|
|
@ -140,7 +140,8 @@ proc isKeyword*(kind: TTokType): bool =
|
||||||
proc isNimIdentifier*(s: string): bool =
|
proc isNimIdentifier*(s: string): bool =
|
||||||
if s[0] in SymStartChars:
|
if s[0] in SymStartChars:
|
||||||
var i = 1
|
var i = 1
|
||||||
while i < s.len:
|
var sLen = s.len
|
||||||
|
while i < sLen:
|
||||||
if s[i] == '_':
|
if s[i] == '_':
|
||||||
inc(i)
|
inc(i)
|
||||||
elif isMagicIdentSeparatorRune(cstring s, 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+1] == '\128' and
|
||||||
buf[pos+2] == '\147': # It's a 'magic separator' en-dash Unicode
|
buf[pos+2] == '\147': # It's a 'magic separator' en-dash Unicode
|
||||||
if buf[pos + magicIdentSeparatorRuneByteWidth] notin SymChars:
|
if buf[pos + magicIdentSeparatorRuneByteWidth] notin SymChars:
|
||||||
lexMessage(L, errInvalidToken, "·")
|
lexMessage(L, errInvalidToken, "–")
|
||||||
break
|
break
|
||||||
inc(pos, magicIdentSeparatorRuneByteWidth)
|
inc(pos, magicIdentSeparatorRuneByteWidth)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -130,14 +130,13 @@ proc hashIgnoreStyle*(x: string): THash =
|
||||||
var c = x[i]
|
var c = x[i]
|
||||||
if c == '_':
|
if c == '_':
|
||||||
inc(i)
|
inc(i)
|
||||||
continue # skip _
|
elif isMagicIdentSeparatorRune(cstring(x), i):
|
||||||
if isMagicIdentSeparatorRune(cstring(x), i):
|
|
||||||
inc(i, magicIdentSeparatorRuneByteWidth)
|
inc(i, magicIdentSeparatorRuneByteWidth)
|
||||||
continue # skip '·' (unicode middle dot)
|
else:
|
||||||
if c in {'A'..'Z'}:
|
if c in {'A'..'Z'}:
|
||||||
c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
|
c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
|
||||||
h = h !& ord(c)
|
h = h !& ord(c)
|
||||||
inc(i)
|
inc(i)
|
||||||
|
|
||||||
result = !$h
|
result = !$h
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue