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
20 changes: 20 additions & 0 deletions components/webui/client/src/sql-parser/Sql.g4
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
grammar Sql;

import SqlBase;

selectItemList
: selectItem (',' selectItem)*
;

standaloneSelectItemList
: selectItemList EOF
;
Comment on lines +5 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider adding documentation comments.

The grammar rules are well-structured for parsing SELECT clause fragments. However, adding comments would improve maintainability and clarify the intended usage for future syntax highlighting.

Consider adding documentation:

+// Parse a comma-separated list of SELECT items (e.g., "col1, col2, func(col3)")
 selectItemList
     : selectItem (',' selectItem)*
     ;
 
+// Standalone entry point for parsing SELECT items in isolation
 standaloneSelectItemList
     : selectItemList EOF
     ;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
selectItemList
: selectItem (',' selectItem)*
;
standaloneSelectItemList
: selectItemList EOF
;
// Parse a comma-separated list of SELECT items (e.g., "col1, col2, func(col3)")
selectItemList
: selectItem (',' selectItem)*
;
// Standalone entry point for parsing SELECT items in isolation
standaloneSelectItemList
: selectItemList EOF
;
🤖 Prompt for AI Agents
In components/webui/client/src/sql-parser/Sql.g4 around lines 5 to 11, the
grammar rules selectItemList and standaloneSelectItemList lack documentation;
add brief ANTLR comments immediately above each rule (using // or /* */)
describing the rule's purpose, intended input and output shape, examples of
valid snippets (e.g., "a, b AS alias"), and any edge-cases (e.g., trailing
commas disallowed), so future maintainers can quickly understand usage and
constraints.


standaloneBooleanExpression
: booleanExpression EOF
;

sortItemList
: sortItem (',' sortItem)*
;

standaloneSortItemList
: sortItemList EOF
;
Comment on lines +17 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

LGTM: Consistent pattern for ORDER BY clause parsing.

The rules follow the same pattern as the SELECT item rules, providing a clean, consistent approach for parsing ORDER BY clause fragments with proper EOF handling.

Consider adding documentation similar to the SELECT rules:

+// Parse a comma-separated list of ORDER BY sort items (e.g., "col1 ASC, col2 DESC")
 sortItemList
     : sortItem (',' sortItem)*
     ;
 
+// Standalone entry point for parsing ORDER BY items in isolation
 standaloneSortItemList
     : sortItemList EOF
     ;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sortItemList
: sortItem (',' sortItem)*
;
standaloneSortItemList
: sortItemList EOF
;
// Parse a comma-separated list of ORDER BY sort items (e.g., "col1 ASC, col2 DESC")
sortItemList
: sortItem (',' sortItem)*
;
// Standalone entry point for parsing ORDER BY items in isolation
standaloneSortItemList
: sortItemList EOF
;
🤖 Prompt for AI Agents
In components/webui/client/src/sql-parser/Sql.g4 around lines 17 to 23, add a
short grammar comment/documentation for sortItemList and standaloneSortItemList
mirroring the SELECT item rules: describe that sortItemList parses one or more
sortItem separated by commas and is used inside ORDER BY clauses, and that
standaloneSortItemList enforces end-of-input (EOF) for parsing isolated ORDER BY
fragments; include a brief example of usage and note why the EOF rule exists for
standalone parsing to aid future maintainers.

10 changes: 5 additions & 5 deletions components/webui/client/src/sql-parser/generated/SqlLexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ export default class SqlLexer extends Lexer {
public static readonly EOF = Token.EOF;

public static readonly channelNames: string[] = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];
public static readonly literalNames: (string | null)[] = [ null, "'.'",
"'('", "')'",
"','", "'?'",
public static readonly literalNames: (string | null)[] = [ null, "','",
"'.'", "'('",
"')'", "'?'",
"'->'", "'['",
"']'", "'=>'",
"'ADD'", "'ADMIN'",
Expand Down Expand Up @@ -988,8 +988,8 @@ export default class SqlLexer extends Lexer {
491,2212,1,0,0,0,493,2216,1,0,0,0,495,2226,1,0,0,0,497,2234,1,0,0,0,499,
2245,1,0,0,0,501,2256,1,0,0,0,503,2279,1,0,0,0,505,2307,1,0,0,0,507,2325,
1,0,0,0,509,2334,1,0,0,0,511,2336,1,0,0,0,513,2338,1,0,0,0,515,2355,1,0,
0,0,517,2370,1,0,0,0,519,2376,1,0,0,0,521,522,5,46,0,0,522,2,1,0,0,0,523,
524,5,40,0,0,524,4,1,0,0,0,525,526,5,41,0,0,526,6,1,0,0,0,527,528,5,44,
0,0,517,2370,1,0,0,0,519,2376,1,0,0,0,521,522,5,44,0,0,522,2,1,0,0,0,523,
524,5,46,0,0,524,4,1,0,0,0,525,526,5,40,0,0,526,6,1,0,0,0,527,528,5,41,
0,0,528,8,1,0,0,0,529,530,5,63,0,0,530,10,1,0,0,0,531,532,5,45,0,0,532,
533,5,62,0,0,533,12,1,0,0,0,534,535,5,91,0,0,535,14,1,0,0,0,536,537,5,93,
0,0,537,16,1,0,0,0,538,539,5,61,0,0,539,540,5,62,0,0,540,18,1,0,0,0,541,
Expand Down
Loading
Loading