Skip to content

Commit

Permalink
Pulled in latest Trieste
Browse files Browse the repository at this point in the history
This pull in various fixes to Trieste that Verona needed from a recent refactor.
These also help with printing error messages more nicely.
  • Loading branch information
mjp41 committed Apr 11, 2024
1 parent 63990b2 commit 5e5a1b0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
15 changes: 9 additions & 6 deletions src/parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace verona
auto depth = std::make_shared<size_t>(0);
auto str = std::make_shared<Str>();
auto indent = std::make_shared<std::vector<size_t>>();
auto start_location = std::make_shared<Location>();
indent->push_back(restart);

p.prefile([](auto&, auto& path) { return path.extension() == ".verona"; });
Expand Down Expand Up @@ -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");
},

Expand All @@ -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");
},

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ parse
(file
(group
(error
(errormsg 35:unterminated comment at end of file)
(errormsg 33:Unterminated comment starting at )
(errorast)))))
9 changes: 0 additions & 9 deletions testsuite/verona_nostdlib/spec/comments_broken_nest_out/ast
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
Verona
defaultargs
(top
{}
(file
(group
(error
(errormsg 35:unterminated comment at end of file)
(errorast)))))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
255
1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5e5a1b0

Please sign in to comment.