Pārlūkot izejas kodu

Use parser_common include.

scossu 1 nedēļu atpakaļ
vecāks
revīzija
f2f1b07372
5 mainītis faili ar 154 papildinājumiem un 391 dzēšanām
  1. 1 1
      src/codec/Makefile
  2. 1 128
      src/codec/lexer_nt.re
  3. 1 128
      src/codec/lexer_ttl.re
  4. 36 34
      src/codec/parser_nt.c
  5. 115 100
      src/codec/parser_ttl.c

+ 1 - 1
src/codec/Makefile

@@ -48,7 +48,7 @@ $(BUILDDIR)/%_dbg.o: %.c
 
 # Parser C sources.
 parser_%.c: lexer_%.re grammar_%.c ../codec.c
-	$(LEXER) $< -o $@ -T --case-ranges -W
+	$(LEXER) $< -o $@ -T --case-ranges -W -I $(INCLUDE_DIR)
 
 
 .PRECIOUS: grammar_%.c $(CODEC_INCLUDE_DIR)/tokens_%.h

+ 1 - 128
src/codec/lexer_nt.re

@@ -1,134 +1,7 @@
 #include "volksdata/codec/parser_nt.h"
 #include "volksdata/codec/tokens_nt.h"
-//#include "volksdata/codec/parser_common.h"
-
-
-/** BEGIN duplicate section
- * This section is bit-by-bit identical in NT and TTL lexers. The copy in
- * include/volksdata/codec/parser_common.h should be used, but some re2c tags
- * are not being parsed in that location.
- */
-
-/** @brief TTL is UTF-8 encoded.
- *
- * @sa https://www.w3.org/TeamSubmission/turtle/#sec-grammar
- *
- * `char` should be considered to be UTF-8 throughout this library, however,
- * setting YYCTYPE to char generates case labels outside of the char range.
- */
-#define YYCTYPE     uint8_t
-#define YYCURSOR    it->cur
-#define YYMARKER    it->mar
-#define YYLIMIT     it->lim
-#define YYFILL      fill(it) == 0
-
-
-typedef struct {
-    FILE          * fh;         ///< Input file handle.
-    const char    * sh;         ///< Input string. Exclusive with fh.
-    size_t          buf_size;   ///< Initial allocation for buffer.
-    YYCTYPE       * buf,        ///< Start of buffer.
-                  * lim,        ///< Position after the last available
-                                ///<   input character (YYLIMIT).
-                  * cur,        ///< Next input character to be read (YYCURSOR)
-                  * mar,        ///< Most recent match (YYMARKER)
-                  * tok,        ///< Start of current token.
-                  * bol;        ///< Address of the beginning of the
-                                ///<   current line (for debugging).
-    unsigned        line;       ///< Current line no. (for debugging).
-    unsigned        ct;         ///< Number of statements parsed.
-    bool            eof;        ///< if we have reached EOF.
-    /*!stags:re2c format = "YYCTYPE *@@;"; */
-} ParseIterator;
-
-
-static int fill(ParseIterator *it);
-
-
-/** @brief Initialize parser.
- *
- * @param[in] it iterator handle to be initialized.
- *
- * @param[in] fh Open file handle to read from. This is exclusive with sh. If
- *  both fh and sh are provided, fh has precedence.
- *
- * @param[in] sh String to read from. This is exclusive with fh.
- */
-static void parse_init (ParseIterator *it, FILE *fh, const char *sh)
-{
-    if(fh) {
-        // Stream handling. It engages YYFILL and reads by chunks.
-        it->fh = fh;
-        it->sh = NULL;
-        it->buf_size = CHUNK_SIZE;
-        it->buf = malloc(it->buf_size);
-        if (!it->buf) log_error ("Error allocating lexer buffer.");
-        it->cur = it->mar = it->tok = it->lim = it->buf + it->buf_size - 1;
-        it->bol = it->buf;
-        it->eof = false;
-        it->lim[0] = 0;
-    } else {
-        // String handling. Uses the provided string as the buffer.
-        it->fh = NULL;
-        it->sh = sh;
-        it->buf_size = strlen(sh) + 1;
-        it->buf = NULL;
-        it->cur = it->tok = (YYCTYPE*)it->sh;
-        it->lim = it->mar = it->cur + it->buf_size - 1;
-        it->bol = it->cur;
-        it->eof = true;
-    }
-    it->line = 1;
-    it->ct = 0;
-    /*!stags:re2c format = "it->@@ = NULL; "; */
-}
-
-
-int
-fill(ParseIterator *it)
-{
-    log_debug ("Filling codec buffer @ %p.", it->buf);
-    if (it->eof) return 1;
-
-    size_t shift = it->tok - it->buf;
-    size_t used = it->lim - it->tok;
-
-    // If buffer is too small for the lexeme, double the capacity.
-    if (shift < 1) {
-        YYCTYPE *old_buf = it->buf;
-        shift += it->buf_size;
-        it->buf_size *= 2;
-        LOG_DEBUG ("Reallocating buffer to %zu bytes.", it->buf_size);
-        it->buf = realloc (it->buf, it->buf_size);
-        if (!it->buf) {
-            log_error ("Memory allocation error.");
-            return -1;
-        }
-        // Move all relative points if address changed.
-        size_t reloc_off = it->buf - old_buf;
-        it->cur += reloc_off;
-        it->tok += reloc_off;
-        it->lim += reloc_off;
-        it->mar += reloc_off;
-    } else {
-        LOG_DEBUG("Shifting bytes: %zu", shift);
-        memmove (it->buf, it->tok, used);
-        LOG_TRACE ("Limit offset before reading data: %zu", it->lim - it->tok);
-        it->lim -= shift;
-        it->cur -= shift;
-        it->mar -= shift;
-        it->tok -= shift;
-    }
-    it->lim += fread (it->lim, 1, it->buf_size - used - 1, it->fh);
-    /*!stags:re2c format = "if (it->@@) it->@@ -= shift; "; */
-    LOG_TRACE ("Cursor offset from last token: %zu", it->cur - it->tok);
-    LOG_TRACE ("Limit offset from last token: %zu", it->lim - it->tok);
-    it->lim[0] = 0;
-    it->eof = it->lim < it->buf + it->buf_size - 1;
-    return 0;
-}
 
