parser: improve error message for missing } in attrset

Change-Id: I2846dbd8d0c1beb23c885a2d6d388a4f6a6a6964
This commit is contained in:
Qyriad
2025-11-25 19:50:24 +00:00
parent 6bb532ed03
commit 9f12981b30
6 changed files with 13 additions and 4 deletions
+3 -2
View File
@@ -209,6 +209,7 @@ namespace d {
namespace t {
struct inherit : one<';'> { };
struct binding : one<';'> { };
struct attrs : one<'}'> { };
}
}
@@ -401,7 +402,7 @@ struct _attr {
struct expr : semantic, seq<
TAO_PEGTL_STRING("${"), seps,
must<grammar::v1::expr>, seps,
must<one<'}'>>
must<d::t::attrs>
> {};
};
struct attr : _attr, sor<
@@ -505,7 +506,7 @@ struct _expr {
Init...,
OpenMod<one<'{'>>, seps,
bindings, seps,
must<one<'}'>>
must<d::t::attrs>
> {};
struct select;
+1
View File
@@ -58,6 +58,7 @@ error_message_for(grammar::v1::t::kw_else) = "expecting 'else'";
error_message_for(grammar::v1::t::kw_in) = "expecting 'in'";
error_message_for(grammar::v1::d::t::binding) = "expecting ';' to end binding";
error_message_for(grammar::v1::d::t::inherit) = "expecting ';' to end 'inherit' bindings";
error_message_for(grammar::v1::d::t::attrs) = "expecting '}' to end attribute set";
struct SyntaxErrors
{
@@ -1,4 +1,4 @@
error: syntax error, unexpected end of file, expecting '}'
error: syntax error, unexpected end of file, expecting '}' to end attribute set
at /pwd/in.nix:1:2:
1| {
| ^
@@ -1,4 +1,4 @@
error: syntax error, unexpected end of file, expecting '}'
error: syntax error, unexpected end of file, expecting '}' to end attribute set
at /pwd/in.nix:1:2:
1| {
| ^
@@ -0,0 +1,2 @@
{
a = "b";
@@ -0,0 +1,5 @@
error: syntax error, unexpected end of file, expecting '}' to end attribute set
at /pwd/in.nix:3:1:
2| a = "b";
3|
| ^