antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.
MIT License
10.24k stars 3.72k forks source link

[postgresql] Fixes for #4321, #4322 #4323

Closed kaby76 closed 5 days ago

kaby76 commented 1 week ago

This PR fixes #4321 and #4322.

For #4321, the grammar rule typename was refactored from the gram.y. The second alt was removed because it added ambiguity.

For #4322, a_expr_caret was corrected to follow the usual Floyd operator precedence grammar pattern. The input SELECT 1 * 2 ^ 3 + 4; is no longer ambiguous.

Several other rules were corrected to remove some of the lingering pl/pgsql grammar rules, which caused ambiguity in col_name_keyword and c_expr.

As I progress in the clean up of this grammar, keep an eye on the list of rules with ambiguity. Before I started a couple of weeks ago, the list of ambiguous rules was this:

a_expr_add
a_expr_and
a_expr_compare
a_expr_qual_op
alter_table_cmd
c_expr
col_name_keyword
colid
collabel
createfunc_opt_list
frame_bound
from_list
func_type
group_by_item
into_clause
opt_analyze
opt_target_list
optschemaeltlist
reindexstmt
select_with_parens
selectstmt
stmt
table_ref
tableelement
type_function_name
zone_value

It is now this:

a_expr_and
a_expr_compare
c_expr
frame_bound
group_by_item
select_with_parens
selectstmt
table_ref

The readme was updated to reflect fixes to the grammar that removed Antlr Tool warnings.

teverett commented 5 days ago

@kaby76 thanks