Skip to content

Commit 193e616

Browse files
committed
fix:Array Index Parsing Fails on Complex Structures
1 parent 43a9f46 commit 193e616

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

rsql/lexer.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,10 @@ func (l *Lexer) peekChar() byte {
235235

236236
func (l *Lexer) readIdentifier() string {
237237
position := l.pos
238-
for isLetter(l.ch) || isDigit(l.ch) || l.ch == '.' || l.ch == '[' || l.ch == ']' || l.ch == '\'' || l.ch == '"' {
239-
// 如果遇到方括号,需要特殊处理以确保括号内容被正确包含
240-
if l.ch == '[' {
241-
l.readChar() // 跳过 '['
242-
// 继续读取直到找到匹配的 ']'
243-
for l.ch != ']' && l.ch != 0 {
244-
l.readChar()
245-
}
246-
if l.ch == ']' {
247-
l.readChar() // 跳过 ']'
248-
}
249-
} else {
250-
l.readChar()
251-
}
238+
// 只处理基本标识符和点号(用于嵌套字段访问)
239+
// 数组索引(方括号)应该由解析器处理,而不是词法分析器
240+
for isLetter(l.ch) || isDigit(l.ch) || l.ch == '.' {
241+
l.readChar()
252242
}
253243
return l.input[position:l.pos]
254244
}

0 commit comments

Comments
 (0)