public override CodeGenPayload Visit(SubtractToken token, CodeGenPayload state = default) { return(new CodeGenPayload { Expression = Expression.Subtract(Visit(token.Item1, state).Expression, Visit(token.Item2, state).Expression) }); }
protected T Visit(IToken token, T state = default) { return(token switch { AddToken addToken => Visit(addToken, state), SubtractToken subtractToken => Visit(subtractToken, state), MultiplyToken multiplyToken => Visit(multiplyToken, state), DivideToken divideToken => Visit(divideToken, state), NegateToken negateToken => Visit(negateToken, state), NumberToken numberToken => Visit(numberToken, state), FactorialToken factorialToken => Visit(factorialToken, state), PowerToken powerToken => Visit(powerToken, state), VariableToken variableToken => Visit(variableToken, state), AssignmentToken assignmentToken => Visit(assignmentToken, state), _ => throw new ArgumentOutOfRangeException(nameof(token)) });
public virtual T Visit(SubtractToken token, T state = default) { return(Visit(token.Item1, state ?? new T()).Combine(Visit(token.Item2, state ?? new T()))); }