SeedV / SeedLang

An embeddable and visualizable scripting engine for .Net and Unity.
https://seedv.github.io/SeedLang/
Apache License 2.0
9 stars 1 forks source link

Indention but no EOF in the last line causes compilation errors #209

Closed wixette closed 2 years ago

wixette commented 2 years ago
      var engine = new Engine(SeedXLanguage.SeedPython, RunMode.Script);
      string code = "a=0\nfor i in range(10):\n\ta = a + i\n\t";
      var collection = new DiagnosticCollection();
      if (!engine.Compile(code, "", collection)) {
        Console.WriteLine(collection.Diagnostics[0].ToString());
      } else {
        Console.WriteLine("OK");
      }

The above code results in SeedLang compilation error:

20220620002906110 Fatal (SeedLang.X) <> [Ln 4, Col 1 - Ln 4, Col 0] 29: SyntaxErrorMissingToken '<EOF>' DEDENT

While in Python3, the same code piece can be executed with no error:

Python 3.9.13 (main, May 24 2022, 21:13:51) 
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
>>> code = "a=0\nfor i in range(10):\n\ta = a + i\n\t"
>>> exec(code)
>>> a
45