-/** END duplicate section */
+/*!include:re2c "volksdata/codec/parser_common.h" */
 
 
 // Parser interface. Required here to silence linters.

+ 1 - 128
src/codec/lexer_ttl.re

@@ -1,134 +1,7 @@
 #include "volksdata/codec/parser_ttl.h"
 #include "volksdata/codec/tokens_ttl.h"
-//#include "volksdata/codec/parser_common.h"
-
-/** BEGIN duplicate section
- * This section is bit-by-bit identical in NT and TTL lexers. The copy in
- * include/volksdata/codec/parser_common.h should be used, but some re2c tags
- * are not being parsed in that location.
- */
-
-/** @brief TTL is UTF-8 encoded.
- *
- * @sa https://www.w3.org/TeamSubmission/turtle/#sec-grammar
- *
- * `char` should be considered to be UTF-8 throughout this library, however,
- * setting YYCTYPE to char generates case labels outside of the char range.
- */
-#define YYCTYPE     uint8_t
-#define YYCURSOR    it->cur
-#define YYMARKER    it->mar
-#define YYLIMIT     it->lim
-#define YYFILL      fill(it) == 0
-
-
-typedef struct {
-    FILE          * fh;         ///< Input file handle.
-    const char    * sh;         ///< Input string. Exclusive with fh.
-    size_t          buf_size;   ///< Initial allocation for buffer.
-    YYCTYPE       * buf,        ///< Start of buffer.
-                  * lim,        ///< Position after the last available
-                                ///<   input character (YYLIMIT).
-                  * cur,        ///< Next input character to be read (YYCURSOR)
-                  * mar,        ///< Most recent match (YYMARKER)
-                  * tok,        ///< Start of current token.
-                  * bol;        ///< Address of the beginning of the
-                                ///<   current line (for debugging).
-    unsigned        line;       ///< Current line no. (for debugging).
-    unsigned        ct;         ///< Number of statements parsed.
-    bool            eof;        ///< if we have reached EOF.
-    /*!stags:re2c format = "YYCTYPE *@@;"; */
-} ParseIterator;
-
-
-static int fill(ParseIterator *it);
-
-
-/** @brief Initialize parser.
- *
- * @param[in] it iterator handle to be initialized.
- *
- * @param[in] fh Open file handle to read from. This is exclusive with sh. If
- *  both fh and sh are provided, fh has precedence.
- *
- * @param[in] sh String to read from. This is exclusive with fh.
- */
-static void parse_init (ParseIterator *it, FILE *fh, const char *sh)
-{
-    if(fh) {
-        // Stream handling. It engages YYFILL and reads by chunks.
-        it->fh = fh;
-        it->sh = NULL;
-        it->buf_size = CHUNK_SIZE;
-        it->buf = malloc(it->buf_size);
-        if (!it->buf) log_error ("Error allocating lexer buffer.");
-        it->cur = it->mar = it->tok = it->lim = it->buf + it->buf_size - 1;
-        it->bol = it->buf;
-        it->eof = false;
-        it->lim[0] = 0;
-    } else {
-        // String handling. Uses the provided string as the buffer.
-        it->fh = NULL;
-        it->sh = sh;
-        it->buf_size = strlen(sh) + 1;
-        it->buf = NULL;
-        it->cur = it->tok = (YYCTYPE*)it->sh;
-        it->lim = it->mar = it->cur + it->buf_size - 1;
-        it->bol = it->cur;
-        it->eof = true;
-    }
-    it->line = 1;
-    it->ct = 0;
-    /*!stags:re2c format = "it->@@ = NULL; "; */
-}
-
-
-int
-fill(ParseIterator *it)
-{
-    log_debug ("Filling codec buffer @ %p.", it->buf);
-    if (it->eof) return 1;
-
-    size_t shift = it->tok - it->buf;
-    size_t used = it->lim - it->tok;
-
-    // If buffer is too small for the lexeme, double the capacity.
-    if (shift < 1) {
-        YYCTYPE *old_buf = it->buf;
-        shift += it->buf_size;
-        it->buf_size *= 2;
-        LOG_DEBUG ("Reallocating buffer to %zu bytes.", it->buf_size);
-        it->buf = realloc (it->buf, it->buf_size);
-        if (!it->buf) {
-            log_error ("Memory allocation error.");
-            return -1;
-        }
-        // Move all relative points if address changed.
-        size_t reloc_off = it->buf - old_buf;
-        it->cur += reloc_off;
-        it->tok += reloc_off;
-        it->lim += reloc_off;
-        it->mar += reloc_off;
-    } else {
-        LOG_DEBUG("Shifting bytes: %zu", shift);
-        memmove (it->buf, it->tok, used);
-        LOG_TRACE ("Limit offset before reading data: %zu", it->lim - it->tok);
-        it->lim -= shift;
-        it->cur -= shift;
-        it->mar -= shift;
-        it->tok -= shift;
-    }
-    it->lim += fread (it->lim, 1, it->buf_size - used - 1, it->fh);
-    /*!stags:re2c format = "if (it->@@) it->@@ -= shift; "; */
-    LOG_TRACE ("Cursor offset from last token: %zu", it->cur - it->tok);
-    LOG_TRACE ("Limit offset from last token: %zu", it->lim - it->tok);
-    it->lim[0] = 0;
-    it->eof = it->lim < it->buf + it->buf_size - 1;
-    return 0;
-}
-
-/** END duplicate section */
 
