構文要素に対応するクラス(DomainUnit クラス:数値を表す無限自由モノイドの項)
<summary>
</summary>
internal class DomainUnit : Term
{
<summary>
</summary>
private readonly DomainExpression expression;
public DomainUnit(DomainExpression expression)
{
this.expression = expression;
}
<summary>
</summary>
<param name="env"></param>
<param name="prog"></param>
<returns></returns>
public FreeMonoid<int> Eval(Env<FreeMonoidUnion> env, Prog prog)
{
return FreeMonoid<int>.Unit(expression.Eval(env).Number_);
}
<summary>
</summary>
<returns></returns>
public string Print()
{
return expression.Print();
}
<summary>
</summary>
<param name="yieldp"></param>
<param name="typep"></param>
<param name="indp"></param>
<param name="indcount"></param>
<param name="perf"></param>
<returns></returns>
public string GeneratePython(bool yieldp, bool typep, bool indp, int indcount, Func<string, string> perf)
{
string exp_str = expression.GeneratePython(false, typep, false, indcount, perf);
if (yieldp)
{
return $"yield {exp_str}\r\n";
}
else
{
return $"{exp_str}";
}
}
<summary>
</summary>
<param name="yieldp"></param>
<param name="typep"></param>
<param name="indp"></param>
<param name="indcount"></param>
<param name="perf"></param>
<returns></returns>
public string GenerateCS(bool yieldp, bool typep, bool indp, int indcount, Func<string, string> perf)
{
string exp_str = expression.GenerateCS(false, typep, false, indcount, perf);
if (yieldp)
{
return $"yield return {exp_str};\r\n";
}
else
{
return $"{exp_str}";
}
}
}