branch: externals/sql-indent commit 53ee1f7a9940908bbd6d3d52541927ef1c5e625a Author: Alex Harsányi <alexharsa...@gmail.com> Commit: Alex Harsányi <alexharsa...@gmail.com>
Syntax after a JOIN statement is now 'select-table (#99) Updated scanning to recognize a position just before or just after a JOIN statement as being a new table definition with a 'select-table syntax. This changes indentation around JOIN statements and existing tests had to change, but overall it will result in better control over the indentation rules. Also updated CI build to use GNU Emacs 27.1 --- .github/workflows/main.yml | 2 +- sql-indent-test.el | 9 + sql-indent.el | 57 +++- sql-indent.org | 4 +- test-data/m-syn.eld | 124 ++++---- test-data/pr17-io-default.eld | 2 +- test-data/pr17-io-left.eld | 2 +- test-data/pr17-io-right.eld | 2 +- test-data/pr17-syn.eld | 22 +- test-data/pr60-syn.eld | 16 +- test-data/pr64-syn.eld | 120 ++++---- test-data/pr67-syn.eld | 660 ++++++++++++++++++++-------------------- test-data/pr68-syn.eld | 25 +- test-data/pr70-syn.eld | 116 +++---- test-data/pr73-syn.eld | 100 +++--- test-data/pr75-oracle-syn.eld | 20 +- test-data/pr75-postgres-syn.eld | 46 +-- test-data/pr85-syn.eld | 96 +++--- test-data/pr99-syn.eld | 150 +++++++++ test-data/pr99.sql | 64 ++++ 20 files changed, 951 insertions(+), 686 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7424994..1b15c3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: emacs_version: - - 26.3 + - 27.1 steps: - uses: purcell/setup-emacs@master with: diff --git a/sql-indent-test.el b/sql-indent-test.el index 57929d4..266a8bd 100644 --- a/sql-indent-test.el +++ b/sql-indent-test.el @@ -252,6 +252,10 @@ information read from DATA-FILE (as generated by (select-column sqlind-indent-select-column sqlind-align-comma) (select-column-continuation sqlind-indent-select-column) + (select-table sqlind-indent-select-table + sqlind-lineup-joins-to-anchor + sqlind-lineup-open-paren-to-anchor + sqlind-align-comma) (select-table-continuation sqlind-indent-select-table sqlind-lineup-joins-to-anchor sqlind-lineup-open-paren-to-anchor @@ -474,4 +478,9 @@ information read from DATA-FILE (as generated by "test-data/pr97.sql" "test-data/pr97-syn.eld")) +(ert-deftest sqlind-ert-pr99 () + (sqlind-ert-check-file-syntax + "test-data/pr99.sql" + "test-data/pr99-syn.eld")) + ;;; sql-indent-test.el ends here diff --git a/sql-indent.el b/sql-indent.el index 44fbb37..c528f78 100644 --- a/sql-indent.el +++ b/sql-indent.el @@ -1135,7 +1135,9 @@ statement is found." ;; condition (goto-char pos) (when (or (looking-at sqlind-join-condition-regexp) - (progn (forward-word -1) (looking-at sqlind-select-join-regexp))) + (progn (forward-word -1) + (and (sqlind-same-level-statement (point) pos) + (looking-at sqlind-select-join-regexp)))) ;; look for the join start, that will be the anchor (let ((jstart (sqlind-find-join-start (point) start))) (when jstart @@ -1144,15 +1146,44 @@ statement is found." ;; if this line starts with a ',' or the previous line starts ;; with a ',', we have a new table (goto-char pos) + ;; NOTE: the combination of tests and movement operations in + ;; the when clause is not ideal... (when (or (looking-at ",") + (looking-at sqlind-select-join-regexp) + (looking-at "join\\b") (progn (sqlind-backward-syntactic-ws) - (looking-at ","))) + (or (looking-at ",") + (progn + (forward-word -1) + (or (looking-at sqlind-select-join-regexp) + (looking-at "join\\b") + (looking-at "from\\b")))))) (throw 'finished (cons 'select-table match-pos))) - ;; otherwise, we continue the table definition from the - ;; previous line. - (throw 'finished (cons 'select-table-continuation match-pos))) + (goto-char pos) + (let ((limit match-pos)) + (if (sqlind-search-backward (point) (regexp-opt (list "," "join") 'symbols) limit) + (progn + (goto-char (match-end 0)) + (sqlind-forward-syntactic-ws) + (when (looking-at "lateral") + (forward-word 1) + (sqlind-forward-syntactic-ws)) + ;; otherwise, we continue the table definition from the + ;; previous line. + (throw 'finished + ;; If, after following all these joins, we got back + ;; to our line, we are in a select-table after all, + ;; otherwise it is a table continuation. + (if (eq (point) pos) + (cons 'select-table match-pos) + (cons 'select-table-continuation (point))))) + (progn ; this must be the first table in the FROM section + (when (looking-at "from\\b") + (forward-word) + (sqlind-forward-syntactic-ws)) + (throw 'finished (cons 'select-table-continuation (point))))))) (t (throw 'finished @@ -2373,7 +2404,7 @@ example: (defun sqlind-lineup-into-nested-statement (syntax _base-indentation) "Align the line to the first word inside a nested statement. -Return the column of the first non-witespace char in a nested +Return the column of the first non-whitespace char in a nested statement. For example: ( a, @@ -2384,9 +2415,17 @@ This function only makes sense in a 'nested-statement-continuation SYTNAX indentation rule." (save-excursion (goto-char (sqlind-anchor-point syntax)) - (forward-char 1) - (sqlind-forward-syntactic-ws) - (current-column))) + (end-of-line) + (let ((limit (point))) + (goto-char (sqlind-anchor-point syntax)) + (forward-char 1) + (sqlind-forward-syntactic-ws) + (if (< (point) limit) + (current-column) + (progn + (goto-char (sqlind-anchor-point syntax)) + (back-to-indentation) + (+ (current-column) sqlind-basic-offset)))))) ;;;;; sqlind-indent-line diff --git a/sql-indent.org b/sql-indent.org index 049508e..b93d804 100644 --- a/sql-indent.org +++ b/sql-indent.org @@ -454,8 +454,8 @@ clause (select, from, where, etc) in which the current point is. defined and a new one is about to start. * ~select-table-continuation~ -- line is inside the from clause, inside a - table definition which starts on a previous line. Note that ANCHOR still - points to the start of the select statement itself. + table definition which starts on a previous line. ANCHOR still points to + the start of the table definition. * ~(in-select-clause CLAUSE)~ -- line is inside the select CLAUSE, which can be "where", "order by", "group by" or "having". Note that CLAUSE can never diff --git a/test-data/m-syn.eld b/test-data/m-syn.eld index fc31b9c..5811578 100644 --- a/test-data/m-syn.eld +++ b/test-data/m-syn.eld @@ -43,73 +43,73 @@ (statement-continuation . 1)) ((select-clause . 80) (statement-continuation . 1)) - ((select-table-continuation . 411) - (statement-continuation . 1)) - ((select-table-continuation . 433) - (nested-statement-continuation . 423) - (statement-continuation . 423)) - ((select-column . 461) - (nested-statement-continuation . 459) - (statement-continuation . 459)) - ((select-column . 461) - (nested-statement-continuation . 459) - (statement-continuation . 459)) - ((select-column . 461) - (nested-statement-continuation . 459) - (statement-continuation . 459)) - ((select-column-continuation . 461) - (nested-statement-continuation . 459) - (statement-continuation . 459)) - ((nested-statement-continuation . 614) - (statement-continuation . 614)) - ((nested-statement-continuation . 614) - (statement-continuation . 614)) - ((nested-statement-continuation . 614) - (statement-continuation . 614)) - ((nested-statement-close . 614) - (statement-continuation . 614)) - ((select-clause . 461) - (nested-statement-continuation . 459) - (statement-continuation . 459)) - ((select-table-continuation . 795) - (nested-statement-continuation . 459) - (statement-continuation . 459)) - ((nested-statement-close . 459) - (statement-continuation . 459)) - ((select-clause . 424) - (nested-statement-continuation . 423) - (statement-continuation . 423)) + ((select-table . 411) + (statement-continuation . 1)) + ((select-table . 431) + (nested-statement-continuation . 421) + (statement-continuation . 421)) + ((select-column . 455) + (nested-statement-continuation . 453) + (statement-continuation . 453)) + ((select-column . 455) + (nested-statement-continuation . 453) + (statement-continuation . 453)) + ((select-column . 455) + (nested-statement-continuation . 453) + (statement-continuation . 453)) + ((select-column-continuation . 455) + (nested-statement-continuation . 453) + (statement-continuation . 453)) + ((nested-statement-continuation . 592) + (statement-continuation . 592)) + ((nested-statement-continuation . 592) + (statement-continuation . 592)) + ((nested-statement-continuation . 592) + (statement-continuation . 592)) + ((nested-statement-close . 592) + (statement-continuation . 592)) + ((select-clause . 455) + (nested-statement-continuation . 453) + (statement-continuation . 453)) + ((select-table . 753) + (nested-statement-continuation . 453) + (statement-continuation . 453)) + ((nested-statement-close . 453) + (statement-continuation . 453)) + ((select-clause . 422) + (nested-statement-continuation . 421) + (statement-continuation . 421)) (((in-select-clause "where") - . 865) - (nested-statement-continuation . 423) - (statement-continuation . 423)) - ((nested-statement-close . 423) - (statement-continuation . 423)) - ((select-table-continuation . 411) - (statement-continuation . 1)) - ((select-table-continuation . 411) - (statement-continuation . 1)) - ((select-column . 928) - (nested-statement-continuation . 926) - (statement-continuation . 926)) - ((select-column . 928) - (nested-statement-continuation . 926) - (statement-continuation . 926)) - ((select-clause . 928) - (nested-statement-continuation . 926) - (statement-continuation . 926)) - ((select-table-continuation . 990) - (nested-statement-continuation . 926) - (statement-continuation . 926)) - ((nested-statement-close . 926) - (statement-continuation . 926)) - ((select-join-condition . 908) + . 811) + (nested-statement-continuation . 421) + (statement-continuation . 421)) + ((nested-statement-close . 421) + (statement-continuation . 421)) + ((select-table . 411) + (statement-continuation . 1)) + ((select-table . 411) + (statement-continuation . 1)) + ((select-column . 866) + (nested-statement-continuation . 864) + (statement-continuation . 864)) + ((select-column . 866) + (nested-statement-continuation . 864) + (statement-continuation . 864)) + ((select-clause . 866) + (nested-statement-continuation . 864) + (statement-continuation . 864)) + ((select-table . 922) + (nested-statement-continuation . 864) + (statement-continuation . 864)) + ((nested-statement-close . 864) + (statement-continuation . 864)) + ((select-join-condition . 848) (statement-continuation . 1)) ((select-clause . 80) (statement-continuation . 1)) (((in-select-clause "group by") - . 1051) + . 975) (statement-continuation . 1)) (((in-select-clause "group by") - . 1051) + . 975) (statement-continuation . 1))) diff --git a/test-data/pr17-io-default.eld b/test-data/pr17-io-default.eld index 86bc559..f474d25 100644 --- a/test-data/pr17-io-default.eld +++ b/test-data/pr17-io-default.eld @@ -1 +1 @@ -(0 0 0 0 0 0 0 0 9 9 9 7 9 2 1 8 3 0 0 7 7 7 7 7 7 2 9 1 3 3 3 3 3 3 24 31 23 25 25 25 25 25 8 0 0 1 3 10 3 8 0 0 3 10 1 3 9 3 7 0 0 12 12 12 0 7 7 7 7 7 7 24 7 24 7 2 31 31 51 51 26 10 10 29 24 14 1 10 1 10 10 0 0 0 0) +(0 0 0 0 0 0 0 0 9 9 9 7 9 2 1 8 3 0 0 7 7 7 7 7 7 2 9 1 3 3 3 3 3 3 24 31 23 25 25 25 25 25 8 0 0 1 3 10 3 8 0 0 3 10 1 3 9 3 7 0 0 12 12 12 0 7 7 7 7 7 7 24 7 24 7 2 31 31 51 51 26 10 8 27 22 12 1 10 1 10 10 0 0 0 0) diff --git a/test-data/pr17-io-left.eld b/test-data/pr17-io-left.eld index e055a8e..ba4ff01 100644 --- a/test-data/pr17-io-left.eld +++ b/test-data/pr17-io-left.eld @@ -1 +1 @@ -(0 0 0 0 0 0 0 0 10 10 10 7 4 0 0 12 0 0 0 7 7 7 7 7 7 0 7 0 0 0 0 0 0 0 19 26 19 19 19 19 19 19 0 0 0 0 0 7 0 0 0 0 0 7 0 0 6 0 0 0 0 2 3 3 0 7 7 7 7 7 7 24 7 24 7 0 29 29 49 49 22 7 2 21 14 6 0 9 0 9 0 0 0 0 0) +(0 0 0 0 0 0 0 0 10 10 10 7 4 0 0 12 0 0 0 7 7 7 7 7 7 0 7 0 0 0 0 0 0 0 19 26 19 19 19 19 19 19 0 0 0 0 0 7 0 0 0 0 0 7 0 0 6 0 0 0 0 2 3 3 0 7 7 7 7 7 7 24 7 24 7 0 29 29 49 49 22 7 6 25 18 10 0 9 0 9 0 0 0 0 0) diff --git a/test-data/pr17-io-right.eld b/test-data/pr17-io-right.eld index 9911834..67cc57b 100644 --- a/test-data/pr17-io-right.eld +++ b/test-data/pr17-io-right.eld @@ -1 +1 @@ -(0 0 0 0 0 0 0 0 10 10 10 7 4 2 1 13 3 0 0 7 7 7 7 7 7 2 9 1 3 3 3 3 3 3 24 31 23 25 25 25 25 25 1 0 0 1 3 10 3 1 0 0 3 10 1 3 9 3 1 0 0 12 12 12 0 7 7 7 7 7 7 24 7 24 7 2 31 31 51 51 26 10 10 29 24 14 1 10 1 10 1 0 0 0 0) \ No newline at end of file +(0 0 0 0 0 0 0 0 10 10 10 7 4 2 1 13 3 0 0 7 7 7 7 7 7 2 9 1 3 3 3 3 3 3 24 31 23 25 25 25 25 25 1 0 0 1 3 10 3 1 0 0 3 10 1 3 9 3 1 0 0 12 12 12 0 7 7 7 7 7 7 24 7 24 7 2 31 31 51 51 26 10 8 27 22 12 1 10 1 10 1 0 0 0 0) \ No newline at end of file diff --git a/test-data/pr17-syn.eld b/test-data/pr17-syn.eld index 7406365..c620385 100644 --- a/test-data/pr17-syn.eld +++ b/test-data/pr17-syn.eld @@ -182,28 +182,28 @@ ((select-clause . 2231) (nested-statement-continuation . 2230) (statement-continuation . 2230)) - ((select-table-continuation . 2224) + ((select-table . 2224) (statement-continuation . 1753)) - ((select-column . 2603) - (nested-statement-continuation . 2602) - (statement-continuation . 2602)) - ((select-clause . 2603) - (nested-statement-continuation . 2602) - (statement-continuation . 2602)) - ((select-join-condition . 2591) + ((select-column . 2601) + (nested-statement-continuation . 2600) + (statement-continuation . 2600)) + ((select-clause . 2601) + (nested-statement-continuation . 2600) + (statement-continuation . 2600)) + ((select-join-condition . 2589) (statement-continuation . 1753)) ((select-clause . 1855) (statement-continuation . 1753)) (((in-select-clause "group by") - . 2726) + . 2718) (statement-continuation . 1753)) ((select-clause . 1855) (statement-continuation . 1753)) (((in-select-clause "order by") - . 2755) + . 2747) (statement-continuation . 1753)) (((in-select-clause "order by") - . 2755) + . 2747) (statement-continuation . 1753)) ((comment-start . 33) (toplevel . 33)) diff --git a/test-data/pr60-syn.eld b/test-data/pr60-syn.eld index 48b7290..a6c1586 100644 --- a/test-data/pr60-syn.eld +++ b/test-data/pr60-syn.eld @@ -15,22 +15,22 @@ ((select-clause . 112) ((create-statement view "myview") . 1)) - ((select-table-continuation . 208) + ((select-table . 208) ((create-statement view "myview") . 1)) ((toplevel . 1)) ((toplevel . 1)) (((create-statement table "foo") - . 282)) - ((select-column . 328) + . 280)) + ((select-column . 326) ((create-statement table "foo") - . 282)) - ((select-clause . 328) + . 280)) + ((select-clause . 326) ((create-statement table "foo") - . 282)) - ((select-table-continuation . 424) + . 280)) + ((select-table . 422) ((create-statement table "foo") - . 282)) + . 280)) ((toplevel . 1)) ((comment-start . 1) (toplevel . 1)) diff --git a/test-data/pr64-syn.eld b/test-data/pr64-syn.eld index 9b77dc5..45a9cb3 100644 --- a/test-data/pr64-syn.eld +++ b/test-data/pr64-syn.eld @@ -1,93 +1,93 @@ (((toplevel . 1)) ((select-clause . 1) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 29) + ((select-join-condition . 27) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 70) + ((select-join-condition . 64) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 111) + ((select-join-condition . 101) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 151) + ((select-join-condition . 137) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 192) + ((select-join-condition . 174) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 233) + ((select-join-condition . 211) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 276) + ((select-join-condition . 250) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table-continuation . 255) (statement-continuation . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 314) - (statement-continuation . 314)) - ((select-table-continuation . 325) - (statement-continuation . 314)) - ((select-join-condition . 342) - (statement-continuation . 314)) + ((select-clause . 291) + (statement-continuation . 291)) + ((select-table . 302) + (statement-continuation . 291)) + ((select-join-condition . 317) + (statement-continuation . 291)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 376) - (statement-continuation . 376)) - ((select-table-continuation . 387) - (statement-continuation . 376)) - ((select-join-condition . 404) - (statement-continuation . 376)) - ((select-table-continuation . 387) - (statement-continuation . 376)) + ((select-clause . 349) + (statement-continuation . 349)) + ((select-table . 360) + (statement-continuation . 349)) + ((select-join-condition . 375) + (statement-continuation . 349)) + ((select-table-continuation . 385) + (statement-continuation . 349)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 447) - (statement-continuation . 447)) - ((select-table-continuation . 458) - (statement-continuation . 447)) - ((select-join-condition . 475) - (statement-continuation . 447)) - ((select-table-continuation . 458) - (statement-continuation . 447)) + ((select-clause . 426) + (statement-continuation . 426)) + ((select-table . 437) + (statement-continuation . 426)) + ((select-join-condition . 452) + (statement-continuation . 426)) + ((select-table-continuation . 463) + (statement-continuation . 426)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 519) - (statement-continuation . 519)) - ((select-table-continuation . 530) - (statement-continuation . 519)) - ((select-join-condition . 547) - (statement-continuation . 519)) - ((select-table-continuation . 530) - (statement-continuation . 519)) + ((select-clause . 505) + (statement-continuation . 505)) + ((select-table . 516) + (statement-continuation . 505)) + ((select-join-condition . 531) + (statement-continuation . 505)) + ((select-table-continuation . 542) + (statement-continuation . 505)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 591) - (statement-continuation . 591)) - ((select-table-continuation . 602) - (statement-continuation . 591)) - ((select-join-condition . 619) - (statement-continuation . 591)) - ((select-table-continuation . 602) - (statement-continuation . 591)) + ((select-clause . 584) + (statement-continuation . 584)) + ((select-table . 595) + (statement-continuation . 584)) + ((select-join-condition . 610) + (statement-continuation . 584)) + ((select-table-continuation . 623) + (statement-continuation . 584)) ((toplevel . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 666) - (statement-continuation . 666)) - ((select-table-continuation . 677) - (statement-continuation . 666)) + ((select-clause . 668) + (statement-continuation . 668)) + ((select-table . 679) + (statement-continuation . 668)) ((select-join-condition . 694) - (statement-continuation . 666)) - ((select-table-continuation . 677) - (statement-continuation . 666)) + (statement-continuation . 668)) + ((select-table-continuation . 699) + (statement-continuation . 668)) ((toplevel . 1))) \ No newline at end of file diff --git a/test-data/pr67-syn.eld b/test-data/pr67-syn.eld index 26030d1..8738ba4 100644 --- a/test-data/pr67-syn.eld +++ b/test-data/pr67-syn.eld @@ -51,10 +51,10 @@ ((select-clause . 568) (nested-statement-continuation . 567) (statement-continuation . 567)) - ((select-table-continuation . 602) + ((select-table . 602) (nested-statement-continuation . 567) (statement-continuation . 567)) - ((select-table-continuation . 602) + ((select-table . 602) (nested-statement-continuation . 567) (statement-continuation . 567)) ((select-clause . 568) @@ -69,32 +69,32 @@ ((in-block elsif "") . 561)) (((in-block else "") - . 798)) - ((statement-continuation . 813)) - ((select-clause . 836) - (statement-continuation . 813)) - ((select-table-continuation . 859) - (statement-continuation . 813)) - ((select-table-continuation . 859) - (statement-continuation . 813)) - ((select-table-continuation . 859) - (statement-continuation . 813)) - ((select-clause . 836) - (statement-continuation . 813)) + . 794)) + ((statement-continuation . 809)) + ((select-clause . 832) + (statement-continuation . 809)) + ((select-table . 855) + (statement-continuation . 809)) + ((select-table . 855) + (statement-continuation . 809)) + ((select-table . 855) + (statement-continuation . 809)) + ((select-clause . 832) + (statement-continuation . 809)) (((in-block loop "") - . 813)) - ((statement-continuation . 1039)) - ((statement-continuation . 1039)) - ((statement-continuation . 1039)) - ((statement-continuation . 1039)) + . 809)) + ((statement-continuation . 1029)) + ((statement-continuation . 1029)) + ((statement-continuation . 1029)) + ((statement-continuation . 1029)) (((block-end loop "") - . 813) + . 809) ((in-block loop "") - . 813)) + . 809)) (((block-end if "") . 179) ((in-block else "") - . 798)) + . 794)) (((block-end toplevel-block "") . 145) ((in-begin-block toplevel-block "") @@ -102,437 +102,437 @@ ((toplevel . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((declare-statement . 1309)) - ((declare-statement . 1309)) - ((declare-statement . 1309)) + ((declare-statement . 1299)) + ((declare-statement . 1299)) + ((declare-statement . 1299)) (((block-start begin) - . 1309) - (declare-statement . 1309)) + . 1299) + (declare-statement . 1299)) (((in-begin-block toplevel-block "") - . 1399)) + . 1389)) (((in-begin-block toplevel-block "") - . 1399)) + . 1389)) (((in-begin-block toplevel-block "") - . 1399)) + . 1389)) (((in-block if "") - . 1461)) + . 1451)) (((in-block if "") - . 1461)) + . 1451)) (((block-start elsif) - . 1461) + . 1451) ((in-block if "") - . 1461)) + . 1451)) (((in-block elsif "") - . 1542)) + . 1532)) (((in-block elsif "") - . 1542)) + . 1532)) (((block-start elsif) - . 1542) + . 1532) ((in-block elsif "") - . 1542)) - ((select-clause . 1636) - (nested-statement-continuation . 1635) - (statement-continuation . 1635)) - ((select-clause . 1636) - (nested-statement-continuation . 1635) - (statement-continuation . 1635)) + . 1532)) + ((select-clause . 1626) + (nested-statement-continuation . 1625) + (statement-continuation . 1625)) + ((select-clause . 1626) + (nested-statement-continuation . 1625) + (statement-continuation . 1625)) (((in-select-clause "where") - . 1699) - (nested-statement-continuation . 1635) - (statement-continuation . 1635)) + . 1689) + (nested-statement-continuation . 1625) + (statement-continuation . 1625)) (((in-block elsif "") - . 1629)) + . 1619)) (((in-block elsif "") - . 1629)) + . 1619)) (((block-start elsif) - . 1629) + . 1619) ((in-block elsif "") - . 1629)) - ((select-clause . 1819) - (nested-statement-continuation . 1818) - (statement-continuation . 1818)) - ((select-table-continuation . 1853) - (nested-statement-continuation . 1818) - (statement-continuation . 1818)) - ((select-table-continuation . 1853) - (nested-statement-continuation . 1818) - (statement-continuation . 1818)) - ((select-clause . 1819) - (nested-statement-continuation . 1818) - (statement-continuation . 1818)) + . 1619)) + ((select-clause . 1809) + (nested-statement-continuation . 1808) + (statement-continuation . 1808)) + ((select-table . 1843) + (nested-statement-continuation . 1808) + (statement-continuation . 1808)) + ((select-table . 1843) + (nested-statement-continuation . 1808) + (statement-continuation . 1808)) + ((select-clause . 1809) + (nested-statement-continuation . 1808) + (statement-continuation . 1808)) (((in-select-clause "where") - . 1969) - (nested-statement-continuation . 1818) - (statement-continuation . 1818)) + . 1955) + (nested-statement-continuation . 1808) + (statement-continuation . 1808)) (((in-block elsif "") - . 1812)) + . 1802)) (((in-block elsif "") - . 1812)) + . 1802)) (((block-start elsif) - . 1812) + . 1802) ((in-block elsif "") - . 1812)) - ((select-clause . 2089) - (nested-statement-continuation . 2088) - (statement-continuation . 2088)) - ((select-table-continuation . 2123) - (nested-statement-continuation . 2088) - (statement-continuation . 2088)) - ((select-table-continuation . 2123) - (nested-statement-continuation . 2088) - (statement-continuation . 2088)) - ((select-table-continuation . 2123) - (nested-statement-continuation . 2088) - (statement-continuation . 2088)) - ((select-clause . 2089) - (nested-statement-continuation . 2088) - (statement-continuation . 2088)) + . 1802)) + ((select-clause . 2075) + (nested-statement-continuation . 2074) + (statement-continuation . 2074)) + ((select-table . 2109) + (nested-statement-continuation . 2074) + (statement-continuation . 2074)) + ((select-table . 2109) + (nested-statement-continuation . 2074) + (statement-continuation . 2074)) + ((select-table . 2109) + (nested-statement-continuation . 2074) + (statement-continuation . 2074)) + ((select-clause . 2075) + (nested-statement-continuation . 2074) + (statement-continuation . 2074)) (((in-select-clause "where") - . 2283) - (nested-statement-continuation . 2088) - (statement-continuation . 2088)) + . 2263) + (nested-statement-continuation . 2074) + (statement-continuation . 2074)) (((in-block elsif "") - . 2082)) + . 2068)) (((in-block elsif "") - . 2082)) + . 2068)) (((block-start else) - . 2082) + . 2068) ((in-block elsif "") - . 2082)) + . 2068)) (((in-block else "") - . 2397)) - ((select-clause . 2422) - (statement-continuation . 2412)) - ((select-table-continuation . 2453) - (statement-continuation . 2412)) - ((select-table-continuation . 2453) - (statement-continuation . 2412)) - ((select-table-continuation . 2453) - (statement-continuation . 2412)) - ((select-clause . 2422) - (statement-continuation . 2412)) + . 2377)) + ((select-clause . 2402) + (statement-continuation . 2392)) + ((select-table . 2433) + (statement-continuation . 2392)) + ((select-table . 2433) + (statement-continuation . 2392)) + ((select-table . 2433) + (statement-continuation . 2392)) + ((select-clause . 2402) + (statement-continuation . 2392)) (((in-select-clause "where") - . 2633) - (statement-continuation . 2412)) + . 2607) + (statement-continuation . 2392)) (((in-block loop "") - . 2412)) - ((statement-continuation . 2702)) - ((statement-continuation . 2702)) - ((statement-continuation . 2702)) - ((statement-continuation . 2702)) + . 2392)) + ((statement-continuation . 2676)) + ((statement-continuation . 2676)) + ((statement-continuation . 2676)) + ((statement-continuation . 2676)) (((block-end loop "") - . 2412) + . 2392) ((in-block loop "") - . 2412)) + . 2392)) (((block-end if "") - . 1461) + . 1451) ((in-block else "") - . 2397)) + . 2377)) (((block-end toplevel-block "") - . 1399) + . 1389) ((in-begin-block toplevel-block "") - . 1399)) + . 1389)) ((toplevel . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((declare-statement . 2966)) - ((declare-statement . 2966)) + ((declare-statement . 2940)) + ((declare-statement . 2940)) (((block-start begin) - . 2966) - (declare-statement . 2966)) + . 2940) + (declare-statement . 2940)) (((in-begin-block toplevel-block "") - . 3026)) + . 3000)) (((in-begin-block toplevel-block "") - . 3026)) + . 3000)) (((in-block if "") - . 3061)) + . 3035)) (((in-block if "") - . 3061)) + . 3035)) (((block-start elsif) - . 3061) + . 3035) ((in-block if "") - . 3061)) - ((select-clause . 3150) - (nested-statement-continuation . 3149) - (statement-continuation . 3149)) + . 3035)) + ((select-clause . 3124) + (nested-statement-continuation . 3123) + (statement-continuation . 3123)) (((in-block elsif "") - . 3143)) + . 3117)) (((in-block elsif "") - . 3143)) + . 3117)) (((block-start elsif) - . 3143) + . 3117) ((in-block elsif "") - . 3143)) - ((select-clause . 3283) - (nested-statement-continuation . 3282) - (statement-continuation . 3282)) - ((select-table-continuation . 3317) - (nested-statement-continuation . 3282) - (statement-continuation . 3282)) - ((select-clause . 3283) - (nested-statement-continuation . 3282) - (statement-continuation . 3282)) - (((in-block elsif "") - . 3276)) - (((in-block elsif "") - . 3276)) + . 3117)) + ((select-clause . 3257) + (nested-statement-continuation . 3256) + (statement-continuation . 3256)) + ((select-table . 3291) + (nested-statement-continuation . 3256) + (statement-continuation . 3256)) + ((select-clause . 3257) + (nested-statement-continuation . 3256) + (statement-continuation . 3256)) + (((in-block elsif "") + . 3250)) + (((in-block elsif "") + . 3250)) (((block-start else) - . 3276) + . 3250) ((in-block elsif "") - . 3276)) + . 3250)) (((in-block else "") - . 3470)) - ((select-clause . 3495) - (statement-continuation . 3485)) - ((select-table-continuation . 3526) - (statement-continuation . 3485)) - ((select-table-continuation . 3526) - (statement-continuation . 3485)) - ((select-table-continuation . 3526) - (statement-continuation . 3485)) - ((select-clause . 3495) - (statement-continuation . 3485)) + . 3442)) + ((select-clause . 3467) + (statement-continuation . 3457)) + ((select-table . 3498) + (statement-continuation . 3457)) + ((select-table . 3498) + (statement-continuation . 3457)) + ((select-table . 3498) + (statement-continuation . 3457)) + ((select-clause . 3467) + (statement-continuation . 3457)) (((in-block loop "") - . 3485)) - ((statement-continuation . 3737)) - ((statement-continuation . 3737)) - ((statement-continuation . 3737)) - ((statement-continuation . 3737)) + . 3457)) + ((statement-continuation . 3703)) + ((statement-continuation . 3703)) + ((statement-continuation . 3703)) + ((statement-continuation . 3703)) (((block-end loop "") - . 3485) + . 3457) ((in-block loop "") - . 3485)) + . 3457)) (((block-end if "") - . 3061) + . 3035) ((in-block else "") - . 3470)) + . 3442)) (((block-end toplevel-block "") - . 3026) + . 3000) ((in-begin-block toplevel-block "") - . 3026)) + . 3000)) ((toplevel . 1)) ((toplevel . 1)) - ((declare-statement . 4000)) - ((declare-statement . 4000)) + ((declare-statement . 3966)) + ((declare-statement . 3966)) (((block-start begin) - . 4000) - (declare-statement . 4000)) + . 3966) + (declare-statement . 3966)) (((in-begin-block toplevel-block "") - . 4060)) + . 4026)) (((in-begin-block toplevel-block "") - . 4060)) + . 4026)) (((in-block if "") - . 4102)) + . 4068)) (((in-block if "") - . 4102)) + . 4068)) (((block-start elsif) - . 4102) + . 4068) ((in-block if "") - . 4102)) - ((select-clause . 4191) - (nested-statement-continuation . 4190) - (statement-continuation . 4190)) + . 4068)) + ((select-clause . 4157) + (nested-statement-continuation . 4156) + (statement-continuation . 4156)) (((in-block elsif "") - . 4184)) + . 4150)) (((in-block elsif "") - . 4184)) + . 4150)) (((block-start elsif) - . 4184) + . 4150) ((in-block elsif "") - . 4184)) - ((select-clause . 4324) - (nested-statement-continuation . 4323) - (statement-continuation . 4323)) - ((select-table-continuation . 4358) - (nested-statement-continuation . 4323) - (statement-continuation . 4323)) - ((select-clause . 4324) - (nested-statement-continuation . 4323) - (statement-continuation . 4323)) - (((in-block elsif "") - . 4317)) - (((in-block elsif "") - . 4317)) + . 4150)) + ((select-clause . 4290) + (nested-statement-continuation . 4289) + (statement-continuation . 4289)) + ((select-table . 4324) + (nested-statement-continuation . 4289) + (statement-continuation . 4289)) + ((select-clause . 4290) + (nested-statement-continuation . 4289) + (statement-continuation . 4289)) + (((in-block elsif "") + . 4283)) + (((in-block elsif "") + . 4283)) (((block-start else) - . 4317) + . 4283) ((in-block elsif "") - . 4317)) + . 4283)) (((in-block else "") - . 4511)) - ((select-clause . 4536) - (statement-continuation . 4526)) - ((select-table-continuation . 4567) - (statement-continuation . 4526)) - ((select-table-continuation . 4567) - (statement-continuation . 4526)) - ((select-table-continuation . 4567) - (statement-continuation . 4526)) - ((select-clause . 4536) - (statement-continuation . 4526)) + . 4475)) + ((select-clause . 4500) + (statement-continuation . 4490)) + ((select-table . 4531) + (statement-continuation . 4490)) + ((select-table . 4531) + (statement-continuation . 4490)) + ((select-table . 4531) + (statement-continuation . 4490)) + ((select-clause . 4500) + (statement-continuation . 4490)) (((in-block loop "") - . 4526)) - ((statement-continuation . 4778)) - ((statement-continuation . 4778)) - ((statement-continuation . 4778)) - ((statement-continuation . 4778)) + . 4490)) + ((statement-continuation . 4736)) + ((statement-continuation . 4736)) + ((statement-continuation . 4736)) + ((statement-continuation . 4736)) (((block-end loop "") - . 4526) + . 4490) ((in-block loop "") - . 4526)) + . 4490)) (((block-end if "") - . 4102) + . 4068) ((in-block else "") - . 4511)) + . 4475)) (((block-end toplevel-block "") - . 4060) + . 4026) ((in-begin-block toplevel-block "") - . 4060)) + . 4026)) (((block-end toplevel nil) - . 3994) + . 3960) ((in-begin-block toplevel nil) - . 3994)) + . 3960)) ((toplevel . 1)) ((toplevel . 1)) - ((declare-statement . 5041)) - ((declare-statement . 5041)) - ((declare-statement . 5041)) + ((declare-statement . 4999)) + ((declare-statement . 4999)) + ((declare-statement . 4999)) (((block-start begin) - . 5041) - (declare-statement . 5041)) + . 4999) + (declare-statement . 4999)) (((in-begin-block toplevel-block "") - . 5133)) + . 5091)) (((in-begin-block toplevel-block "") - . 5133)) + . 5091)) (((in-begin-block toplevel-block "") - . 5133)) + . 5091)) (((in-block if "") - . 5192)) + . 5150)) (((in-block if "") - . 5192)) + . 5150)) (((block-start elsif) - . 5192) + . 5150) ((in-block if "") - . 5192)) + . 5150)) (((in-block elsif "") - . 5274)) + . 5232)) (((in-block elsif "") - . 5274)) + . 5232)) (((block-start elsif) - . 5274) + . 5232) ((in-block elsif "") - . 5274)) - ((select-clause . 5369) - (nested-statement-continuation . 5368) - (statement-continuation . 5368)) + . 5232)) + ((select-clause . 5327) + (nested-statement-continuation . 5326) + (statement-continuation . 5326)) (((in-select-clause "where") - . 5415) - (nested-statement-continuation . 5368) - (statement-continuation . 5368)) + . 5373) + (nested-statement-continuation . 5326) + (statement-continuation . 5326)) (((in-block elsif "") - . 5362)) + . 5320)) (((in-block elsif "") - . 5362)) + . 5320)) (((block-start else) - . 5362) + . 5320) ((in-block elsif "") - . 5362)) + . 5320)) (((in-block else "") - . 5531)) - ((select-clause . 5556) - (statement-continuation . 5546)) + . 5489)) + ((select-clause . 5514) + (statement-continuation . 5504)) (((in-select-clause "where") - . 5598) - (statement-continuation . 5546)) + . 5556) + (statement-continuation . 5504)) (((in-block loop "") - . 5546)) - ((statement-continuation . 5669)) - ((statement-continuation . 5669)) + . 5504)) + ((statement-continuation . 5627)) + ((statement-continuation . 5627)) (((block-end loop "") - . 5546) + . 5504) ((in-block loop "") - . 5546)) + . 5504)) (((block-end if "") - . 5192) + . 5150) ((in-block else "") - . 5531)) + . 5489)) (((block-end toplevel-block "") - . 5133) + . 5091) ((in-begin-block toplevel-block "") - . 5133)) + . 5091)) (((block-end toplevel nil) - . 5035) + . 4993) ((in-begin-block toplevel nil) - . 5035)) + . 4993)) ((toplevel . 1)) (((block-start begin) . 1) (toplevel . 1)) ((toplevel . 1)) - ((declare-statement . 5847)) - ((declare-statement . 5847)) - ((declare-statement . 5847)) - ((declare-statement . 5847)) + ((declare-statement . 5805)) + ((declare-statement . 5805)) + ((declare-statement . 5805)) + ((declare-statement . 5805)) (((block-start begin) - . 5847) - (declare-statement . 5847)) + . 5805) + (declare-statement . 5805)) (((in-begin-block toplevel-block "") - . 5975)) + . 5933)) (((in-begin-block toplevel-block "") - . 5975)) + . 5933)) (((in-begin-block toplevel-block "") - . 5975)) + . 5933)) (((in-begin-block toplevel-block "") - . 5975)) + . 5933)) (((in-begin-block toplevel-block "") - . 5975)) + . 5933)) (((in-block if "") - . 6114)) + . 6072)) (((in-block if "") - . 6114)) + . 6072)) (((block-start elsif) - . 6114) + . 6072) ((in-block if "") - . 6114)) + . 6072)) (((in-block elsif "") - . 6196)) + . 6154)) (((in-block elsif "") - . 6196)) + . 6154)) (((block-start elsif) - . 6196) + . 6154) ((in-block elsif "") - . 6196)) + . 6154)) (((in-block elsif "") - . 6284)) + . 6242)) (((in-block elsif "") - . 6284)) + . 6242)) (((block-start else) - . 6284) + . 6242) ((in-block elsif "") - . 6284)) + . 6242)) (((in-block else "") - . 6369)) - ((nested-statement-continuation . 6410) - (statement-continuation . 6410)) - ((nested-statement-continuation . 6410) - (statement-continuation . 6410)) - ((nested-statement-continuation . 6410) - (statement-continuation . 6410)) - ((nested-statement-continuation . 6410) - (statement-continuation . 6410)) + . 6327)) + ((nested-statement-continuation . 6368) + (statement-continuation . 6368)) + ((nested-statement-continuation . 6368) + (statement-continuation . 6368)) + ((nested-statement-continuation . 6368) + (statement-continuation . 6368)) + ((nested-statement-continuation . 6368) + (statement-continuation . 6368)) (((in-block else "") - . 6369)) + . 6327)) (((block-end if "") - . 6114) + . 6072) ((in-block else "") - . 6369)) + . 6327)) (((block-end toplevel-block "") - . 5975) + . 5933) ((in-begin-block toplevel-block "") - . 5975)) + . 5933)) (((block-end toplevel nil) - . 5841) + . 5799) ((in-begin-block toplevel nil) - . 5841)) + . 5799)) ((toplevel . 1)) ((toplevel . 1)) (((block-start begin) @@ -540,49 +540,49 @@ (toplevel . 1)) ((toplevel . 1)) (((in-begin-block toplevel nil) - . 6762)) - ((declare-statement . 6770)) + . 6720)) + ((declare-statement . 6728)) (((block-start begin) - . 6770) - (declare-statement . 6770)) + . 6728) + (declare-statement . 6728)) (((in-begin-block toplevel-block "") - . 6804)) + . 6762)) (((in-begin-block toplevel-block "") - . 6804)) + . 6762)) (((in-block if "") - . 6834)) + . 6792)) (((in-block if "") - . 6834)) + . 6792)) (((block-start elsif) - . 6834) + . 6792) ((in-block if "") - . 6834)) + . 6792)) (((in-block elsif "") - . 6941)) + . 6899)) (((in-block elsif "") - . 6941)) + . 6899)) (((in-block elsif "") - . 6941)) + . 6899)) (((block-start else) - . 6941) + . 6899) ((in-block elsif "") - . 6941)) + . 6899)) (((in-block else "") - . 7055)) + . 7013)) (((in-block else "") - . 7055)) + . 7013)) (((block-end if "") - . 6834) + . 6792) ((in-block else "") - . 7055)) + . 7013)) (((block-end toplevel-block "") - . 6804) + . 6762) ((in-begin-block toplevel-block "") - . 6804)) + . 6762)) (((block-end toplevel nil) - . 6762) + . 6720) ((in-begin-block toplevel nil) - . 6762)) + . 6720)) ((toplevel . 1)) ((toplevel . 1))) diff --git a/test-data/pr68-syn.eld b/test-data/pr68-syn.eld index 5167ac3..dacd6d8 100644 --- a/test-data/pr68-syn.eld +++ b/test-data/pr68-syn.eld @@ -1,18 +1,19 @@ (((toplevel . 1)) ((select-clause . 1) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((nested-statement-open . 34) - (statement-continuation . 34)) - ((nested-statement-continuation . 34) - (statement-continuation . 34)) - ((select-join-condition . 61) - (nested-statement-continuation . 34) - (statement-continuation . 34)) - ((nested-statement-close . 34) - (statement-continuation . 34)) - ((select-join-condition . 29) + ((nested-statement-open . 32) + (statement-continuation . 32)) + ((nested-statement-continuation . 32) + (statement-continuation . 32)) + ((select-join-condition . 55) + (nested-statement-continuation . 32) + (statement-continuation . 32)) + ((nested-statement-close . 32) + (statement-continuation . 32)) + ((select-join-condition . 27) (statement-continuation . 1)) ((toplevel . 1)) - ((toplevel . 1))) \ No newline at end of file + ((toplevel . 1))) + \ No newline at end of file diff --git a/test-data/pr70-syn.eld b/test-data/pr70-syn.eld index 8b0612f..4c9ec1c 100644 --- a/test-data/pr70-syn.eld +++ b/test-data/pr70-syn.eld @@ -3,76 +3,78 @@ (statement-continuation . 1)) ((select-clause . 1) (statement-continuation . 1)) - ((select-table-continuation . 14) + ((select-table . 14) (statement-continuation . 1)) - ((select-table-continuation . 14) + ((select-table . 14) (statement-continuation . 1)) - ((select-join-condition . 34) + ((select-join-condition . 30) (statement-continuation . 1)) - ((select-join-condition . 34) + ((select-join-condition . 30) (statement-continuation . 1)) ((comment-start . 1) (statement-continuation . 1)) - ((select-table-continuation . 14) + ((select-table . 14) (statement-continuation . 1)) - ((nested-statement-open . 132) - (statement-continuation . 132)) - ((nested-statement-continuation . 132) - (statement-continuation . 132)) - ((select-join-condition . 153) - (nested-statement-continuation . 132) - (statement-continuation . 132)) - ((select-join-condition . 153) - (nested-statement-continuation . 132) - (statement-continuation . 132)) - ((nested-statement-close . 132) - (statement-continuation . 132)) - ((select-join-condition . 127) + ((nested-statement-open . 122) + (statement-continuation . 122)) + ((nested-statement-continuation . 122) + (statement-continuation . 122)) + ((select-join-condition . 139) + (nested-statement-continuation . 122) + (statement-continuation . 122)) + ((select-join-condition . 139) + (nested-statement-continuation . 122) + (statement-continuation . 122)) + ((nested-statement-close . 122) + (statement-continuation . 122)) + ((select-join-condition . 117) (statement-continuation . 1)) - ((select-join-condition . 127) + ((select-join-condition . 117) (statement-continuation . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((select-column . 389) - (statement-continuation . 389)) - ((select-clause . 389) - (statement-continuation . 389)) - ((select-table-continuation . 402) - (statement-continuation . 389)) - ((select-table-continuation . 402) - (statement-continuation . 389)) - ((select-join-condition . 422) - (statement-continuation . 389)) - ((nested-statement-continuation . 443) - (statement-continuation . 443)) - ((comment-start . 389) - (statement-continuation . 389)) - ((select-table-continuation . 402) - (statement-continuation . 389)) - ((nested-statement-open . 606) - (statement-continuation . 606)) - ((nested-statement-continuation . 606) - (statement-continuation . 606)) - ((select-join-condition . 627) - (nested-statement-continuation . 606) - (statement-continuation . 606)) - ((nested-statement-continuation . 655) - (statement-continuation . 655)) - ((nested-statement-close . 606) - (statement-continuation . 606)) - ((select-join-condition . 601) - (statement-continuation . 389)) - ((nested-statement-continuation . 771) - (statement-continuation . 771)) + ((select-column . 365) + (statement-continuation . 365)) + ((select-clause . 365) + (statement-continuation . 365)) + ((select-table . 378) + (statement-continuation . 365)) + ((select-table . 378) + (statement-continuation . 365)) + ((select-join-condition . 394) + (statement-continuation . 365)) + ((nested-statement-continuation . 413) + (statement-continuation . 413)) + ((comment-start . 365) + (statement-continuation . 365)) + ((select-table . 378) + (statement-continuation . 365)) + ((nested-statement-open . 570) + (statement-continuation . 570)) + ((nested-statement-continuation . 570) + (statement-continuation . 570)) + ((select-join-condition . 587) + (nested-statement-continuation . 570) + (statement-continuation . 570)) + ((nested-statement-continuation . 613) + (statement-continuation . 613)) + ((nested-statement-close . 570) + (statement-continuation . 570)) + ((select-join-condition . 565) + (statement-continuation . 365)) + ((nested-statement-continuation . 723) + (statement-continuation . 723)) ((toplevel . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((nested-statement-continuation . 874) - (statement-continuation . 874)) - ((select-join-condition . 885) - (nested-statement-continuation . 874) - (statement-continuation . 874)) - ((select-clause . 867) - (statement-continuation . 867)) + ((nested-statement-continuation . 824) + (statement-continuation . 824)) + ((select-join-condition . 835) + (nested-statement-continuation . 824) + (statement-continuation . 824)) + ((select-clause . 817) + (statement-continuation . 817)) ((toplevel . 1))) + + \ No newline at end of file diff --git a/test-data/pr73-syn.eld b/test-data/pr73-syn.eld index 330bff7..75419b7 100644 --- a/test-data/pr73-syn.eld +++ b/test-data/pr73-syn.eld @@ -1,58 +1,58 @@ (((toplevel . 1)) ((select-clause . 1) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 30) + ((select-join-condition . 28) (statement-continuation . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 76) - (statement-continuation . 76)) - ((select-clause . 76) - (statement-continuation . 76)) - ((select-clause . 76) - (statement-continuation . 76)) - ((select-clause . 76) - (statement-continuation . 76)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 127) - (statement-continuation . 127)) - ((select-clause . 127) - (statement-continuation . 127)) - ((select-clause . 127) - (statement-continuation . 127)) - ((select-clause . 127) - (statement-continuation . 127)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 178) - (statement-continuation . 178)) - ((select-clause . 178) - (statement-continuation . 178)) - ((select-clause . 178) - (statement-continuation . 178)) - ((select-clause . 178) - (statement-continuation . 178)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 233) - (statement-continuation . 233)) - ((select-clause . 233) - (statement-continuation . 233)) - ((select-clause . 233) - (statement-continuation . 233)) - ((select-clause . 233) - (statement-continuation . 233)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 284) - (statement-continuation . 284)) - ((select-clause . 284) - (statement-continuation . 284)) - ((select-clause . 284) - (statement-continuation . 284)) - ((select-clause . 284) - (statement-continuation . 284)) + ((select-clause . 72) + (statement-continuation . 72)) + ((select-clause . 72) + (statement-continuation . 72)) + ((select-clause . 72) + (statement-continuation . 72)) + ((select-clause . 72) + (statement-continuation . 72)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 123) + (statement-continuation . 123)) + ((select-clause . 123) + (statement-continuation . 123)) + ((select-clause . 123) + (statement-continuation . 123)) + ((select-clause . 123) + (statement-continuation . 123)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 174) + (statement-continuation . 174)) + ((select-clause . 174) + (statement-continuation . 174)) + ((select-clause . 174) + (statement-continuation . 174)) + ((select-clause . 174) + (statement-continuation . 174)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 229) + (statement-continuation . 229)) + ((select-clause . 229) + (statement-continuation . 229)) + ((select-clause . 229) + (statement-continuation . 229)) + ((select-clause . 229) + (statement-continuation . 229)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 280) + (statement-continuation . 280)) + ((select-clause . 280) + (statement-continuation . 280)) + ((select-clause . 280) + (statement-continuation . 280)) + ((select-clause . 280) + (statement-continuation . 280)) ((toplevel . 1))) \ No newline at end of file diff --git a/test-data/pr75-oracle-syn.eld b/test-data/pr75-oracle-syn.eld index 1b1851e..35af409 100644 --- a/test-data/pr75-oracle-syn.eld +++ b/test-data/pr75-oracle-syn.eld @@ -19,26 +19,26 @@ ((select-clause . 233) ((create-statement view "myview") . 196)) - ((select-table-continuation . 329) + ((select-table . 329) ((create-statement view "myview") . 196)) ((toplevel . 1)) ((toplevel . 1)) (((create-statement table "foo") - . 403)) + . 401)) (((create-statement table "foo") - . 403)) + . 401)) (((create-statement table "foo") - . 403)) - ((select-column . 525) + . 401)) + ((select-column . 523) ((create-statement table "foo") - . 403)) - ((select-clause . 525) + . 401)) + ((select-clause . 523) ((create-statement table "foo") - . 403)) - ((select-table-continuation . 621) + . 401)) + ((select-table . 619) ((create-statement table "foo") - . 403)) + . 401)) ((toplevel . 1)) ((comment-start . 1) (toplevel . 1)) diff --git a/test-data/pr75-postgres-syn.eld b/test-data/pr75-postgres-syn.eld index d874f20..811fb69 100644 --- a/test-data/pr75-postgres-syn.eld +++ b/test-data/pr75-postgres-syn.eld @@ -9,50 +9,50 @@ ((select-clause . 52) ((create-statement table "mytable") . 1)) - ((select-table-continuation . 148) + ((select-table . 148) ((create-statement table "mytable") . 1)) ((toplevel . 1)) ((toplevel . 1)) (((create-statement table "mytable") - . 222)) - ((select-column . 273) + . 220)) + ((select-column . 271) ((create-statement table "mytable") - . 222)) - ((select-clause . 273) + . 220)) + ((select-clause . 271) ((create-statement table "mytable") - . 222)) - ((select-table-continuation . 369) + . 220)) + ((select-table . 367) ((create-statement table "mytable") - . 222)) + . 220)) ((toplevel . 1)) ((toplevel . 1)) (((create-statement view "myview") - . 443)) - ((select-column . 480) + . 439)) + ((select-column . 476) ((create-statement view "myview") - . 443)) - ((select-clause . 480) + . 439)) + ((select-clause . 476) ((create-statement view "myview") - . 443)) - ((select-table-continuation . 576) + . 439)) + ((select-table . 572) ((create-statement view "myview") - . 443)) + . 439)) ((toplevel . 1)) ((toplevel . 1)) (((create-statement table "foo") - . 650)) + . 644)) (((create-statement table "foo") - . 650)) - ((select-column . 698) + . 644)) + ((select-column . 692) ((create-statement table "foo") - . 650)) - ((select-clause . 698) + . 644)) + ((select-clause . 692) ((create-statement table "foo") - . 650)) - ((select-table-continuation . 794) + . 644)) + ((select-table . 788) ((create-statement table "foo") - . 650)) + . 644)) ((toplevel . 1)) ((comment-start . 1) (toplevel . 1)) diff --git a/test-data/pr85-syn.eld b/test-data/pr85-syn.eld index 7710e7d..6396890 100644 --- a/test-data/pr85-syn.eld +++ b/test-data/pr85-syn.eld @@ -1,57 +1,57 @@ (((toplevel . 1)) ((select-clause . 1) (statement-continuation . 1)) - ((select-table-continuation . 12) + ((select-table . 12) (statement-continuation . 1)) - ((select-join-condition . 30) + ((select-join-condition . 28) (statement-continuation . 1)) ((toplevel . 1)) ((toplevel . 1)) - ((select-clause . 82) - (statement-continuation . 82)) - ((select-table-continuation . 93) - (statement-continuation . 82)) - ((select-table-continuation . 93) - (statement-continuation . 82)) - ((select-join-condition . 111) - (statement-continuation . 82)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 172) - (statement-continuation . 172)) - ((select-table-continuation . 183) - (statement-continuation . 172)) - ((select-table-continuation . 183) - (statement-continuation . 172)) - ((select-join-condition . 201) - (statement-continuation . 172)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 290) - (statement-continuation . 290)) - ((select-table-continuation . 301) - (statement-continuation . 290)) - ((select-join-condition . 319) - (statement-continuation . 290)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 372) - (statement-continuation . 372)) - ((select-table-continuation . 383) - (statement-continuation . 372)) - ((select-table-continuation . 383) - (statement-continuation . 372)) - ((select-join-condition . 401) - (statement-continuation . 372)) - ((toplevel . 1)) - ((toplevel . 1)) - ((select-clause . 496) - (statement-continuation . 496)) - ((select-table-continuation . 507) - (statement-continuation . 496)) - ((select-table-continuation . 507) - (statement-continuation . 496)) - ((select-join-condition . 525) - (statement-continuation . 496)) + ((select-clause . 78) + (statement-continuation . 78)) + ((select-table . 89) + (statement-continuation . 78)) + ((select-table . 89) + (statement-continuation . 78)) + ((select-join-condition . 105) + (statement-continuation . 78)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 162) + (statement-continuation . 162)) + ((select-table . 173) + (statement-continuation . 162)) + ((select-table . 173) + (statement-continuation . 162)) + ((select-join-condition . 189) + (statement-continuation . 162)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 274) + (statement-continuation . 274)) + ((select-table . 285) + (statement-continuation . 274)) + ((select-join-condition . 301) + (statement-continuation . 274)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 352) + (statement-continuation . 352)) + ((select-table . 363) + (statement-continuation . 352)) + ((select-table . 363) + (statement-continuation . 352)) + ((select-join-condition . 379) + (statement-continuation . 352)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-clause . 470) + (statement-continuation . 470)) + ((select-table . 481) + (statement-continuation . 470)) + ((select-table . 481) + (statement-continuation . 470)) + ((select-join-condition . 497) + (statement-continuation . 470)) ((toplevel . 1))) \ No newline at end of file diff --git a/test-data/pr99-syn.eld b/test-data/pr99-syn.eld new file mode 100644 index 0000000..979192a --- /dev/null +++ b/test-data/pr99-syn.eld @@ -0,0 +1,150 @@ +(((comment-start . 1) + (toplevel . 1)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-column . 73) + (statement-continuation . 73)) + ((select-clause . 73) + (statement-continuation . 73)) + ((comment-start . 103) + (nested-statement-open . 103) + (statement-continuation . 103)) + ((comment-start . 103) + (nested-statement-continuation . 103) + (statement-continuation . 103)) + ((nested-statement-continuation . 103) + (statement-continuation . 103)) + ((select-column . 177) + (nested-statement-continuation . 103) + (statement-continuation . 103)) + ((select-column . 177) + (nested-statement-continuation . 103) + (statement-continuation . 103)) + ((select-clause . 177) + (nested-statement-continuation . 103) + (statement-continuation . 103)) + ((nested-statement-continuation . 271) + (statement-continuation . 271)) + ((nested-statement-continuation . 271) + (statement-continuation . 271)) + ((select-table-continuation . 256) + (nested-statement-continuation . 103) + (statement-continuation . 103)) + ((select-table-continuation . 103) + (statement-continuation . 73)) + ((select-table . 98) + (statement-continuation . 73)) + ((comment-start . 472) + (nested-statement-open . 472) + (statement-continuation . 472)) + ((nested-statement-continuation . 472) + (statement-continuation . 472)) + ((select-clause . 526) + (nested-statement-continuation . 472) + (statement-continuation . 472)) + ((nested-statement-open . 551) + (statement-continuation . 551)) + ((nested-statement-continuation . 551) + (statement-continuation . 551)) + ((nested-statement-continuation . 551) + (statement-continuation . 551)) + ((nested-statement-continuation . 551) + (statement-continuation . 551)) + ((select-table-continuation . 551) + (nested-statement-continuation . 472) + (statement-continuation . 472)) + ((select-table-continuation . 472) + (statement-continuation . 73)) + ((select-join-condition . 462) + (statement-continuation . 73)) + ((select-table . 98) + (statement-continuation . 73)) + ((nested-statement-open . 973) + (statement-continuation . 973)) + ((comment-start . 973) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((select-column . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((case-clause-item-cont . 1127) + (select-column-continuation . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + (((block-end case "") + . 1089) + (select-column-continuation . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((select-column . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((select-column . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((select-column . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((select-column . 984) + (nested-statement-continuation . 973) + (statement-continuation . 973)) + ((select-table-continuation . 973) + (statement-continuation . 73)) + ((select-table . 98) + (statement-continuation . 73)) + ((comment-start . 1649) + (nested-statement-open . 1649) + (statement-continuation . 1649)) + ((nested-statement-continuation . 1649) + (statement-continuation . 1649)) + ((select-column . 1716) + (nested-statement-continuation . 1649) + (statement-continuation . 1649)) + ((nested-statement-open . 1742) + (statement-continuation . 1742)) + ((nested-statement-continuation . 1742) + (statement-continuation . 1742)) + ((nested-statement-close . 1742) + (statement-continuation . 1742)) + ((select-column-continuation . 1716) + (nested-statement-continuation . 1649) + (statement-continuation . 1649)) + ((nested-statement-close . 1649) + (statement-continuation . 1649)) + ((toplevel . 1)) + ((comment-start . 1) + (toplevel . 1)) + ((comment-start . 1) + (toplevel . 1)) + ((comment-start . 1) + (toplevel . 1)) + ((toplevel . 1)) + ((toplevel . 1)) + ((select-column . 2025) + (statement-continuation . 2025)) + ((select-column . 2025) + (statement-continuation . 2025)) + ((select-column . 2025) + (statement-continuation . 2025)) + ((select-column . 2025) + (statement-continuation . 2025)) + ((select-column . 2025) + (statement-continuation . 2025)) + ((select-clause . 2025) + (statement-continuation . 2025)) + ((select-table . 2227) + (statement-continuation . 2025)) + ((select-table . 2227) + (statement-continuation . 2025)) + ((select-table . 2227) + (statement-continuation . 2025)) + ((select-table-continuation . 2311) + (statement-continuation . 2025)) + ((select-clause . 2025) + (statement-continuation . 2025)) + (((in-select-clause "where") + . 2501) + (statement-continuation . 2025)) + (((in-select-clause "where") + . 2501) + (statement-continuation . 2025))) \ No newline at end of file diff --git a/test-data/pr99.sql b/test-data/pr99.sql new file mode 100644 index 0000000..2629011 --- /dev/null +++ b/test-data/pr99.sql @@ -0,0 +1,64 @@ +-- SQL from https://ddrscott.github.io/blog/2017/what-the-sql-lateral/ + +SELECT + t2.up_seconds + from ( + -- build virtual table of all hours between + -- a date range + SELECT + start_ts, + start_ts + interval '1 hour' AS end_ts + FROM generate_series('2017-03-01'::date, + '2017-03-03'::timestamp - interval '1 hour', + interval '1 hour') + AS t(start_ts)) + AS cal + LEFT JOIN ( + -- build virtual table of uptimes + SELECT * + FROM ( + VALUES + ('2017-03-01 01:15:00-06'::timestamp, '2017-03-01 02:15:00-06'::timestamp), + ('2017-03-01 08:00:00-06', '2017-03-01 20:00:00-06'), + ('2017-03-02 19:00:00-06', null)) + AS t(start_ts, end_ts)) + AS uptime + ON cal.end_ts > uptime.start_ts AND cal.start_ts <= coalesce(uptime.end_ts, current_timestamp) + JOIN LATERAL ( + SELECT + -- will use `first_ts` and `last_ts` to calculate uptime duration + CASE WHEN uptime.start_ts IS NOT NULL THEN + greatest(uptime.start_ts, cal.start_ts) + END AS first_ts, + least(cal.end_ts, uptime.end_ts) AS last_ts, + date_trunc('day', cal.start_ts)::date AS cal_date, + extract(hour from cal.start_ts) AS cal_hour, + extract(epoch from age(cal.end_ts, cal.start_ts)) AS cal_seconds) + as t1 ON true + JOIN LATERAL ( + -- calculate uptime seconds for the time slice + SELECT + coalesce( + extract(epoch FROM age(last_ts, first_ts)), + 0 + ) + AS up_seconds + ) t2 ON true; + +-- SQL from https://github.com/alex-hhh/emacs-sql-indent/issues/99#issuecomment-833821835 +-- +-- newline after JOIN LATERAL is correctly detected. + +SELECT reports.diagnostic_report_version_id, + image_descriptors.order, + image_descriptors.descriptor, + files.file_name as name, + files.file_id as id, + files.content_type + FROM diagnostic_report_versions as reports, + files + JOIN LATERAL + jsonb_to_recordset(jsonb_path_query_array(reports.tree, 'strict $.children.report.children.images.children.*')) + AS image_descriptors("name" text, "order" text, "descriptor" jsonb) + WHERE reports.diagnostic_report_version_id = files.diagnostic_report_version_id + AND files.file_id = image_descriptors.NAME