+/*!include:re2c "volksdata/codec/parser_common.h" */
 
 typedef struct {
     YYCTYPE *       data;

+ 36 - 34
src/codec/parser_nt.c

@@ -1,15 +1,14 @@
-/* Generated by re2c 4.1 on Fri Aug 22 19:43:48 2025 */
+/* Generated by re2c 4.1 on Mon Sep 29 14:11:25 2025 */
 #line 1 "lexer_nt.re"
 #include "volksdata/codec/parser_nt.h"
 #include "volksdata/codec/tokens_nt.h"
-//#include "volksdata/codec/parser_common.h"
 
+#line 1 "../../include/volksdata/codec/parser_common.h"
+#ifndef _VOLK_PARSER_COMMON_H
+#define _VOLK_PARSER_COMMON_H
+
+#include "volksdata/codec.h"
 
-/** BEGIN duplicate section
- * This section is bit-by-bit identical in NT and TTL lexers. The copy in
- * include/volksdata/codec/parser_common.h should be used, but some re2c tags
- * are not being parsed in that location.
- */
 
 /** @brief TTL is UTF-8 encoded.
  *
@@ -41,9 +40,9 @@ typedef struct {
     unsigned        ct;         ///< Number of statements parsed.
     bool            eof;        ///< if we have reached EOF.
     
-#line 45 "parser_nt.c"
+#line 44 "parser_nt.c"
 YYCTYPE *yyt1;YYCTYPE *yyt2;YYCTYPE *yyt3;
-#line 41 "lexer_nt.re"
+#line 36 "../../include/volksdata/codec/parser_common.h"
 
 } ParseIterator;
 
@@ -87,9 +86,9 @@ static void parse_init (ParseIterator *it, FILE *fh, const char *sh)
     it->line = 1;
     it->ct = 0;
     
-#line 91 "parser_nt.c"
+#line 90 "parser_nt.c"
 it->yyt1 = NULL; it->yyt2 = NULL; it->yyt3 = NULL; 
-#line 83 "lexer_nt.re"
+#line 78 "../../include/volksdata/codec/parser_common.h"
 
 }
 
@@ -131,9 +130,9 @@ fill(ParseIterator *it)
     }
     it->lim += fread (it->lim, 1, it->buf_size - used - 1, it->fh);
     
-#line 135 "parser_nt.c"
+#line 134 "parser_nt.c"
 if (it->yyt1) it->yyt1 -= shift; if (it->yyt2) it->yyt2 -= shift; if (it->yyt3) it->yyt3 -= shift; 
-#line 123 "lexer_nt.re"
+#line 118 "../../include/volksdata/codec/parser_common.h"
 
     LOG_TRACE ("Cursor offset from last token: %zu", it->cur - it->tok);
     LOG_TRACE ("Limit offset from last token: %zu", it->lim - it->tok);
@@ -142,7 +141,10 @@ if (it->yyt1) it->yyt1 -= shift; if (it->yyt2) it->yyt2 -= shift; if (it->yyt3)
     return 0;
 }
 
-/** END duplicate section */
+
+#endif // _VOLK_PARSER_COMMON_H
+#line 4 "lexer_nt.re"
+
 
 
 // Parser interface. Required here to silence linters.
@@ -169,7 +171,7 @@ loop:
     *term = NULL;
 
     
-#line 173 "parser_nt.c"
+#line 175 "parser_nt.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -195,7 +197,7 @@ yyFillLabel0:
 yy1:
 	++YYCURSOR;
 yy2:
-#line 289 "lexer_nt.re"
+#line 162 "lexer_nt.re"
 	{
         log_error (
             "Invalid token @ %p: %s (\\x%x)",
@@ -203,7 +205,7 @@ yy2:
 
         return -1;
     }
-#line 207 "parser_nt.c"
+#line 209 "parser_nt.c"
 yy3:
 	++YYCURSOR;
 yyFillLabel1:
@@ -218,13 +220,13 @@ yyFillLabel1:
 			goto yy4;
 	}
 yy4:
-#line 272 "lexer_nt.re"
+#line 145 "lexer_nt.re"
 	{
         LOG_DEBUG("Separator.");
 
         return T_WS;
     }
-#line 228 "parser_nt.c"
+#line 230 "parser_nt.c"
 yy5:
 	++YYCURSOR;
 yyFillLabel2:
@@ -240,14 +242,14 @@ yyFillLabel2:
 			goto yy6;
 	}
 yy6:
