@@ -3,18 +3,19 @@ open Sgen_ast
33% }
44
55% token SHOW SHOWEXEC
6- % token EXEC
76% token INTERFACE
7+ % token USE
88% token RUN
99% token SPEC
1010% token TRACE
1111% token SHARP
12- % token LINEXEC
12+ % token EXEC LINEXEC
1313% token PROCESS
1414% token GALAXY
1515% token RARROW DRARROW
1616% token EQ
1717% token END
18+ % token PROOF LEMMA THEOREM
1819
1920% start < Sgen_ast. program> program
2021
@@ -25,27 +26,31 @@ let program :=
2526 | EOL * ; d= declaration; EOL + ; p= program; { d ::p }
2627 | EOL * ; d= declaration; EOF ; { [d] }
2728
28- let ident :=
29- | ~= ray; <>
29+ let ident := ~= ray; <>
3030
3131let declaration :=
32- | SPEC ; ~= ident; EOL * ; EQ ; EOL * ;
33- ~= galaxy_expr; < Def >
34- | ~= ident; EOL * ; EQ ; EOL * ;
35- ~= galaxy_expr; < Def >
36- | INTERFACE ; EOL * ; x= ident; EOL * ;
37- i= interface_item* ;
38- END ; INTERFACE ?; { Def (x, Raw (Interface i)) }
39- | SHOW ; EOL * ; ~= galaxy_expr; < Show >
40- | SHOWEXEC ; EOL * ; ~= galaxy_expr; < ShowExec >
41- | TRACE ; EOL * ; ~= galaxy_expr; < Trace >
42- | RUN ; EOL * ; ~= galaxy_expr; < Run >
43- | ~= type_declaration; < TypeDef >
32+ | SPEC ; ~= ident; EOL * ; EQ ; EOL * ; ~= galaxy_expr; < Def >
33+ | ~= ident; EOL * ; EQ ; EOL * ; ~= galaxy_expr; < Def >
34+ | SHOW ; EOL * ; ~= galaxy_expr; < Show >
35+ | SHOWEXEC ; EOL * ; ~= galaxy_expr; < ShowExec >
36+ | TRACE ; EOL * ; ~= galaxy_expr; < Trace >
37+ | RUN ; EOL * ; ~= galaxy_expr; < Run >
38+ | ~= type_declaration; < TypeDef >
39+ | USE ; ~= separated_list(RARROW , ident); DOT ; < Use >
40+ | proof_spec; x= ident; CONS ; ts= separated_list(COMMA , ident);
41+ EOL * ; ck= bracks(ident)?; EOL * ; EQ ; EOL * ; g= galaxy_expr;
42+ { ProofDef (x, ts, ck, g) }
43+ | INTERFACE ; EOL * ; x= ident; EOL * ; i= interface_item* ; END ; INTERFACE ?;
44+ { Def (x, Raw (Interface i)) }
45+
46+ let proof_spec :=
47+ | THEOREM ; EOL * ; <>
48+ | LEMMA ; EOL * ; <>
4449
4550let type_declaration :=
4651 | x= ident; CONS ; CONS ; ts= separated_list(COMMA , ident);
47- EOL * ; ck= bracks(ident)?; EOL * ; DOT ; { TDef (x, ts, ck) }
48- | x= ident; CONS ; EQ ; CONS ; EOL * ; g= galaxy_expr; { TExp (x, g) }
52+ EOL * ; ck= bracks(ident)?; EOL * ; DOT ; { TDef (x, ts, ck) }
53+ | x= ident; CONS ; EQ ; CONS ; EOL * ; g= galaxy_expr; { TExp (x, g) }
4954
5055let galaxy_expr :=
5156 | ~= galaxy_content; EOL * ; DOT ; <>
@@ -60,26 +65,30 @@ let undelimited_raw_galaxy :=
6065 | GALAXY ; EOL * ; ~= galaxy_item* ; EOL * ; END ; GALAXY ?; < Galaxy >
6166
6267let delimited_raw_galaxy :=
63- | ~= pars(marked_constellation); < Const >
6468 | braces(EOL * ); { Const [] }
69+ | ~= pars(marked_constellation); < Const >
6570 | ~= braces(marked_constellation); < Const >
6671
72+ let prefixed_id := SHARP ; ~= ident; < Id >
73+
74+ let naked_id := ~= ident; < Id >
75+
6776let galaxy_content :=
68- | ~= pars(galaxy_content); <>
69- | SHARP ; ~= ident ; < Id >
70- | ~= delimited_raw_galaxy; < Raw >
71- | g = galaxy_content; h = galaxy_content; { Union (g, h) }
72- | ~= galaxy_access ; < >
73- | AT ; ~= focussed_galaxy_content ; < Focus >
74- | ~= galaxy_content; ~= bracks(substitution); < Subst >
75- | ~= galaxy_block; <>
77+ | ~= pars(galaxy_content); <>
78+ | ~= delimited_raw_galaxy ; < Raw >
79+ | g = galaxy_content; h = galaxy_content; { Union (g, h) }
80+ | ~= galaxy_access; <>
81+ | AT ; ~= focussed_galaxy_content ; < Focus >
82+ | ~= galaxy_content ; ~= bracks(substitution) ; < Subst >
83+ | ~= galaxy_block; < >
84+ | ~= prefixed_id; <>
7685
7786let focussed_galaxy_content :=
78- | ~= pars(galaxy_content); <>
79- | ~= galaxy_access; <>
80- | SHARP ; ~= ident ; < Id >
81- | ~= delimited_raw_galaxy; < Raw >
82- | ~= galaxy_block; <>
87+ | ~= pars(galaxy_content); <>
88+ | ~= galaxy_access; <>
89+ | ~= delimited_raw_galaxy ; < Raw >
90+ | ~= galaxy_block; < >
91+ | ~= prefixed_id; <>
8392
8493let galaxy_block :=
8594 | EXEC ; EOL * ; ~= galaxy_content; EOL * ; END ; EXEC ?;
@@ -105,20 +114,25 @@ let substitution :=
105114 h= marked_constellation; { SGal (x, Raw (Const h)) }
106115
107116let galaxy_item :=
108- | ~= ident; EQ ; EOL * ; ~= galaxy_content; DOT ; EOL * ; < GLabelDef >
117+ | ~= ident; EQ ; EOL * ; ~= galaxy_content; DOT ; EOL * ;
118+ < GLabelDef >
109119 | x= ident; EQ ; EOL * ; mcs= marked_constellation; EOL * ; DOT ; EOL * ;
110120 { GLabelDef (x, Raw (Const mcs)) }
111121 | x= ident; EQ ; EOL * ; g= undelimited_raw_galaxy; EOL * ; DOT ; EOL * ;
112122 { GLabelDef (x, Raw g) }
113- | ~= ident; EQ ; EOL * ; ~= process; EOL * ; < GLabelDef >
114- | ~= type_declaration; EOL * ; < GTypeDef >
123+ | ~= ident; EQ ; EOL * ; ~= process; EOL * ; < GLabelDef >
124+ | ~= type_declaration; EOL * ; < GTypeDef >
115125
116126let process :=
117- | PROCESS ; EOL * ; END ; PROCESS ?;
118- { Process [] }
119- | PROCESS ; EOL * ; ~= process_item+ ; END ; PROCESS ?;
120- < Process >
127+ | PROCESS ; EOL * ; END ; PROCESS ?; { Process [] }
128+ | PROOF ; EOL * ; END ; PROOF ?; { Process [] }
129+ | PROCESS ; EOL * ; ~= process_item+ ; END ; PROCESS ?; < Process >
130+ | PROOF ; EOL * ; ~= proof_content + ; END ; PROOF ?; < Process >
121131
122132let process_item :=
123- | ~= galaxy_content; DOT ; EOL * ; <>
124- | ~= undelimited_raw_galaxy; EOL * ; < Raw >
133+ | ~= galaxy_content; DOT ; EOL * ; <>
134+ | ~= undelimited_raw_galaxy; EOL * ; < Raw >
135+
136+ let proof_content :=
137+ | ~= delimited_raw_galaxy; DOT ; EOL * ; < Raw >
138+ | ~= naked_id; DOT ; EOL * ; <>
0 commit comments