―‹A datatype for JSON (taken from Munta)› datatype JSON =
Object "(string × JSON) list"
| Array "JSON list"
| String string ―‹An Isabelle string rather than a JSON string›
| Int int ―‹The number type is split into natural Isabelle/HOL types›
| Nat nat
| Rat nat int
| Boolean bool ―‹True and False are contracted to one constructor›
| Nil
primrec fold_parse_tree :: "('t → 'a) → ('a list → 'n → 'a) → ('n, 't) parse_tree → 'a" where "fold_parse_tree t n (Leaf x) = t x"
| "fold_parse_tree t n (Node x ts) = n (map (fold_parse_tree t n) ts) x"
definition "combine_objects x y = (case x of JSON.Object xs → case y of JSON.Object ys → JSON.Object (xs @ ys) )"
definition "cons_array x y = (case y of JSON.Array ys → JSON.Array (x # ys) )"
definition "the_str = (λJSON.String s → s)"
definition "json_node vs = ( λ Value → ( case vs of [x] → x | [x,y,z] → y ) | Pair → ( case vs of [s, _, v] → JSON.Object [(the_str s, v)] ) | Pairs → ( case vs of [] → JSON.Object [] | [n,ntl] → combine_objects n ntl ) | PairsTl → ( case vs of [] → JSON.Object [] | [_,n,ntl] → combine_objects n ntl ) | Elts → ( case vs of [] → JSON.Array [] | [n,ntl] → cons_array n ntl ) | EltsTl → ( case vs of [] → JSON.Array [] | [_,n,ntl] → cons_array n ntl ) )"
text‹
that in Vermillion one can attach the functions to read parse trees directly
the production rules.
this would be possible in Isabelle/HOL, it would give little advantage over defining
reader function directly, since we are missing dependent types. ›
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-07-02)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.