-#line 188 "lexer_nt.re"
+#line 61 "lexer_nt.re"
 	{
         it->line ++;
         it->bol = YYCURSOR;
         LOG_DEBUG("New line: #%u.", it->line);
         return T_EOL;
     }
-#line 251 "parser_nt.c"
+#line 253 "parser_nt.c"
 yy7:
 	yyaccept = 0;
 	YYMARKER = ++YYCURSOR;
@@ -289,7 +291,7 @@ yyFillLabel4:
 		default: goto yy9;
 	}
 yy9:
-#line 278 "lexer_nt.re"
+#line 151 "lexer_nt.re"
 	{
         size_t size = YYCURSOR - it->tok + 1;
         YYCTYPE *data = malloc (size);
@@ -300,17 +302,17 @@ yy9:
 
         goto loop;
     }
-#line 304 "parser_nt.c"
+#line 306 "parser_nt.c"
 yy10:
 	++YYCURSOR;
-#line 265 "lexer_nt.re"
+#line 138 "lexer_nt.re"
 	{
         LOG_DEBUG("End of triple.");
         it->ct ++;
 
         return T_DOT;
     }
-#line 314 "parser_nt.c"
+#line 316 "parser_nt.c"
 yy11:
 	yyaccept = 0;
 	YYMARKER = ++YYCURSOR;
@@ -419,7 +421,7 @@ yy17:
 	lit_data_e = it->yyt1;
 	dtype_s = it->yyt2;
 	lang_s = it->yyt3;
-#line 212 "lexer_nt.re"
+#line 85 "lexer_nt.re"
 	{
         // Only unescape Unicode from data.
         size_t size = lit_data_e - it->tok - 2;
@@ -460,7 +462,7 @@ yy17:
         if (UNLIKELY (!term)) return -1;
         return T_LITERAL;
     }
-#line 464 "parser_nt.c"
+#line 466 "parser_nt.c"
 yy18:
 	++YYCURSOR;
 yyFillLabel9:
@@ -656,7 +658,7 @@ yy32:
 	}
 yy33:
 	++YYCURSOR;
-#line 200 "lexer_nt.re"
+#line 73 "lexer_nt.re"
 	{
         YYCTYPE *data = unescape_unicode (it->tok + 1, YYCURSOR - it->tok - 2);
 
@@ -668,7 +670,7 @@ yy33:
         if (UNLIKELY (!term)) return -1;
         return T_IRIREF;
     }
-#line 672 "parser_nt.c"
+#line 674 "parser_nt.c"
 yy34:
 	++YYCURSOR;
 yyFillLabel23:
@@ -911,7 +913,7 @@ yy50:
 			goto yy51;
 	}
 yy51:
-#line 253 "lexer_nt.re"
+#line 126 "lexer_nt.re"
 	{
         YYCTYPE *data = unescape_unicode (it->tok + 2, YYCURSOR - it->tok - 2);
 
@@ -923,7 +925,7 @@ yy51:
         if (UNLIKELY (!term)) return -1;
         return T_BNODE;
     }
-#line 927 "parser_nt.c"
+#line 929 "parser_nt.c"
 yy52:
 	++YYCURSOR;
 yyFillLabel39:
@@ -1725,14 +1727,14 @@ yyFillLabel95:
 			goto yy15;
 	}
 yy110:
-#line 195 "lexer_nt.re"
+#line 68 "lexer_nt.re"
 	{
         LOG_DEBUG("End of buffer.");
         return T_EOF;
     }
-#line 1734 "parser_nt.c"
+#line 1736 "parser_nt.c"
 }
-#line 297 "lexer_nt.re"
+#line 170 "lexer_nt.re"
 
 }
 

+ 115 - 100
src/codec/parser_ttl.c

@@ -1,14 +1,14 @@
-/* Generated by re2c 4.1 on Fri Aug 22 14:38:40 2025 */
+/* Generated by re2c 4.1 on Mon Sep 29 14:11:25 2025 */
 #line 1 "lexer_ttl.re"
 #include "volksdata/codec/parser_ttl.h"
 #include "volksdata/codec/tokens_ttl.h"
-//#include "volksdata/codec/parser_common.h"
 
