Skip to content

Commit 40df19b

Browse files
authored
Fix 31 todo tests by adding # comment and parameterized query support (#23)
1 parent 7034530 commit 40df19b

File tree

35 files changed

+108
-35
lines changed

35 files changed

+108
-35
lines changed

lexer/lexer.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func (l *Lexer) NextToken() Item {
9292
if l.ch == '-' && l.peekChar() == '-' {
9393
return l.readLineComment()
9494
}
95+
if l.ch == '#' {
96+
return l.readHashComment()
97+
}
9598
if l.ch == '/' && l.peekChar() == '*' {
9699
return l.readBlockComment()
97100
}
@@ -280,6 +283,20 @@ func (l *Lexer) readLineComment() Item {
280283
return Item{Token: token.COMMENT, Value: sb.String(), Pos: pos}
281284
}
282285

286+
func (l *Lexer) readHashComment() Item {
287+
pos := l.pos
288+
var sb strings.Builder
289+
// Skip #
290+
sb.WriteRune(l.ch)
291+
l.readChar()
292+
293+
for l.ch != '\n' && l.ch != 0 && !l.eof {
294+
sb.WriteRune(l.ch)
295+
l.readChar()
296+
}
297+
return Item{Token: token.COMMENT, Value: sb.String(), Pos: pos}
298+
}
299+
283300
func (l *Lexer) readBlockComment() Item {
284301
pos := l.pos
285302
var sb strings.Builder

parser/parser.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,6 +3098,13 @@ func (p *Parser) parseIdentifierName() string {
30983098
return name
30993099
}
31003100

3101+
// Handle parameterized identifiers like {CLICKHOUSE_DATABASE:Identifier}
3102+
if p.currentIs(token.PARAM) {
3103+
name = "{" + p.current.Value + "}"
3104+
p.nextToken()
3105+
return name
3106+
}
3107+
31013108
// Handle name starting with number (e.g., 03657_test)
31023109
if p.currentIs(token.NUMBER) {
31033110
name = p.current.Value

parser/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestParser(t *testing.T) {
6666
var queryParts []string
6767
for _, line := range strings.Split(string(queryBytes), "\n") {
6868
trimmed := strings.TrimSpace(line)
69-
if trimmed == "" || strings.HasPrefix(trimmed, "--") {
69+
if trimmed == "" || strings.HasPrefix(trimmed, "--") || strings.HasPrefix(trimmed, "#") {
7070
continue
7171
}
7272
// Remove trailing comment if present (but not inside strings - simple heuristic)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain":false,"todo": true}
1+
{"explain":false}

0 commit comments

Comments
 (0)