From 7fdee6f9f0d2cf1e4c5cf1ea2f46757ebddb0fa8 Mon Sep 17 00:00:00 2001 From: Christian De la Hoz Date: Wed, 1 Sep 2021 17:47:14 +0200 Subject: [PATCH] bug fixes --- corpus/create_sequence_statement.txt | 1 - corpus/grant_statement.txt | 2 +- ...{block.txtor_statement.txt => for_statement.txt} | 0 corpus/plpgsql/raise_statement.txt | 2 +- corpus/select_statement/value_expression.txt | 8 ++------ grammar.js | 13 ++++++++----- 6 files changed, 12 insertions(+), 14 deletions(-) rename corpus/plpgsql/{block.txtor_statement.txt => for_statement.txt} (100%) diff --git a/corpus/create_sequence_statement.txt b/corpus/create_sequence_statement.txt index 036de7b..4b43a95 100644 --- a/corpus/create_sequence_statement.txt +++ b/corpus/create_sequence_statement.txt @@ -222,7 +222,6 @@ owned by none; (as (identifier)) (sequence_increment - (ERROR) (number)) (sequence_min (number)) diff --git a/corpus/grant_statement.txt b/corpus/grant_statement.txt index c12d6b6..75a66b6 100644 --- a/corpus/grant_statement.txt +++ b/corpus/grant_statement.txt @@ -15,7 +15,7 @@ grant all on table foo to postgres; ================================================================================ all privileges ================================================================================ -grant all privileges on table foo.bar to postgres; +GRANT ALL PRIVILEGES ON TABLE FOO.BAR TO POSTGRES; -------------------------------------------------------------------------------- (source_file diff --git a/corpus/plpgsql/block.txtor_statement.txt b/corpus/plpgsql/for_statement.txt similarity index 100% rename from corpus/plpgsql/block.txtor_statement.txt rename to corpus/plpgsql/for_statement.txt diff --git a/corpus/plpgsql/raise_statement.txt b/corpus/plpgsql/raise_statement.txt index 4cf3b2b..b598f90 100644 --- a/corpus/plpgsql/raise_statement.txt +++ b/corpus/plpgsql/raise_statement.txt @@ -11,7 +11,7 @@ end $$; (block (dollar_quote) (body - (ERROR)) + (raise_statement)) (dollar_quote)))) ================================================================================ diff --git a/corpus/select_statement/value_expression.txt b/corpus/select_statement/value_expression.txt index 2dfcd6b..5e2e2ec 100644 --- a/corpus/select_statement/value_expression.txt +++ b/corpus/select_statement/value_expression.txt @@ -33,9 +33,7 @@ SELECT 1234, -25, TRUE, FALSE, NULL, *; (select_item (number)) (select_item - (op_expression - (minus) - (number))) + (number)) (select_item (true)) (select_item @@ -89,9 +87,7 @@ SELECT -22 + - (5 + 1); (select_statement (select_item (op_expression - (op_expression - (minus) - (number)) + (number) (op_expression (minus) (op_expression diff --git a/grammar.js b/grammar.js index cf0c447..89ac368 100644 --- a/grammar.js +++ b/grammar.js @@ -297,7 +297,7 @@ module.exports = grammar({ grant_privileges: $ => choice( - seq(kw("all"), optional("privileges")), + seq(kw("all"), optional(kw("privileges"))), commaSep1($.identifier), ), @@ -437,9 +437,12 @@ module.exports = grammar({ // TODO(chrde): https://www.postgresql.org/docs/13/plpgsql-errors-and-messages.html raise_statement: $ => seq( - kw("raise"), optional($.identifier), - $.string, - optional(seq(",", commaSep($._value_expression))) + kw("raise"), + optional(seq( + optional($.identifier), + $.string, + optional(seq(",", commaSep($._value_expression))) + )), ), if_statement: $ => seq( @@ -810,7 +813,7 @@ module.exports = grammar({ null: $ => kw("null"), star: $ => "*", any: $ => /.*/, - number: $ => /\d+/, + number: $ => /-?\d+/, identifier: $ => $._identifier, _identifier: $ => /[a-zA-Z0-9_]+(\.?[a-zA-Z0-9_]+)*/, // ^