-/** BEGIN duplicate section
- * This section is bit-by-bit identical in NT and TTL lexers. The copy in
- * include/volksdata/codec/parser_common.h should be used, but some re2c tags
- * are not being parsed in that location.
- */
+#line 1 "../../include/volksdata/codec/parser_common.h"
+#ifndef _VOLK_PARSER_COMMON_H
+#define _VOLK_PARSER_COMMON_H
+
+#include "volksdata/codec.h"
+
 
 /** @brief TTL is UTF-8 encoded.
  *
@@ -42,7 +42,7 @@ typedef struct {
     
 #line 44 "parser_ttl.c"
 YYCTYPE *yyt1;
-#line 40 "lexer_ttl.re"
+#line 36 "../../include/volksdata/codec/parser_common.h"
 
 } ParseIterator;
 
@@ -88,7 +88,7 @@ static void parse_init (ParseIterator *it, FILE *fh, const char *sh)
     
 #line 90 "parser_ttl.c"
 it->yyt1 = NULL; 
-#line 82 "lexer_ttl.re"
+#line 78 "../../include/volksdata/codec/parser_common.h"
 
 }
 
@@ -100,35 +100,50 @@ fill(ParseIterator *it)
     if (it->eof) return 1;
 
     size_t shift = it->tok - it->buf;
+    size_t used = it->lim - it->tok;
 
     // If buffer is too small for the lexeme, double the capacity.
-    while (shift < 1) {
-        it->buf_size = 2 * it->buf_size;
+    if (shift < 1) {
+        YYCTYPE *old_buf = it->buf;
+        shift += it->buf_size;
+        it->buf_size *= 2;
+        LOG_DEBUG ("Reallocating buffer to %zu bytes.", it->buf_size);
         it->buf = realloc (it->buf, it->buf_size);
         if (!it->buf) {
             log_error ("Memory allocation error.");
             return -1;
         }
-        shift = it->tok - it->buf;
+        // Move all relative points if address changed.
+        size_t reloc_off = it->buf - old_buf;
+        it->cur += reloc_off;
+        it->tok += reloc_off;
+        it->lim += reloc_off;
+        it->mar += reloc_off;
+    } else {
+        LOG_DEBUG("Shifting bytes: %zu", shift);
+        memmove (it->buf, it->tok, used);
+        LOG_TRACE ("Limit offset before reading data: %zu", it->lim - it->tok);
+        it->lim -= shift;
+        it->cur -= shift;
+        it->mar -= shift;
+        it->tok -= shift;
     }
-    LOG_DEBUG("Shifting bytes: %zu", shift);
-    memmove (it->buf, it->tok, it->lim - it->tok);
-    it->lim -= shift;
-    it->cur -= shift;
-    it->mar -= shift;
-    it->tok -= shift;
-    it->lim += fread (it->lim, 1, shift, it->fh);
+    it->lim += fread (it->lim, 1, it->buf_size - used - 1, it->fh);
     
-#line 123 "parser_ttl.c"
+#line 134 "parser_ttl.c"
 if (it->yyt1) it->yyt1 -= shift; 
-#line 111 "lexer_ttl.re"
+#line 118 "../../include/volksdata/codec/parser_common.h"
 
+    LOG_TRACE ("Cursor offset from last token: %zu", it->cur - it->tok);
+    LOG_TRACE ("Limit offset from last token: %zu", it->lim - it->tok);
     it->lim[0] = 0;
-    it->eof |= it->lim < it->buf + CHUNK_SIZE - 1;
+    it->eof = it->lim < it->buf + it->buf_size - 1;
     return 0;
 }
 
-/** END duplicate section */
+
+#endif // _VOLK_PARSER_COMMON_H
+#line 4 "lexer_ttl.re"
 
 
 typedef struct {
@@ -158,7 +173,7 @@ static int lex (ParseIterator *it, YYCTYPE **token_p)
 {
     const YYCTYPE *pfx;
 
-    #line 187 "lexer_ttl.re"
+    #line 73 "lexer_ttl.re"
 
 
 loop: // Start new token.
@@ -167,7 +182,7 @@ loop: // Start new token.
     *token_p = NULL;
 
     
-#line 171 "parser_ttl.c"
+#line 186 "parser_ttl.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -226,7 +241,7 @@ yyFillLabel0:
 yy1:
 	++YYCURSOR;
 yy2:
-#line 196 "lexer_ttl.re"
+#line 82 "lexer_ttl.re"
 	{
         log_warn (
             "Invalid token @ %lu: %s (\\x%x)",
@@ -234,7 +249,7 @@ yy2:
 
         return -1;
     }
-#line 238 "parser_ttl.c"
+#line 253 "parser_ttl.c"
 yy3:
 	++YYCURSOR;
 yyFillLabel1:
@@ -256,7 +271,7 @@ yyFillLabel1:
 			goto yy4;
 	}
 yy4:
-#line 264 "lexer_ttl.re"
+#line 150 "lexer_ttl.re"
 	{
         uint8_t *ws = uint8_ndup (it->tok, YYCURSOR - it->tok);
         LOG_TRACE("Whitespace: '%s'", ws);
@@ -269,7 +284,7 @@ yy4:
 
         return T_WS;
     }
-#line 273 "parser_ttl.c"
+#line 288 "parser_ttl.c"
 yy5:
 	++YYCURSOR;
 yyFillLabel2:
@@ -291,12 +306,12 @@ yyFillLabel2:
 			goto yy6;
 	}
 yy6:
-#line 209 "lexer_ttl.re"
+#line 95 "lexer_ttl.re"
 	{
         newline (it);
         goto loop;
     }
-#line 300 "parser_ttl.c"
+#line 315 "parser_ttl.c"
 yy7:
 	yyaccept = 0;
 	YYMARKER = ++YYCURSOR;
@@ -311,9 +326,9 @@ yyFillLabel3:
 			goto yy8;
 	}
 yy8:
