%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 "graph.h" } %token_type { LSUP_Term * } %token_prefix "T_" %type triple { LSUP_SerTriple * } %destructor triple { LSUP_striple_free ($$); } %type subject { LSUP_Term * } %destructor subject { LSUP_term_free ($$); } %type predicate { LSUP_Term * } %destructor predicate { LSUP_term_free ($$); } %type object { LSUP_Term * } %destructor object { LSUP_term_free ($$); } %default_type { void * } %extra_argument { LSUP_GraphIterator *it } // Rules. ntriplesDoc ::= triples EOF. { printf (" Start of document.\n"); } triples ::= eol. triples ::= triple eol. triples ::= triples triple eol. triple(A) ::= ws subject(S) ws predicate(P) ws object(O) ws DOT. { A = LSUP_striple_new ( LSUP_buffer_new_from_term (S), LSUP_buffer_new_from_term (P), LSUP_buffer_new_from_term (O) ); LSUP_graph_add_iter (it, A); LSUP_term_free (S); LSUP_term_free (P); LSUP_term_free (O); } subject ::= IRIREF. subject ::= BNODE. predicate ::= IRIREF. object ::= IRIREF. object ::= BNODE. object ::= LITERAL. eol ::= EOL. eol ::= eol EOL. ws ::=. ws ::= WS. { printf ("WS in grammar.\n"); }