From 8d954ab071e286f0b2bdfc542bb3725eb5a2ab0e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 23 Sep 2017 21:30:52 +0200 Subject: Add basic error tolerant parsing for line-based formats --- NEWS | 3 ++- src/reader.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index f35745fa..ed213940 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,13 @@ serd (0.29.3) unstable; + * Add basic error tolerant parsing for line-based formats * Support strict parsing of prefixed names * Report errors for all failing test cases * Use more efficient stack allocation and growth policies * Add NTriples test suite * Fix building with MSVC - -- David Robillard Sat, 23 Sep 2017 15:03:52 +0200 + -- David Robillard Sat, 23 Sep 2017 20:33:19 +0200 serd (0.28.0) stable; diff --git a/src/reader.c b/src/reader.c index afaf411e..9e30f9c1 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1669,11 +1669,25 @@ read_statement(SerdReader* reader) return ret; } +static void +skip_until(SerdReader* reader, uint8_t byte) +{ + for (uint8_t c = 0; (c = peek_byte(reader)) && c != byte;) { + eat_byte_safe(reader, c); + } +} + static bool read_turtleTrigDoc(SerdReader* reader) { while (!reader->eof) { - TRY_RET(read_statement(reader)); + if (!read_statement(reader)) { + if (reader->strict) { + return 0; + } + skip_until(reader, '\n'); + reader->status = SERD_ERR_BAD_SYNTAX; + } } return reader->status <= SERD_FAILURE; } -- cgit v1.2.1