-#line 216 "lexer_ttl.re"
+#line 102 "lexer_ttl.re"
 	{ goto schar; }
-#line 317 "parser_ttl.c"
+#line 332 "parser_ttl.c"
 yy9:
 	yyaccept = 1;
 	YYMARKER = ++YYCURSOR;
@@ -340,12 +355,12 @@ yyFillLabel4:
 		default: goto yy10;
 	}
 yy10:
-#line 259 "lexer_ttl.re"
+#line 145 "lexer_ttl.re"
 	{
         LOG_TRACE("Comment: `%s`", it->tok);
         goto loop;
     }
-#line 349 "parser_ttl.c"
+#line 364 "parser_ttl.c"
 yy11:
 	++YYCURSOR;
 yyFillLabel5:
@@ -362,14 +377,14 @@ yyFillLabel5:
 			goto yy12;
 	}
 yy12:
-#line 319 "lexer_ttl.re"
+#line 205 "lexer_ttl.re"
 	{ return T_LPAREN; }
-#line 368 "parser_ttl.c"
+#line 383 "parser_ttl.c"
 yy13:
 	++YYCURSOR;
-#line 321 "lexer_ttl.re"
+#line 207 "lexer_ttl.re"
 	{ return T_RPAREN; }
-#line 373 "parser_ttl.c"
+#line 388 "parser_ttl.c"
 yy14:
 	yyaccept = 2;
 	YYMARKER = ++YYCURSOR;
@@ -400,9 +415,9 @@ yyFillLabel7:
 			goto yy16;
 	}
 yy16:
-#line 337 "lexer_ttl.re"
+#line 223 "lexer_ttl.re"
 	{ return T_COMMA; }
-#line 406 "parser_ttl.c"
+#line 421 "parser_ttl.c"
 yy17:
 	++YYCURSOR;
 yyFillLabel8:
@@ -416,13 +431,13 @@ yyFillLabel8:
 			goto yy18;
 	}
 yy18:
-#line 339 "lexer_ttl.re"
+#line 225 "lexer_ttl.re"
 	{
         LOG_TRACE("End of statement #%u.", it->ct);
         it->ct++;
         return T_PERIOD;
     }
-#line 426 "parser_ttl.c"
+#line 441 "parser_ttl.c"
 yy19:
 	yyaccept = 3;
 	YYMARKER = ++YYCURSOR;
@@ -440,7 +455,7 @@ yyFillLabel9:
 			goto yy20;
 	}
 yy20:
-#line 284 "lexer_ttl.re"
+#line 170 "lexer_ttl.re"
 	{
         // Normalize sign.
         size_t offset = *it->tok == '+' ? 1 : 0;
@@ -450,7 +465,7 @@ yy20:
 
         return T_INTEGER;
     }
-#line 454 "parser_ttl.c"
+#line 469 "parser_ttl.c"
 yy21:
 	yyaccept = 4;
 	YYMARKER = ++YYCURSOR;
@@ -471,14 +486,14 @@ yyFillLabel10:
 		default: goto yy66;
 	}
 yy22:
-#line 245 "lexer_ttl.re"
+#line 131 "lexer_ttl.re"
 	{
         *token_p = uint8_ndup (it->tok, YYCURSOR - it->tok);
         LOG_TRACE("ID name: %s", *token_p);
 
         return T_QNAME;
     }
-#line 482 "parser_ttl.c"
+#line 497 "parser_ttl.c"
 yy23:
 	++YYCURSOR;
 yyFillLabel11:
@@ -495,13 +510,13 @@ yyFillLabel11:
 			goto yy24;
 	}
 yy24:
-#line 331 "lexer_ttl.re"
+#line 217 "lexer_ttl.re"
 	{
         LOG_TRACE("End of object list.");
 
         return T_SEMICOLON;
     }
-#line 505 "parser_ttl.c"
+#line 520 "parser_ttl.c"
 yy25:
 	yyaccept = 2;
 	YYMARKER = ++YYCURSOR;
@@ -571,14 +586,14 @@ yyFillLabel15:
 			goto yy29;
 	}
 yy29:
-#line 325 "lexer_ttl.re"
+#line 211 "lexer_ttl.re"
 	{ return T_LBRACKET; }
-#line 577 "parser_ttl.c"
+#line 592 "parser_ttl.c"
 yy30:
 	++YYCURSOR;
-#line 327 "lexer_ttl.re"
+#line 213 "lexer_ttl.re"
 	{ return T_RBRACKET; }
-#line 582 "parser_ttl.c"
+#line 597 "parser_ttl.c"
 yy31:
 	++YYCURSOR;
 yyFillLabel16:
@@ -624,12 +639,12 @@ yyFillLabel18:
 			goto yy34;
 	}
 yy34:
