Progmasoft Git

tazel

A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.

Clonegit clone https://git.progmasoft.com/tazel

Refuse a ; after a value of tazel_envs.txt

The entries of tazel_envs.txt follow one another with no ; between them; a ; after
a value is an error with its place.
Commit
6d4e6ed5add9ec91a3acb6c39a4aead355935939
Author
Leitwolf11 ·
Parents
5a2e5c4203e4

Files · Download .tar.gz

Changes

 docs/commands.md                           | 3 ++-
 src/Progmasoft.Tazel/Dsl/Envs/TazelEnvs.cs | 6 +++---
 tests/Progmasoft.Tazel.Tests/EnvsTests.cs  | 5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/docs/commands.md b/docs/commands.md
index 6d25599..46d3f99 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -166,7 +166,8 @@ using Progmasoft.Tazel.Dsl.Environment;
 var exampleVersion = GetEnvironment.From("example-version"); // "0.1.0"; null for a name the file does not have
 ```
 
-- It is read with the lexer of `tazel_custom.txt`: the same comments and strings; a `;` after a value is optional.
+- It is read with the lexer of `tazel_custom.txt`: the same comments and strings; the entries follow one another
+  with no `;` between them.
 - A string is the value as written. `("program" "argument")` starts a program directly, each string one argument;
   `s("line")` gives one line to `/bin/sh` on Linux, macOS and the BSDs and to `cmd.exe` on Windows. Their value is
   what they print, less the line endings at its end. A program runs when its value is first asked for, once per
diff --git a/src/Progmasoft.Tazel/Dsl/Envs/TazelEnvs.cs b/src/Progmasoft.Tazel/Dsl/Envs/TazelEnvs.cs
index 87703c2..a4aa61e 100644
--- a/src/Progmasoft.Tazel/Dsl/Envs/TazelEnvs.cs
+++ b/src/Progmasoft.Tazel/Dsl/Envs/TazelEnvs.cs
@@ -38,7 +38,7 @@ public sealed record EnvEntry(string Name, EnvValue Value, int Line);
 
 /// <summary>
 /// Reads <c>tazel_envs.txt</c> with the lexer of <c>tazel_custom.txt</c> and <c>tazel_options.txt</c>: the same comments
-/// and strings, <c>name: value</c> one after another, a <c>;</c> after a value optional.
+/// and strings, <c>name: value</c> one after another, with no <c>;</c> between them.
 /// </summary>
 public static class TazelEnvsFile
 {
@@ -92,9 +92,9 @@ public static class TazelEnvsFile
             }
 
             entries.Add(new EnvEntry(name.Text, value, name.Line));
-            if (Peek() is { Kind: TokenKind.Semicolon })
+            if (Peek() is { Kind: TokenKind.Semicolon } semicolon)
             {
-                i++;
+                throw Fail(semicolon, $"a value of tazel_envs.txt has no ';' after it: {name.Text}: ...");
             }
         }
 
diff --git a/tests/Progmasoft.Tazel.Tests/EnvsTests.cs b/tests/Progmasoft.Tazel.Tests/EnvsTests.cs
index 9716016..dab7e15 100644
--- a/tests/Progmasoft.Tazel.Tests/EnvsTests.cs
+++ b/tests/Progmasoft.Tazel.Tests/EnvsTests.cs
@@ -34,11 +34,12 @@ public sealed class EnvsTests
     }
 
     [Fact]
-    public void ASemicolonAfterAValueIsAllowed() =>
-        Assert.Equal(2, TazelEnvsFile.Parse("a: 'x'; b: \"y\"").Count);
+    public void ValuesFollowOneAnotherWithoutSemicolons() =>
+        Assert.Equal(2, TazelEnvsFile.Parse("a: 'x' b: \"y\"").Count);
 
     [Theory]
     [InlineData("a: 'x'\na: 'y'", "'a' is set twice")]
+    [InlineData("a: 'x';", "has no ';' after it")]
     [InlineData("a 'x'", "expected ':' after a")]
     [InlineData("a: ()", "a program names at least itself")]
     [InlineData("a: s('x' 'y')", "s(...) takes one string")]