Skip to content

Commit

Permalink
Add info_statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Ce11an committed Aug 25, 2024
1 parent bda9e6b commit 5a472a7
Show file tree
Hide file tree
Showing 7 changed files with 63,664 additions and 62,762 deletions.
16 changes: 16 additions & 0 deletions examples/info.surql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Root information
INFO FOR ROOT;

-- Namespace information
INFO FOR NS;

-- Database information
INFO FOR DB;

-- Table information
INFO FOR TABLE user;

-- User information
INFO FOR USER root ON ROOT;
INFO FOR USER ns_user ON NAMESPACE;
INFO FOR USER db_user ON DATABASE;
30 changes: 30 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = grammar({
),
),
semi_colon: _ => token(";"),
keyword_info: _ => token("INFO"),
keyword_if: _ => token("IF"),
keyword_exists: _ => token("EXISTS"),
keyword_tokenizers: _ => token("TOKENIZERS"),
Expand Down Expand Up @@ -170,6 +171,7 @@ module.exports = grammar({
keyword_signin: _ => token("SIGNIN"),
keyword_signup: _ => token("SIGNUP"),
keyword_database: _ => token("DATABASE"),
keyword_namespace: _ => token("NAMESPACE"),
keyword_password: _ => token("PASSWORD"),
keyword_password_hash: _ => token("PASSHASH"),
keyword_on_duplicate_key_update: _ => token("ON DUPLICATE KEY UPDATE"),
Expand Down Expand Up @@ -218,6 +220,18 @@ module.exports = grammar({
$.relate_statement,
$.delete_statement,
$.use_statement,
$.info_statement,
),

info_statement: $ => seq($.keyword_info, $.keyword_for, $.info_target),

info_target: $ =>
choice(
$.root_info,
$.namespace_info,
$.database_info,
$.table_info,
$.user_info,
),

use_statement: $ =>
Expand Down Expand Up @@ -563,6 +577,22 @@ module.exports = grammar({

// Clauses

root_info: $ => $.keyword_root,

namespace_info: $ => choice($.keyword_ns, $.keyword_namespace),

database_info: $ => choice($.keyword_db, $.keyword_database),

table_info: $ => seq($.keyword_table, $.identifier),

user_info: $ =>
seq($.keyword_user, $.identifier, optional($.on_level_clause)),

on_level_clause: $ => seq($.keyword_on, $.level_clause),

level_clause: $ =>
choice($.keyword_root, $.keyword_namespace, $.keyword_database),

ns_clause: $ => seq($.keyword_ns, $.identifier),
db_clause: $ => seq($.keyword_db, $.identifier),

Expand Down
2 changes: 2 additions & 0 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
(keyword_ignore)
(keyword_values)
(keyword_for)
(keyword_info)
(keyword_comment)
(keyword_fields)
(keyword_columns)
Expand All @@ -145,6 +146,7 @@
(keyword_if)
(keyword_exists)
(keyword_database)
(keyword_namespace)
(keyword_password)
(keyword_password_hash)
(keyword_on_duplicate_key_update)
Expand Down
151 changes: 151 additions & 0 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5a472a7

Please sign in to comment.