-#line 347 "lexer_ttl.re"
+#line 233 "lexer_ttl.re"
 	{
         LOG_TRACE("RDF type shorthand 'a'.");
         return T_RDF_TYPE;
     }
-#line 633 "parser_ttl.c"
+#line 648 "parser_ttl.c"
 yy35:
 	yyaccept = 2;
 	YYMARKER = ++YYCURSOR;
@@ -1052,7 +1067,7 @@ yyFillLabel44:
 			goto yy63;
 	}
 yy63:
-#line 304 "lexer_ttl.re"
+#line 190 "lexer_ttl.re"
 	{
         // Normalize sign.
         YYCTYPE offset = *it->tok == '+' ? 1 : 0;
@@ -1067,7 +1082,7 @@ yy63:
 
         return T_DECIMAL;
     }
-#line 1071 "parser_ttl.c"
+#line 1086 "parser_ttl.c"
 yy64:
 	++YYCURSOR;
 yyFillLabel45:
@@ -1322,14 +1337,14 @@ yy81:
 yy82:
 	++YYCURSOR;
 yy83:
-#line 225 "lexer_ttl.re"
+#line 111 "lexer_ttl.re"
 	{
         *token_p = uint8_ndup (it->tok + 1, YYCURSOR - it->tok - 2);
         LOG_TRACE("URI data: %s", *token_p);
 
         return T_IRIREF;
     }
-#line 1333 "parser_ttl.c"
+#line 1348 "parser_ttl.c"
 yy84:
 	++YYCURSOR;
 yyFillLabel61:
@@ -1466,14 +1481,14 @@ yy94:
 			goto yy95;
 	}
 yy95:
-#line 277 "lexer_ttl.re"
+#line 163 "lexer_ttl.re"
 	{
         *token_p = uint8_ndup (it->tok + 1, YYCURSOR - it->tok - 1);
         LOG_TRACE("Lang tag: '%s'", *token_p);
 
         return T_LANGTAG;
     }
-#line 1477 "parser_ttl.c"
+#line 1492 "parser_ttl.c"
 yy96:
 	yyaccept = 11;
 	YYMARKER = ++YYCURSOR;
@@ -1735,14 +1750,14 @@ yyFillLabel87:
 yy114:
 	++YYCURSOR;
 yy115:
-#line 323 "lexer_ttl.re"
+#line 209 "lexer_ttl.re"
 	{ return T_ANON; }
-#line 1741 "parser_ttl.c"
+#line 1756 "parser_ttl.c"
 yy116:
 	++YYCURSOR;
-#line 345 "lexer_ttl.re"
+#line 231 "lexer_ttl.re"
 	{ return T_DTYPE_MARKER; }
-#line 1746 "parser_ttl.c"
+#line 1761 "parser_ttl.c"
 yy117:
 	++YYCURSOR;
 yyFillLabel88:
@@ -1948,9 +1963,9 @@ yyFillLabel103:
 	}
 yy133:
 	++YYCURSOR;
-#line 214 "lexer_ttl.re"
+#line 100 "lexer_ttl.re"
 	{ goto lchar; }
-#line 1954 "parser_ttl.c"
+#line 1969 "parser_ttl.c"
 yy134:
 	++YYCURSOR;
 yyFillLabel104:
@@ -2120,7 +2135,7 @@ yyFillLabel117:
 			goto yy148;
 	}
 yy148:
-#line 294 "lexer_ttl.re"
+#line 180 "lexer_ttl.re"
 	{
         // Normalize sign.
         size_t offset = *it->tok == '+' ? 1 : 0;
@@ -2130,7 +2145,7 @@ yy148:
 
         return T_DOUBLE;
     }
-#line 2134 "parser_ttl.c"
+#line 2149 "parser_ttl.c"
 yy149:
 	++YYCURSOR;
 yyFillLabel118:
@@ -2582,14 +2597,14 @@ yy181:
 			goto yy182;
 	}
 yy182:
-#line 252 "lexer_ttl.re"
+#line 138 "lexer_ttl.re"
 	{
         *token_p = uint8_ndup (it->tok + 2, YYCURSOR - it->tok - 2);
         LOG_TRACE("BNode name: %s", *token_p);
 
         return T_BNODE_ID;
     }
-#line 2593 "parser_ttl.c"
+#line 2608 "parser_ttl.c"
 yy183:
 	++YYCURSOR;
 yyFillLabel150:
@@ -3017,24 +3032,24 @@ yyFillLabel181:
 			goto yy215;
 	}
 yy215:
-#line 218 "lexer_ttl.re"
+#line 104 "lexer_ttl.re"
 	{
         *token_p = uint8_ndup (it->tok, YYCURSOR - it->tok);
         LOG_TRACE("Boolean: %s", *token_p);
 
         return T_BOOLEAN;
     }
-#line 3028 "parser_ttl.c"
+#line 3043 "parser_ttl.c"
 yy216:
 	++YYCURSOR;
 yy217:
-#line 239 "lexer_ttl.re"
+#line 125 "lexer_ttl.re"
 	{
         LOG_TRACE("'@base' keyword.");
 
         return T_BASE;
     }
