aboutsummaryrefslogtreecommitdiff
path: root/bin/main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'bin/main.ml')
-rw-r--r--bin/main.ml218
1 files changed, 0 insertions, 218 deletions
diff --git a/bin/main.ml b/bin/main.ml
index 091a6d6..e69de29 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -1,218 +0,0 @@
-module Parser = Rdf_turtle.Parser
-
-module Ast = Rdf_turtle.Ast
-
-let parse p =
- Angstrom.parse_string
- ~consume:Angstrom.Consume.All
- p
-
-let test (parser_str, parse_str, parser', pp) =
- let () = Fmt.pr "\n@.Trying string:@. %s@. with parser %s@." parse_str parser_str in
- parse_str |> parse parser' |> function
- | Ok x -> Fmt.pr "... ok ... pp_output is:@. %a @." pp x
- | Error e -> raise (Failure (Fmt.str "error: %s@." e))
-
-let turtle_list =
- [
-(* SUBJECT = COLLECTION , this works! *)
- "() <http://a.example/p> <http://a.example/o> ."
- ;
- "('''hello''') <http://a.example/p> <http://a.example/o> ."
- ;
- "('1' '2') <http://a.example/p> <http://a.example/o> ."
- ;
- "('1' '2' '3') <http://a.example/p> <http://a.example/o> ."
- ;
-
-(* OBJECT = COLLECTION, this works! *)
- "<http://a.example/s> <http://a.example/p> () ."
- ;
- "<http://a.example/s> <http://a.example/p> ('1') ."
- ;
- "<http://a.example/s> <http://a.example/p> ('1' '2') ."
- ;
- "<http://a.example/s> <http://a.example/p> ('1' '2' '3') ."
- ;
-
-(* SUBJECT = BNODPS, this works *)
- "[] <http://a.example/p> <http://a.example/o> ."
- ;
- "
- @prefix as: <https://www.w3.org/ns/activitystreams#> .
- [ a as:Person ; ]
- <http://a.example/p> <http://a.example/o> ."
- ;
- "
- @prefix as: <https://www.w3.org/ns/activitystreams#> .
- @prefix ldp: <http://www.w3.org/ns/ldp#> .
-
- [ a as:Person ;
- ldp:inbox <http://localhost:4000/users/alice/inbox> ;
- ]
- <http://a.example/p> <http://a.example/o> ."
- ;
-
- (* TRIPLE / SUBJECT / OBJECT = BNODPS, this works *)
- (* This is parsed, but no triple is emmited .. *)
- "[] ."
- ;
- "[<pred> <obj>] ."
- ;
- "[] <pred> <obj> ."
- ;
- "<sub> <pred> [] ."
- ;
- "<sub> <pred> [<pred2> <obj2>] ."
- ;
- "<sub> <pred> [<pred2> <obj2>, <obj3> ; <pred4> <obj4>, <obj5>] ."
- ;
-
-(* NESTED BNODPS (in subject), this works *)
- "[ <http://a.example/p1> [ <http://a.example/p2> <http://a.example/o2> ] ; <http://a.example/p> <http://a.example/o> ]."
- ;
-
-(* BNODPS (as triple) CONTAINING COLLECTION, this works *)
- "[ <http://a.example/p1> ('1') ] ."
- ;
-
-(* NESTED COLLECTIONS, this works *)
- "<http://a.example/s> <http://a.example/p> (('1')) ."
- ;
- "<http://a.example/s> <http://a.example/p> ('1' ('2')) ."
- ;
-
-(* A MORE REALISTIC EXAMPLE *)
- "@prefix as: <https://www.w3.org/ns/activitystreams#> .
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-@prefix ldp: <http://www.w3.org/ns/ldp#> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
-
-<http://localhost:4000/users/alice>
- a as:Person ;
- ldp:inbox <http://localhost:4000/users/alice/inbox> ;
- as:outbox <http://localhost:4000/users/alice/outbox> ;
- as:preferredUsername \"alice\" .
- "
- ;
- ]
-
-(* let test_ctx : Rdf_turtle.Ast.state = *)
-(* { *)
-(* base_uri = "base" |> Iri.of_string; *)
-(* namespaces = Rdf_turtle.Ast.SMap.empty; *)
-(* bnode_counter = 0; *)
-(* } *)
-(* *)
-(* let empty_graph = Graph.empty *)
-
-let () =
- List.iter (
- fun turtle_str ->
- turtle_str
- |> (fun turtle ->
- Fmt.pr "@.THE TURTLE STRING: %s@." turtle;
- turtle)
- |> Rdf_turtle.decode
- |> Rdf.Graph.to_triples
- |> Seq.iter (fun triple ->
- Fmt.pr "@.%a" Rdf.Triple.pp triple;
- )
- ) turtle_list
-
-(* List.iter ( *)
-(* fun statement_str -> *)
-(* statement_str *)
-(* |> (fun str -> *)
-(* Fmt.pr "The statement_str: %s@." str; *)
-(* str) *)
-(* |> parse Parser.statement *)
-(* |> (function *)
-(* | Ok x -> Fmt.pr "... ok ... pp_output is:@. %a @." Ast.Statement.pp x; x *)
-(* | Error e -> raise (Failure (Fmt.str "error: %s@." e))) *)
-(* |> (fun statement -> *)
-(* Rdf_turtle.apply_statement (test_ctx, empty_graph) statement) *)
-(* |> (fun (_ctx, g) -> *)
-(* List.of_seq @@ Graph.to_triples @@ g) *)
-(* |> List.iter (fun triple -> *)
-(* Fmt.pr "%a@." Triple.pp triple) *)
-(* ) turtle_list ; *)
-
->>>>>>> a64d084 (Cleaned up some code, changed a few names. Added a test function in)
-(* test ("literal", "\"Cette Série des Années Septantei\"^^<iri>@lang", Parser.literal, Ast.Literal.pp) ; *)
-(* *)
-(* test ("iriref", "<http://example.org/#spidermanhhhhhhhhhhhhhh>", Parser.iriref, Ast.Iriref.pp) ; *)
-(* test ("language", "@en-fr", Parser.language, Ast.Language.pp) ; *)
-(* test ("iri", "a:p", Parser.iri, Ast.Iri.pp) ; *)
-(* test ("prefixed_name", "rdfs:some-example", Parser.prefixed_name, Ast.Prefixed_name.pp) ; *)
-(* test ("blank_node", "_:some-example", Parser.blank_node, Ast.Blank_node.pp) ; *)
-(* test ("iri" , "<https://someiri.com/blah>", Parser.iri, Ast.Iri.pp) ; *)
-(* test ("iri" , "rdfsk:irir", Parser.iri, Ast.Iri.pp) ; *)
-(* test ("literal", "\"hia\"", Parser.literal, Ast.Literal.pp) ; *)
-(* test ("literal", "\"Cette Série des Années Septantei\"@be", Parser.literal, Ast.Literal.pp) ; *)
-(* test ("literal", "\"Cette Série des Années Septantei\"^^xsd:string", Parser.literal, Ast.Literal.pp) ; *)
-(* test ("predicate", "b:a", Parser.predicate, Ast.Predicate.pp) ; *)
-(* test ("object (iri)", "a:p", Parser.object', Ast.object_pp) ; *)
-(* test ("object (bnode)", "_:blabla", Parser.object', Ast.object_pp) ; *)
-(* test ("object (literal)", "\"Cette Série des Années Septantei\"^^<iri>", Parser.object', Ast.object_pp) ; *)
-(* test ("object (coll)", "(_:a _:b <iriobj> rdfs:o)", Parser.object', Ast.object_pp) ; *)
-(* test ("object (bnodps)", "[ <predicate> <object> ]", Parser.object', Ast.object_pp) ; *)
-(* test ("object (bnodps)", "[ <pred1> <obj1>; <pred2> <obj2>, <obj3> ]", Parser.object', Ast.object_pp) ; *)
-(* test ("object (bnodps)", "[ a:p a:o1 ]", Parser.object', Ast.object_pp) ; *)
-(* test ("object (bnodps)", *)
-(* "[ rel:enemyOf <#green-goblin>, \"henkie\"; *)
-(* rel:enemyOf <#green-goblin>, _:sjaak; *)
-(* a foaf:Person ; *)
-(* foaf:name \"Spiderman\", \"Человек-паук\"@ru]", *)
-(* Parser.object', Ast.object_pp) ; *)
-(* test ("subject (iri)", "alaaf:potverdorie", Parser.subject, Ast.subject_pp) ; *)
-(* test ("subject (iri)", "<#spiderman>", Parser.subject, Ast.subject_pp) ; *)
-(* test ("subject (blank_node)", "_:potverdorie", Parser.subject, Ast.subject_pp) ; *)
-(* test ("subject (bnodps)", *)
-(* "[ rel:enemyOf <#green-goblin>, \"henkie\"; *)
-(* rel:enemyOf <#green-goblin>, _:sjaak; *)
-(* a foaf:Person ; *)
-(* foaf:name \"Spiderman\", \"Человек-паук\"@ru]", *)
-(* Parser.subject, Ast.subject_pp) ; *)
-(* test ("subject (collection)", "( _:a _:b _:c)", Parser.subject, Ast.subject_pp) ; *)
-(* test ("bnodps", "[ p:a _:b, _:c ]", Parser.bnodps, Ast.bnodps_pp) ; *)
-(* test ("predobjs", " p:a _:b, _:c ", Parser.predobjs, Ast.predobjs_pp) ; *)
-(* test ("predobjs", *)
-(* " rel:enemyOf <#green-goblin> ; *)
-(* a foaf:Person ; *)
-(* foaf:name \"Spiderman\", \"Человек-паук\"@ru ", *)
-(* Parser.predobjs, Ast.predobjs_pp) ; *)
-(* test ("triples", "[ p:a _:b, _:c ] ", Parser.triples, Ast.Triple.pp) ; *)
-(* test ("triples", "<#spiderman> <what> <#green-goblin> ", Parser.triples, Ast.Triple.pp) ; *)
-(* test ("triples", *)
-(* " <#spiderman> rel:enemyOf <#green-goblin> ; *)
-(* a foaf:Person ; *)
-(* foaf:name \"Spiderman\", \"Человек-паук\"@ru", *)
-(* Parser.triples, Ast.Triple.pp) ; *)
-(* test ("directive", "@base <http://one.example/>", Parser.directive, Ast.Directive.pp) ; *)
-(* test ("directive", "@prefix foaf: <http://xmlns.com/foaf/0.1/>", Parser.directive, Ast.Directive.pp) ; *)
-(* test ("statement", "@base <http://one.example/> . ", Parser.statement, Ast.Statement.pp) ; *)
-(* test ("statement", *)
-(* " <#spiderman> rel:enemyOf <#green-goblin> ; *)
-(* a foaf:Person ; *)
-(* foaf:name \"Spiderman\", \"Человек-паук\"@ru . ", *)
-(* Parser.statement, Ast.Statement.pp) ; *)
-(* test ("turtle", *)
-(* " @base <http://example.org/> . *)
-(* @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . *)
-(* @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . *)
-(* @prefix foaf: <http://xmlns.com/foaf/0.1/> . *)
-(* *)
-(* <#green-goblin> *)
-(* rel:enemyOf <#spiderman> ; #LET us put a comment here *)
-(* a foaf:Person ; *)
-(* foaf:name \"Green Goblin\" . *)
-(* *)
-(* @prefix rel: <http://www.perceive.net/schemas/relationship/> . *)
-(* <#spiderman> *)
-(* rel:enemyOf <#green-goblin> ; *)
-(* a foaf:Person ; *)
-(* foaf:name \"Spiderman\", \"Человек-паук\"@ru . ", *)
-(* Parser.turtle, Ast.Turtle.pp) ; *)