@@ -94,28 +94,37 @@ const
9494 " is_not" , " not" , " of" , " as" , " from" , " .." , " and" , " or" , " xor" ,
9595 ]
9696
97- proc endsWith (s, subs: string , endIdx: var int ): bool =
97+ proc eqIdent (a, b: string ): bool =
98+ a.nimIdentNormalize == b.nimIdentNormalize
99+
100+ proc endsWithIdent (s, subs: string ): bool =
101+ let le = subs.len
102+ if le > s.len: return false
103+ s[^ le .. ^ 1 ].eqIdent subs
104+
105+ proc continuesWithIdent (s, subs: string , start: int ): bool =
106+ s.substr (start, start+ subs.high).eqIdent subs
107+
108+ proc endsWithIdent (s, subs: string , endIdx: var int ): bool =
98109 endIdx.dec subs.len
99- result = s.continuesWith (subs, endIdx+ 1 )
110+ result = s.continuesWithIdent (subs, endIdx+ 1 )
100111
101112proc containsObjectOf (x: string ): bool =
102113 const sep = ' '
103114 var idx = x.rfind (sep)
104115 if idx == - 1 : return
105-
106116 template eatWord (word) =
107117 while x[idx] == sep: idx.dec
108- result = x.endsWith (word, idx)
118+ result = x.endsWithIdent (word, idx)
109119 if not result : return
110-
111120 eatWord " of"
112121 eatWord " object"
113122 result = true
114123
115124proc endsWithLineContinuationToken (x: string ): bool =
116125 result = false
117126 for tok in LineContinuationTokens :
118- if x.endsWith (tok):
127+ if x.endsWithIdent (tok):
119128 return true
120129 result = x.containsObjectOf
121130
0 commit comments