%include { /** @brief Lemon parser grammar for N-Triples. * * The `lemon' parser generator executable must be in your PATH: * https://sqlite.org/src/doc/trunk/doc/lemon.html * * To generate the parser, run: `lemon ${FILE}' */ #include "codec.h" } %name NTParse %token_type { LSUP_Term * } %token_prefix "T_" %default_type { void * } %extra_argument { LSUP_GraphIterator *it } // Rules. ntriplesDoc ::= triples EOF. triples ::= eol. triples ::= triple eol. triples ::= triples triple eol. %type triple { LSUP_Triple * } %destructor triple { LSUP_triple_free ($$); } triple(A) ::= ws subject(S) ws predicate(P) ws object(O) ws DOT. { A = LSUP_triple_new (S, P, O); LSUP_graph_add_iter (it, A); } %type subject { LSUP_Term * } %destructor subject { (void)(it); LSUP_term_free ($$); } subject ::= IRIREF. subject ::= BNODE. %type predicate { LSUP_Term * } %destructor predicate { LSUP_term_free ($$); } predicate ::= IRIREF. %type object { LSUP_Term * } %destructor object { LSUP_term_free ($$); } object ::= IRIREF. object ::= BNODE. object ::= LITERAL. eol ::= EOL. eol ::= eol EOL. ws ::=. ws ::= WS.