From 5e5a1b0df3a9d465a6c8d63f11fe414dfc7c1a35 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Thu, 11 Apr 2024 11:16:41 +0100 Subject: [PATCH] Pulled in latest Trieste This pull in various fixes to Trieste that Verona needed from a recent refactor. These also help with printing error messages more nicely. --- CMakeLists.txt | 2 +- src/parse.cc | 15 +++++++++------ .../comments_broken_nest_out/00_parse.trieste | 2 +- .../spec/comments_broken_nest_out/ast | 9 --------- .../spec/comments_broken_nest_out/exit_code.txt | 2 +- .../spec/comments_broken_nest_out/stdout.txt | 6 ++++-- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 985a2df53..28d5ea5ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ set(TRIESTE_BUILD_SAMPLES OFF) FetchContent_Declare( trieste GIT_REPOSITORY https://github.com/microsoft/trieste - GIT_TAG fac9e4c84de192ee53051be32c5426256cd1086e + GIT_TAG 61678d80ffd239e23338ef9d002f2eef9badce67 GIT_SHALLOW FALSE ) diff --git a/src/parse.cc b/src/parse.cc index 5dc5b260f..f0abc7c2c 100644 --- a/src/parse.cc +++ b/src/parse.cc @@ -49,6 +49,7 @@ namespace verona auto depth = std::make_shared(0); auto str = std::make_shared(); auto indent = std::make_shared>(); + auto start_location = std::make_shared(); indent->push_back(restart); p.prefile([](auto&, auto& path) { return path.extension() == ".verona"; }); @@ -202,10 +203,11 @@ namespace verona // Unescaped string. "([']+)\"([^\"]*)" >> - [str](auto& m) { + [str, start_location](auto& m) { str->start = m.match(1).len; str->end = 0; m.add(String, 2); + *start_location = m.match(1); m.mode("string"); }, @@ -220,9 +222,10 @@ namespace verona // Nested comment. "/\\*" >> - [depth](auto& m) { + [depth, start_location](auto& m) { assert(*depth == 0); ++(*depth); + *start_location = m.match(); m.mode("comment"); }, @@ -334,12 +337,12 @@ namespace verona "\r?\n" >> [](auto&) {}, }); - p.done([](auto& m) { + p.done([start_location](auto& m) { if (m.mode() == "comment") - m.error("unterminated comment at end of file"); - + m.error("Unterminated comment starting at ", *start_location); + if (m.mode() == "string") - m.error("unterminated string at end of file"); + m.error("Unterminated string starting at ", *start_location); m.term(terminators); }); diff --git a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/00_parse.trieste b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/00_parse.trieste index 75e598921..54dffdf9d 100644 --- a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/00_parse.trieste +++ b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/00_parse.trieste @@ -5,5 +5,5 @@ parse (file (group (error - (errormsg 35:unterminated comment at end of file) + (errormsg 33:Unterminated comment starting at ) (errorast))))) diff --git a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/ast b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/ast index 8232b1e77..e69de29bb 100644 --- a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/ast +++ b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/ast @@ -1,9 +0,0 @@ -Verona -defaultargs -(top - {} - (file - (group - (error - (errormsg 35:unterminated comment at end of file) - (errorast))))) diff --git a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/exit_code.txt b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/exit_code.txt index b8e817d4f..56a6051ca 100644 --- a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/exit_code.txt +++ b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/exit_code.txt @@ -1 +1 @@ -255 \ No newline at end of file +1 \ No newline at end of file diff --git a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/stdout.txt b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/stdout.txt index 60014f301..1ed9618da 100644 --- a/testsuite/verona_nostdlib/spec/comments_broken_nest_out/stdout.txt +++ b/testsuite/verona_nostdlib/spec/comments_broken_nest_out/stdout.txt @@ -1,6 +1,8 @@ Errors: -unterminated comment at end of file/home/mjp41/verona/testsuite/verona_nostdlib/spec/comments_broken_nest.verona:1:38 +Unterminated comment starting at +-- comments_broken_nest.verona:1:1 /* Nested comments /* like this work */ - ~~ +~~ + Pass parse failed with 1 errors