Ejemplo n.º 1
0
 public static string AsString(this AstExpressionOperator op)
 {
     return(op switch
     {
         AstExpressionOperator.Open => "(",
         AstExpressionOperator.Close => ")",
         // arithmetic
         AstExpressionOperator.Plus => "+",
         AstExpressionOperator.Minus => "-",
         AstExpressionOperator.Divide => "/",
         AstExpressionOperator.Multiply => "*",
         AstExpressionOperator.Modulo => "%",
         AstExpressionOperator.Power => "**",
         AstExpressionOperator.Negate => "-",
         // comparison
         AstExpressionOperator.Equal => "=",
         AstExpressionOperator.NotEqual => "<>",
         AstExpressionOperator.Greater => ">",
         AstExpressionOperator.Smaller => "<",
         AstExpressionOperator.GreaterEqual => ">=",
         AstExpressionOperator.SmallerEqual => "<=",
         // bitwise
         AstExpressionOperator.BitAnd => "&",
         AstExpressionOperator.BitOr => "|",
         AstExpressionOperator.BitXor => "^",
         AstExpressionOperator.BitShiftLeft => "<<",
         AstExpressionOperator.BitShiftRight => ">>",
         AstExpressionOperator.BitRollLeft => "|<",
         AstExpressionOperator.BitRollRight => ">|",
         AstExpressionOperator.BitNegate => "~",
         // logic
         AstExpressionOperator.And => "and",
         AstExpressionOperator.Or => "or",
         AstExpressionOperator.Not => "not",
         _ => String.Empty,
     });
Ejemplo n.º 2
0
 public bool IsOperator(AstExpressionOperator op) => (Operator & op) > 0;