feat: add special case for string representation of cons which is a quote.

This commit is contained in:
redxef 2024-12-18 01:04:44 +01:00
parent d5e8b69b70
commit 805d0efb4f
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
2 changed files with 8 additions and 1 deletions

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);