Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## [Unreleased]

### Fixed

- Fixed a parser bug that interpreted comment characters inside string literals
as initializing a comment (#555).

## 0.5.2 - 2026-09-11

### Changed
Expand Down
2 changes: 1 addition & 1 deletion tree-sitter-ggsql/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ module.exports = grammar({
)
)),

string: $ => seq("'", repeat(choice(/[^'\\]/, /\\./)), "'"),
string: $ => token(seq("'", repeat(choice(/[^'\\]/, /\\./)), "'")),

boolean: $ => choice('true', 'false'),

Expand Down
152 changes: 152 additions & 0 deletions tree-sitter-ggsql/test/corpus/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4536,3 +4536,155 @@ DRAW point SETTING bounds => [null, 1, Inf, -Inf], limit => inf
(bare_identifier)))
value: (parameter_value
(infinity))))))))

================================================================================
Label string containing URL with comment-like sequences
================================================================================

VISUALISE
DRAW point
LABEL caption => 'Data source: <https://doi.org/10.1371/journal.pone.0090081> -- see appendix'

--------------------------------------------------------------------------------

(query
(visualise_statement
(visualise_keyword)
(viz_clause
(draw_clause
(geom_type)))
(viz_clause
(label_clause
(label_assignment
(label_type
(identifier
(bare_identifier)))
(string))))))

================================================================================
Line comment (double slash) between clauses
================================================================================

// A leading comment
VISUALISE x, y // trailing comment on the same line
DRAW point
// comment before a clause
LABEL title => 'My Plot' // and one at the end

--------------------------------------------------------------------------------

(query
(comment)
(visualise_statement
(visualise_keyword)
(global_mapping
(mapping_list
(mapping_element
(implicit_mapping
(identifier
(bare_identifier))))
(mapping_element
(implicit_mapping
(identifier
(bare_identifier))))))
(comment)
(viz_clause
(draw_clause
(geom_type)))
(comment)
(viz_clause
(label_clause
(label_assignment
(label_type
(identifier
(bare_identifier)))
(string)))))
(comment))

================================================================================
SQL line comment (double dash)
================================================================================

VISUALISE x -- pick the x column
DRAW point

--------------------------------------------------------------------------------

(query
(visualise_statement
(visualise_keyword)
(global_mapping
(mapping_list
(mapping_element
(implicit_mapping
(identifier
(bare_identifier))))))
(comment)
(viz_clause
(draw_clause
(geom_type)))))

================================================================================
Block comment spanning lines
================================================================================

VISUALISE /* inline block */ x, y
DRAW point
/* a multi-line
block comment */
LABEL title => 'My Plot'

--------------------------------------------------------------------------------

(query
(visualise_statement
(visualise_keyword)
(comment)
(global_mapping
(mapping_list
(mapping_element
(implicit_mapping
(identifier
(bare_identifier))))
(mapping_element
(implicit_mapping
(identifier
(bare_identifier))))))
(viz_clause
(draw_clause
(geom_type)))
(comment)
(viz_clause
(label_clause
(label_assignment
(label_type
(identifier
(bare_identifier)))
(string))))))

================================================================================
Comments alongside strings that contain comment-like text
================================================================================

-- leading comment
VISUALISE
DRAW point
LABEL caption => 'see https://example.com -- details' // trailing comment

--------------------------------------------------------------------------------

(query
(comment)
(visualise_statement
(visualise_keyword)
(viz_clause
(draw_clause
(geom_type)))
(viz_clause
(label_clause
(label_assignment
(label_type
(identifier
(bare_identifier)))
(string)))))
(comment))
Loading