<commit_before>/**
 * Exports factor functions for creating numeric expressions.
 * @module Parser/Ast/expressions
 **/
let typenames = require('./typenames.js');

/** @class BinExpr **/
let BinExpr = {};

BinExpr.prototype = {
  /** @lends BinExpr **/

  /**
   * Writes the expression of two terms as a string.
   * @return {String} String representation of a binary expression.
   **/
  toString : function() {
    return this.type() + "(" +
      this.term1.toString() + ", " +
      this.term2.toString() + ")";
  },
};

/** @class SubExpr **/
let SubExpr = {};

SubExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends SubExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.SUB_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs - rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) - this.rhs.execute(sysvars);
  }
};

/** @class AddExpr **/
let AddExpr = {};

AddExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends AddExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.ADD_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs + rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) + this.rhs.execute(sysvars);
  }
};

/** @class MulExpr **/
let MulExpr = {};

MulExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends MulExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.MUL_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs * rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) * this.rhs.execute(sysvars);
  }
};

/** @class DivExpr **/
let DivExpr = {};

DivExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends DivExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.DIV_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs / rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) / this.rhs.execute(sysvars);
  }
};

/** @class PowExpr **/
let PowExpr = {};

PowExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends PowExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.POW_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of math.pow(lhs, rhs).
   **/
  execute : function(sysvars) {
    return Math.pow(this.lhs.execute(sysvars), this.rhs.execute(sysvars));
  }
};

/** @class UMinusExpr **/
let UMinusExpr = {};

UMinusExpr.prototype = {
  /** @lends UMinusExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.UMINUS_EXPR; },

  /**
   * Executes the unary minus expression.
   * @param {Object} sysvars - The bot's state as it is represented to the DNA.
   * @return {Number} Result of -expression.
   **/
  execute : function(sysvars) {
    return -this.expression.execute(sysvars);
  },
};

/** @class Literal **/
let Literal = {};

Literal.prototype = {
  /** @lends Literal **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.LITERAL; },

  /**
   * Simply returns the value of the literal.
   * @return {Number} The literal's value.
   **/
  execute : function() {
    return this.value;
  },
};

/** @class Variable **/
let Variable = {};

Variable.prototype = {
  /** @lends Variable **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.VARIABLE; },

  /**
   * Reads the value stored in the variables location
   * in the sysvars.
   * @param {Object} sysvars - The bot dna's view of the bot's state.
   * @return {Number} The value of the variable (0 if undefined).
   **/
  execute : function(sysvars) {
    return sysvars[this.name] || 0;
  },
};

<commit_msg>added tostring methods to the unary expressions<commit_after>/**
 * Exports factor functions for creating numeric expressions.
 * @module Parser/Ast/expressions
 **/
let typenames = require('./typenames.js');

/** @class BinExpr **/
let BinExpr = {};

BinExpr.prototype = {
  /** @lends BinExpr **/

  /**
   * Writes the expression of two terms as a string.
   * @return {String} String representation of a binary expression.
   **/
  toString : function() {
    return this.type() + "(" +
      this.term1.toString() + ", " +
      this.term2.toString() + ")";
  },
};

/** @class SubExpr **/
let SubExpr = {};

SubExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends SubExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.SUB_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs - rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) - this.rhs.execute(sysvars);
  }
};

/** @class AddExpr **/
let AddExpr = {};

AddExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends AddExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.ADD_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs + rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) + this.rhs.execute(sysvars);
  }
};

/** @class MulExpr **/
let MulExpr = {};

MulExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends MulExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.MUL_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs * rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) * this.rhs.execute(sysvars);
  }
};

/** @class DivExpr **/
let DivExpr = {};

DivExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends DivExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.DIV_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of lhs / rhs.
   **/
  execute : function(sysvars) {
    return this.lhs.execute(sysvars) / this.rhs.execute(sysvars);
  }
};

/** @class PowExpr **/
let PowExpr = {};

PowExpr.prototype = {
  __proto__ : BinExpr.prototype,
  /** @lends PowExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.POW_EXPR; },

  /**
   * Executes the expression.
   * @param {Object} sysvars - The bot's state as it is represented tothe DNA.
   * @return {Number} Result of math.pow(lhs, rhs).
   **/
  execute : function(sysvars) {
    return Math.pow(this.lhs.execute(sysvars), this.rhs.execute(sysvars));
  }
};

/** @class UMinusExpr **/
let UMinusExpr = {};

UMinusExpr.prototype = {
  /** @lends UMinusExpr **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.UMINUS_EXPR; },

  /**
   * Executes the unary minus expression.
   * @param {Object} sysvars - The bot's state as it is represented to the DNA.
   * @return {Number} Result of -expression.
   **/
  execute : function(sysvars) {
    return -this.expression.execute(sysvars);
  },

  /**
   * Creates a human-readable representation of the unary expression.
   * @return {String} Pretty-printed form of this node.
   **/
  toString : function() {
    return "Minus(" + this.expression.toString() + ")";
  },
};

/** @class Literal **/
let Literal = {};

Literal.prototype = {
  /** @lends Literal **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.LITERAL; },

  /**
   * Simply returns the value of the literal.
   * @return {Number} The literal's value.
   **/
  execute : function() {
    return this.value;
  },

  /**
   * Creates a human-readable representation of the literal.
   * @return {String} Pretty-printed form of this node.
   **/
  toString : function() {
    return "Literal(" + this.value + ")";
  },
};

/** @class Variable **/
let Variable = {};

Variable.prototype = {
  /** @lends Variable **/

  /**
   * Retrieves the expression's type.
   **/
  type : function() { return typenames.VARIABLE; },

  /**
   * Reads the value stored in the variables location
   * in the sysvars.
   * @param {Object} sysvars - The bot dna's view of the bot's state.
   * @return {Number} The value of the variable (0 if undefined).
   **/
  execute : function(sysvars) {
    return sysvars[this.name] || 0;
  },

  /**
   * Creates a human-readable representation of the variable.
   * @return {String} Pretty-printed form of this node.
   **/
  toString : function() {
    return "Variable(" + this.name + ")";
  },
};


{'fraction_non_alphanumeric': 0.15972812234494477, 'fraction_numerical': 0.0008496176720475786, 'mean_word_length': 2.807925596441569, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5691829', 'n_tokens_mistral': 3221, 'n_tokens_neox': 3136, 'n_words': 830}