Skip to content

Commit 0066a3a

Browse files
authored
Merge pull request #601 from LPCIC/attlabel
attlabel
2 parents 475ac11 + 8eaf7ef commit 0066a3a

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## UNRELEASED
44

55
### API
6+
- New `coq.parse-attributes` support for the `attlabel` specification,
7+
see `coq-lib-common.elpi` for its documentation.
68
- New `coq.goal->pp`
79

810
## [2.0.2] - 01/02/2024

elpi/coq-lib-common.elpi

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ type int attribute-type.
6767
type string attribute-type.
6868
type bool attribute-type.
6969
type oneof list attribute-mapping -> attribute-type.
70-
type attmap attribute-type.
71-
type attlist attribute-type.
70+
type attmap attribute-type. % #[map(k1="v1",k2="v2")]
71+
type attlist attribute-type. % #[set(b1,b2,b3)]
72+
type attlabel attribute-type. % #[label( a(..), b, .. )] if #[label(a, b), a(..), ..]
7273
type loc attribute-type.
7374

7475
kind attribute-mapping type.
@@ -123,6 +124,9 @@ pred append-string i:string, i:string, o:string.
123124
append-string "" A A :- !.
124125
append-string A B R :- R is A ^ "." ^ B.
125126

127+
pred keep-only-label i:attribute, o:attribute.
128+
keep-only-label (attribute L _) (attribute L (leaf-str "")).
129+
126130
coq.parse-attributes L S O :-
127131
std.map S (x\r\ r = supported-attribute x) CS,
128132
CS => parse-attributes.aux L "" O, !.
@@ -137,6 +141,13 @@ parse-attributes.aux [attribute S (node L)|AS] Prefix R :-
137141
parse-attributes.aux AS Prefix R1,
138142
(pi x\ supported-attribute (att x string) :- !) => parse-attributes.aux L "" Map,
139143
std.append R1 [get-option PS Map] R.
144+
parse-attributes.aux [attribute S (node L)|AS] Prefix R :-
145+
append-string Prefix S PS, supported-attribute (att PS attlabel), !,
146+
parse-attributes.aux AS Prefix R1,
147+
std.map L keep-only-label Ll,
148+
(pi x\ supported-attribute (att x bool) :- !) => parse-attributes.aux Ll "" Map,
149+
parse-attributes.aux L Prefix R2,
150+
std.append R1 [get-option PS Map|R2] R.
140151
parse-attributes.aux [attribute S (node L)|AS] Prefix R :- !,
141152
parse-attributes.aux AS Prefix R1,
142153
append-string Prefix S PS,

tests/test_vernacular1.v

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,27 @@ Elpi Accumulate lp:{{
7272
}}.
7373
Elpi test.scope (_ * _)%type.
7474
Fail Elpi test.scope ((_ * _)%type).
75+
76+
Elpi Command test_attlabel.
77+
Elpi Accumulate lp:{{
78+
main _ :-
79+
attributes A,
80+
coq.parse-attributes A [
81+
att "only" attlabel,
82+
att "foo.x" string,
83+
att "foo.y" bool,
84+
] CL,
85+
CL = [get-option "elpi.loc" _, get-option "elpi.phase" _,
86+
get-option "only" [get-option "foo" tt],
87+
get-option "foo.x" "a",
88+
get-option "foo.y" ff].
89+
}}.
90+
Elpi Typecheck.
91+
Elpi Export test_attlabel.
92+
93+
#[only(foo(x="a",y=no))] test_attlabel.
94+
95+
96+
97+
98+

0 commit comments

Comments
 (0)