Compare commits

...

2 commits

3 changed files with 14 additions and 3 deletions

View file

@ -78,8 +78,11 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp.Compiler {
}
value += t;
}
if (value.Equals("")) {
return null;
}
return new AtomToken(value);
}
}
class CharStream: Stream<char> {
@ -101,7 +104,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp.Compiler {
if (prev_avail == program.Available() && prev_avail == 0) {
break;
} else if (prev_avail == program.Available()) {
throw new ApplicationException("Program is invalid");
throw new ApplicationException($"Program is invalid, still available: {program.Available()}");
}
prev_avail = program.Available();
foreach (Type c in _classes) {

View file

@ -243,6 +243,13 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
return $"{Item1} . {Item2}";
}
public override string? ToString() {
if (Item1 is Symbol SymbolItem1
&& SymbolItem1.Name() == "quote"
&& Item2 is Cons ConsItem2
&& ConsItem2.Item2.Equals(Boolean.FALSE)
) {
return $"'{ConsItem2.Item1}";
}
return $"({ToStringSimple()})";
}
}

View file

@ -70,7 +70,7 @@ namespace Tests
program = "(abc '(1 2 3))";
sts = StringTokenStream.generate(program);
p = new Parser(sts);
Assert.Equal("(abc (quote (1 2 3)))", string.Format("{0}", p.parse()));
Assert.Equal(program, string.Format("{0}", p.parse()));
program = "(abc \"'(1 2 3)\")";
sts = StringTokenStream.generate(program);
@ -148,6 +148,7 @@ namespace Tests
(if (> 0 1) (car (quote (1 2 3))) (cdr (quote (2 3 4)))))
""").ToString());
Assert.Equal("a", e.eval("'a").ToString());
}
[Fact]