From 193e616636ea5cbd3401bd91482a560f91123895 Mon Sep 17 00:00:00 2001 From: rulego-team Date: Mon, 16 Jun 2025 12:06:16 +0800 Subject: [PATCH] fix:Array Index Parsing Fails on Complex Structures --- rsql/lexer.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/rsql/lexer.go b/rsql/lexer.go index 5def1c1..59ca231 100644 --- a/rsql/lexer.go +++ b/rsql/lexer.go @@ -235,20 +235,10 @@ func (l *Lexer) peekChar() byte { func (l *Lexer) readIdentifier() string { position := l.pos - for isLetter(l.ch) || isDigit(l.ch) || l.ch == '.' || l.ch == '[' || l.ch == ']' || l.ch == '\'' || l.ch == '"' { - // 如果遇到方括号,需要特殊处理以确保括号内容被正确包含 - if l.ch == '[' { - l.readChar() // 跳过 '[' - // 继续读取直到找到匹配的 ']' - for l.ch != ']' && l.ch != 0 { - l.readChar() - } - if l.ch == ']' { - l.readChar() // 跳过 ']' - } - } else { - l.readChar() - } + // 只处理基本标识符和点号(用于嵌套字段访问) + // 数组索引(方括号)应该由解析器处理,而不是词法分析器 + for isLetter(l.ch) || isDigit(l.ch) || l.ch == '.' { + l.readChar() } return l.input[position:l.pos] }