Skip to content

Commit

Permalink
feat: relax order of configuration paragraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoKaios committed Jul 26, 2024
1 parent bdc4016 commit 56cb047
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 63 deletions.
33 changes: 28 additions & 5 deletions src/lsp/cobol_parser/grammar.mly
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,36 @@ let environment_division :=

(* ------------- ENVIRONMENT DIVISION / CONFIGURATION SECTION -------------- *)

let unorder2_opt [@default (None, None)] (A, B) :=
| a = A; b = ro(B); { (Some a, b) }
| b = B; a = ro(A); { (a, Some b) }
| { (None, None) }

let unorder3_opt [@default (None, None, None)](A, B, C) :=
| a = A; u2 = unorder2_opt(B, C); { (Some a, fst u2, snd u2) }
| b = B; u2 = unorder2_opt(A, C); { (fst u2, Some b, snd u2) }
| c = C; u2 = unorder2_opt(A, B); { (fst u2, snd u2, Some c) }
| { (None, None, None) }

let unorder4_opt [@default (None, None, None, None)] (A, B, C, D) :=
| a = A; u3 = unorder3_opt(B, C, D); { let (b,c,d) = u3 in (Some a, b, c, d) }
| b = B; u3 = unorder3_opt(A, C, D); { let (a,c,d) = u3 in (a, Some b, c, d) }
| c = C; u3 = unorder3_opt(A, B, D); { let (a,b,d) = u3 in (a, b, Some c, d) }
| d = D; u3 = unorder3_opt(A, B, C); { let (a,b,c) = u3 in (a, b, c, Some d) }
| { (None, None, None, None) }

let configuration_section :=
| CONFIGURATION; SECTION; ".";
source_computer_paragraph = ro(loc(source_computer_paragraph));
object_computer_paragraph = ro(loc(object_computer_paragraph));
special_names_paragraph = ro(loc(special_names_paragraph));
repository_paragraph = ro(loc(repository_paragraph)); (* +COB2002 *)
{ { source_computer_paragraph;
unordered = unorder4_opt(
loc(source_computer_paragraph),
loc(object_computer_paragraph),
loc(special_names_paragraph),
loc(repository_paragraph)); (* +COB2002 *)
{ let (source_computer_paragraph,
object_computer_paragraph,
special_names_paragraph,
repository_paragraph) = unordered in
{ source_computer_paragraph;
object_computer_paragraph;
special_names_paragraph;
repository_paragraph } }
Expand Down
10 changes: 0 additions & 10 deletions test/output-tests/run_fundamental.expected
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,6 @@ run_fundamental.at-1390-prog.cob:18.11-18.17:
20 END FUNCTION f2.
>> Warning: Invalid syntax

run_fundamental.at-1390-prog.cob:29.7-29.20:
26 REPOSITORY.
27 FUNCTION f1
28 FUNCTION f2.
29 > SPECIAL-NAMES.
---- ^^^^^^^^^^^^^
30 CURRENCY SIGN IS "Y"
31 DECIMAL-POINT IS COMMA.
>> Error: Invalid syntax

run_fundamental.at-1390-prog.cob:45.19-45.20:
42 77 curr PIC 9.9999,99Y.
43
Expand Down
48 changes: 0 additions & 48 deletions test/output-tests/syn_misc.expected
Original file line number Diff line number Diff line change
Expand Up @@ -1494,55 +1494,7 @@ syn_misc.at-2876-prog.cob:6.11-6.17:
Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:2910:0
Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:2943:0
Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:2987:0
syn_misc.at-2987-prog.cob:8.7-8.22:
5 ENVIRONMENT DIVISION.
6 CONFIGURATION SECTION.
7 OBJECT-COMPUTER. a.
8 > SOURCE-COMPUTER. b.
---- ^^^^^^^^^^^^^^^
>> Error: Invalid syntax

Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:3048:0
syn_misc.at-3048-prog.cob:8.7-8.22:
5 ENVIRONMENT DIVISION.
6 CONFIGURATION SECTION.
7 REPOSITORY.
8 > SOURCE-COMPUTER. b.
---- ^^^^^^^^^^^^^^^
9 OBJECT-COMPUTER. a.
10 SPECIAL-NAMES.
>> Error: Invalid syntax

syn_misc.at-3048-prog.cob:22.7-22.20:
19 SOURCE-COMPUTER. b.
20 OBJECT-COMPUTER. a.
21 REPOSITORY.
22 > SPECIAL-NAMES.
---- ^^^^^^^^^^^^^
23
24 END PROGRAM prog2.
>> Error: Invalid syntax

syn_misc.at-3048-prog.cob:32.7-32.22:
29 ENVIRONMENT DIVISION.
30 CONFIGURATION SECTION.
31 REPOSITORY.
32 > SOURCE-COMPUTER. b.
---- ^^^^^^^^^^^^^^^
33 OBJECT-COMPUTER. a.
34
>> Error: Invalid syntax

syn_misc.at-3048-prog.cob:43.7-43.20:
40 ENVIRONMENT DIVISION.
41 CONFIGURATION SECTION.
42 REPOSITORY.
43 > SPECIAL-NAMES.
---- ^^^^^^^^^^^^^
44 SOURCE-COMPUTER. b.
45 OBJECT-COMPUTER. a.
>> Error: Invalid syntax

Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:3104:0
Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:3107:0
Considering: import/gnucobol/tests/testsuite.src/syn_misc.at:3109:0
Expand Down

0 comments on commit 56cb047

Please sign in to comment.