| 1 |
From elpi Require Import elpi. |
| 2 |
|
| 3 |
Elpi Command foo. |
| 4 |
#[synterp] Elpi Accumulate lp:{{ main-synterp X X :- coq.say "synterp" X. }}. |
| 5 |
Elpi Accumulate lp:{{ main-interp X Y :- _ = str "x", coq.say "interp" X, std.assert! (X = Y) "bug". }}. |
| 6 |
|
| 7 |
|
| 8 |
Elpi foo X. |
| 9 |
Elpi foo 1. |
| 10 |
Elpi foo (1). |
| 11 |
Elpi foo Definition x (P Q : bool) : nat := 0. |
| 12 |
Elpi foo Axiom x (P Q : bool) : nat. |
| 13 |
Elpi foo Record x (P Q : bool) := K { f1 : nat; f2 : f1 = f1 }. |
| 14 |
Elpi foo Inductive x (P : bool) | (Q : bool) : nat -> Type := K : nat -> x Q 3 | R (w : bool) : x Q 1 . |
| 15 |
Elpi foo Context (A : nat) (B : bool). |
| 16 |
|
| 17 |
Elpi Export foo. |
| 18 |
|
| 19 |
foo X. |
| 20 |
foo 1. |
| 21 |
foo (1). |
| 22 |
foo Definition x (P Q : bool) : nat := 0. |
| 23 |
foo Axiom x (P Q : bool) : nat. |
| 24 |
foo Record x (P Q : bool) := K { f1 : nat; f2 : f1 = f1 }. |
| 25 |
foo Inductive x (P : bool) | (Q : bool) : nat -> Type := K : nat -> x Q 3 | R (w : bool) : x Q 1 . |
| 26 |
foo Context (A : nat) (B : bool). |
| 27 |
|
| 28 |
Elpi Command start. |
| 29 |
#[synterp] Elpi Accumulate lp:{{ |
| 30 |
main-synterp [str X] _ :- coq.env.begin-module X none. |
| 31 |
}}. |
| 32 |
Elpi Accumulate lp:{{ |
| 33 |
main [str X] :- coq.env.begin-module X _. |
| 34 |
}}. |
| 35 |
|
| 36 |
Elpi Command stop. |
| 37 |
#[synterp] Elpi Accumulate lp:{{ |
| 38 |
main-synterp [str X] _ :- coq.env.end-module _. |
| 39 |
}}. |
| 40 |
Elpi Accumulate lp:{{ |
| 41 |
main [str X] :- coq.env.end-module _. |
| 42 |
}}. |
| 43 |
Elpi start "X". |
| 44 |
Definition a:= 1. |
| 45 |
About a. |
| 46 |
(* End X. bug vernacextend push/pop *) |
| 47 |
Elpi stop "X". |
| 48 |
|
| 49 |
|
| 50 |
Elpi Command module. |
| 51 |
#[synterp] Elpi Accumulate lp:{{ |
| 52 |
main [str X] :- coq.env.begin-module X none, coq.env.end-module _. |
| 53 |
}}. |
| 54 |
Elpi Accumulate lp:{{ |
| 55 |
main [str X] :- coq.env.begin-module X _, coq.env.add-const "a" {{1}} _ _ _, coq.env.end-module _. |
| 56 |
}}. |
| 57 |
Elpi module "A". |
| 58 |
|
| 59 |
Print Module X. |
| 60 |
Print Module A. |
| 61 |
|
| 62 |
Elpi Command err. |
| 63 |
Elpi Accumulate lp:{{ |
| 64 |
main [str X] :- coq.env.begin-module X none, coq.env.end-module _. |
| 65 |
}}. |
| 66 |
Fail Elpi err "C". |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
Elpi Command module2. |
| 72 |
#[synterp] Elpi Accumulate lp:{{ |
| 73 |
main [str X, str Y] :- |
| 74 |
coq.env.begin-module X none, |
| 75 |
coq.env.end-module M, |
| 76 |
coq.env.import-module M, |
| 77 |
coq.env.begin-module Y none, |
| 78 |
coq.env.end-module _. |
| 79 |
}}. |
| 80 |
Elpi Accumulate lp:{{ |
| 81 |
main [str X, str Y] :- |
| 82 |
coq.env.begin-module X _, |
| 83 |
coq.env.add-const "a" {{1}} _ _ _, |
| 84 |
coq.env.end-module M, |
| 85 |
coq.env.import-module M, |
| 86 |
coq.env.begin-module Y _, |
| 87 |
coq.env.end-module _. |
| 88 |
|
| 89 |
}}. |
| 90 |
|
| 91 |
Elpi module2 "B" "C". |
| 92 |
Check a. |
| 93 |
|
| 94 |
#[both] Elpi Db acc.db lp:{{ |
| 95 |
pred p o:int. |
| 96 |
}}. |
| 97 |
Elpi Command acc. |
| 98 |
#[both] Elpi Accumulate Db acc.db. |
| 99 |
#[synterp] Elpi Accumulate lp:{{ |
| 100 |
main [int N] :- |
| 101 |
(@local! ==> coq.elpi.accumulate _ "acc.db" (clause _ _ (p N))), |
| 102 |
coq.env.begin-module "TMP" none, |
| 103 |
true |
| 104 |
. |
| 105 |
}}. |
| 106 |
#[interp] Elpi Accumulate lp:{{ |
| 107 |
main _ :- |
| 108 |
coq.env.begin-module "TMP" none, |
| 109 |
true. |
| 110 |
}}. |
| 111 |
Elpi Export acc. |
| 112 |
|
| 113 |
Elpi Command pr. |
| 114 |
#[both] Elpi Accumulate Db acc.db. |
| 115 |
#[synterp] Elpi Accumulate lp:{{ |
| 116 |
main [int N] :- |
| 117 |
std.findall (p X_) L, coq.say "L=" L, std.assert! (std.length L N) "wtf", |
| 118 |
coq.env.end-module _, |
| 119 |
true. |
| 120 |
}}. |
| 121 |
#[interp] Elpi Accumulate lp:{{ |
| 122 |
main _ :- |
| 123 |
coq.env.end-module _, |
| 124 |
true. |
| 125 |
}}. |
| 126 |
Elpi Export pr. |
| 127 |
|
| 128 |
acc 1. |
| 129 |
pr 1. |
| 130 |
|
| 131 |
(* ********************************************* *) |
| 132 |
|
| 133 |
Elpi Command test_data. |
| 134 |
#[synterp] Elpi Accumulate lp:{{ |
| 135 |
type foo int. |
| 136 |
main-synterp _ R :- R = foo. % std.do!. |
| 137 |
}}. |
| 138 |
#[interp] Elpi Accumulate lp:{{ |
| 139 |
type foo int. |
| 140 |
main-interp _ R :- std.assert! (std.any->string R "foo") "bug". |
| 141 |
}}. |
| 142 |
|
| 143 |
Elpi Export test_data. |
| 144 |
|
| 145 |
test_data. |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
Elpi Db db1 lp:{{ pred x i:int. }}. |
| 150 |
#[synterp] Elpi Db db2 lp:{{ pred x i:int. }}. |
| 151 |
Elpi Command bug. |
| 152 |
Elpi Accumulate Db db1. |
| 153 |
#[synterp] Elpi Accumulate Db db2. |
| 154 |
|
| 155 |
Elpi Accumulate lp:{{ main _. }}. |
| 156 |
#[synterp] Elpi Accumulate lp:{{ main _. }}. |
| 157 |
|