instruction_serialiser 0.0.6

This package helps developers serialising calculation instructions for reusing or archiving them.
Documentation
syntax = "proto3";

package instruction_serialiser;
option go_package = "github.com/nico151999/instruction_serialiser/go/instruction_serialiser";

message InstructionWrapper {
  oneof wrapper {
    ArithmeticResultNodeWrapper arithmetic_wrapper = 1;
    LogicalResultNodeWrapper logical_wrapper = 2;
  }
}

message ArithmeticResultNodeWrapper {
  oneof node {
    AddNode add_node = 1;
    DivideNode divide_node = 2;
    MultiplyNode multiply_node = 3;
    NumberNode number_node = 4;
    SubtractNode subtract_node = 5;
    ArithmeticVariableNode variable_node = 6;
    LogarithmNode logarithm_node = 7;
    PowerNode power_node = 8;
    ModuloNode modulo_node = 9;
    ArithmeticIfElseNode if_else_node = 10;
  }
}

message LogicalResultNodeWrapper {
  oneof node {
    EqualNode equal_node = 1;
    AndNode and_node = 2;
    BoolNode bool_node = 3;
    NegateNode negate_node = 4;
    OrNode or_node = 5;
    XorNode xor_node = 6;
    LogicalVariableNode variable_node = 7;
    LogicalIfElseNode if_else_node = 8;
    GreaterThanNode greater_than_node = 9;
    GreaterThanOrEqualNode greater_than_or_equal_node = 10;
    SmallerThanNode smaller_than_node = 11;
    SmallerThanOrEqualNode smaller_than_or_equal_node = 12;
  }
}

message AddNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message ArithmeticIfElseNode {
  LogicalResultNodeWrapper condition = 1;
  ArithmeticResultNodeWrapper if = 2;
  ArithmeticResultNodeWrapper else = 3;
}

message ArithmeticVariableNode {
  string variable_name = 1;
}

message DivideNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message LogarithmNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2; // the base
}

message ModuloNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message MultiplyNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message NumberNode {
  double value = 1;
}

message PowerNode {
  ArithmeticResultNodeWrapper left_child = 1; // the base
  ArithmeticResultNodeWrapper right_child = 2; // the exponent
}

message SubtractNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message AndNode {
  LogicalResultNodeWrapper left_child = 1;
  LogicalResultNodeWrapper right_child = 2;
}

message BoolNode {
  bool value = 1;
}

// The equal node compares arithmetic nodes only.
// If you want to determine equality of logical nodes use Xor followed by a negation.
message EqualNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message GreaterThanNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message GreaterThanOrEqualNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message LogicalIfElseNode {
  LogicalResultNodeWrapper condition = 1;
  LogicalResultNodeWrapper if = 2;
  LogicalResultNodeWrapper else = 3;
}

message LogicalVariableNode {
  string variable_name = 1;
}

message NegateNode {
  LogicalResultNodeWrapper child = 1;
}

message OrNode {
  LogicalResultNodeWrapper left_child = 1;
  LogicalResultNodeWrapper right_child = 2;
}

message SmallerThanNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message SmallerThanOrEqualNode {
  ArithmeticResultNodeWrapper left_child = 1;
  ArithmeticResultNodeWrapper right_child = 2;
}

message XorNode {
  LogicalResultNodeWrapper left_child = 1;
  LogicalResultNodeWrapper right_child = 2;
}