Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25153: build: update the grammar/parser generation rules r=knz a=knz CockroachDB uses a two-step process to generate a SQL syntax parser: the main definition file `sql.y` is first pre-processed (to add error handling and contextual help) into another `.y` file, and then that file is given as input to `goyacc`. Prior to this patch, the result of preprocessing would also be named `sql.y` (albeit in a separate directory). This creates a hurdle when troubleshooting changes to the grammar: when goyacc complains, it refers to its input file by name, without directory context. For the contributor unaware of the two-step process described above, it is confusing to see an error refer to a file named "`sql.y`", open that file in its expected location (`sql/parser`) and see no relevant context there (because the error really refers to `sql/parser/gen/sql.y`). The first change in this patch aims to alleviate this confusion, by clarifying that `goyacc` operates on a different file: the intermediate file is now called `sql-gen.y`. The seond change works around a bug in `goyacc`: when generating an error message, `goyacc` computes a line number based on all non-empty, non-comment lines in the `.y` file. This means that if `goyacc` is given a file with empty lines or comments, the line number information becomes unusable to navigate to the context of the error. This patch works around this bug in `goyacc` by stripping comment and empty lines from `sql-gen.y`. Release note: None Co-authored-by: Raphael 'kena' Poss <[email protected]>
- Loading branch information