protected override object DoEvaluate(ScriptThread thread) { thread.CurrentNode = this; if (children == null) { throw new ParserException(); } if (children.Length == 1) { var e = children[0].Term switch { KeyTerm key => key.Text == "true" ? true : key.Text == "false" ? false : key.Text == "null" ? null : throw new ParserException("Invalid"), IdentifierTerminal => new IdentifierNode(children[0].AsString), _ => children[0].Evaluate(thread), }; thread.CurrentNode = Parent; // EbisterNodeでなければおそらくリテラルの即値(としておく) return(e is EbisterNode node ? node : new LiteralNode(EbiValueBase.ToEbiObject(e))); } else if (children.Length == 3) { if (children[0]?.Evaluate(thread) is not ExpressionNode left) { throw new ParserException(); } if (children[1].Term is not KeyTerm t) { throw new ParserException(); } if (children[2]?.Evaluate(thread) is not ExpressionNode right) { throw new ParserException(); } thread.CurrentNode = Parent; return(new BinaryExpressionNode(t.Text, left, right)); } else { throw new ParserException("invalid children size"); } }