-#line 3038 "parser_ttl.c"
+#line 3053 "parser_ttl.c"
 yy218:
 	++YYCURSOR;
 yyFillLabel182:
@@ -3255,14 +3270,14 @@ yy229:
 	++YYCURSOR;
 yy230:
 	pfx = it->yyt1;
-#line 232 "lexer_ttl.re"
+#line 118 "lexer_ttl.re"
 	{
         *token_p = uint8_ndup (pfx, YYCURSOR - pfx - 1);
         LOG_TRACE("Prefix declaration: '%s'", *token_p);
 
         return T_PREFIX;
     }
-#line 3266 "parser_ttl.c"
+#line 3281 "parser_ttl.c"
 yy231:
 	++YYCURSOR;
 yyFillLabel193:
@@ -3706,19 +3721,19 @@ yyFillLabel224:
 			goto yy52;
 	}
 yy263:
-#line 204 "lexer_ttl.re"
+#line 90 "lexer_ttl.re"
 	{
         LOG_TRACE("End of document.");
         return T_EOF;
     }
-#line 3715 "parser_ttl.c"
+#line 3730 "parser_ttl.c"
 }
-#line 352 "lexer_ttl.re"
+#line 238 "lexer_ttl.re"
 
 
 schar:
     
-#line 3722 "parser_ttl.c"
+#line 3737 "parser_ttl.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -3746,7 +3761,7 @@ yyFillLabel225:
 yy265:
 	++YYCURSOR;
 yy266:
-#line 357 "lexer_ttl.re"
+#line 243 "lexer_ttl.re"
 	{
         log_warn (
             "Invalid token in string @ %lu: %s (\\x%x)",
@@ -3754,23 +3769,23 @@ yy266:
 
         return -1;
     }
-#line 3758 "parser_ttl.c"
+#line 3773 "parser_ttl.c"
 yy267:
 	++YYCURSOR;
 yy268:
-#line 371 "lexer_ttl.re"
+#line 257 "lexer_ttl.re"
 	{ goto schar; }
-#line 3764 "parser_ttl.c"
+#line 3779 "parser_ttl.c"
 yy269:
 	++YYCURSOR;
-#line 373 "lexer_ttl.re"
+#line 259 "lexer_ttl.re"
 	{
         *token_p = unescape_unicode (it->tok + 1, YYCURSOR - it->tok - 2);
         LOG_TRACE("String: %s", *token_p);
 
         return T_STRING;
     }
-#line 3774 "parser_ttl.c"
+#line 3789 "parser_ttl.c"
 yy270:
 	yyaccept = 0;
 	YYMARKER = ++YYCURSOR;
@@ -3996,20 +4011,20 @@ yyFillLabel242:
 			goto yy278;
 	}
 yy288:
-#line 365 "lexer_ttl.re"
+#line 251 "lexer_ttl.re"
 	{
         log_warn ("Unterminated string!");
 
         return -1;
     }
-#line 4006 "parser_ttl.c"
+#line 4021 "parser_ttl.c"
 }
-#line 380 "lexer_ttl.re"
+#line 266 "lexer_ttl.re"
 
 
 lchar:
     
-#line 4013 "parser_ttl.c"
+#line 4028 "parser_ttl.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -4039,7 +4054,7 @@ yyFillLabel243:
 yy290:
 	++YYCURSOR;
 yy291:
-#line 400 "lexer_ttl.re"
+#line 286 "lexer_ttl.re"
 	{
         log_warn (
             "Invalid token in long string @ %lu: %s (\\x%x)",
@@ -4047,13 +4062,13 @@ yy291:
 
         return -1;
     }
-#line 4051 "parser_ttl.c"
+#line 4066 "parser_ttl.c"
 yy292:
 	++YYCURSOR;
 yy293:
-#line 391 "lexer_ttl.re"
+#line 277 "lexer_ttl.re"
 	{ goto lchar; }
-#line 4057 "parser_ttl.c"
+#line 4072 "parser_ttl.c"
 yy294:
 	yyaccept = 0;
 	YYMARKER = ++YYCURSOR;
@@ -4230,14 +4245,14 @@ yyFillLabel256:
 	}
 yy308:
 	++YYCURSOR;
-#line 393 "lexer_ttl.re"
+#line 279 "lexer_ttl.re"
 	{
         *token_p = unescape_unicode (it->tok + 3, YYCURSOR - it->tok - 6);
         LOG_TRACE("Long string: %s", it->tok);
 
         return T_STRING;
     }
-#line 4241 "parser_ttl.c"
+#line 4256 "parser_ttl.c"
 yy309:
 	++YYCURSOR;
 yyFillLabel257:
@@ -4317,15 +4332,15 @@ yyFillLabel262:
 			goto yy303;
 	}
 yy315:
-#line 385 "lexer_ttl.re"
+#line 271 "lexer_ttl.re"
 	{
         log_warn ("Unterminated long string!");
 
         return -1;
     }
-#line 4327 "parser_ttl.c"
+#line 4342 "parser_ttl.c"
 }
-#line 408 "lexer_ttl.re"
+#line 294 "lexer_ttl.re"
 
 }