public void Execute(List <Expression> instruction) { //Eliminar keyword de tipo IExecutable. No lo necesito para compilar. instruction.RemoveAt(0); if (SyntacticAnalysis(instruction)) { string nameVariable = instruction[0].ToString(); //Solo trabajar con las expresiones de la derecha del = instruction.RemoveAt(0); instruction.RemoveAt(0); //Si es un tipo Text y del operador =, y no hay mas tokens if (instruction.Count == 1 && (instruction[0] is Text)) { Memory.ChangeText(nameVariable, (instruction[0] as Text).Value); } //Es un tipo number else { FunctionArithmetic ecuation = ConvertToConditionalFunction.FetchFunction(instruction); //Guardar variable en la memoria if (ecuation != null) { Memory.ChangeVariable(nameVariable, ecuation.Evaluate(0)); } } } }
/// <summary> /// Constructor de funcion local /// </summary> /// <param name="name">Representa el nombre de la funcion</param> /// <param name="fparam">Representa la funcion en la que se desea evaluar dicha funcion</param> public LocalFunction(string name, FunctionArithmetic fparam) { _existFunction = true; _name = name; _function = fparam; if (!Memory.DataFunction.ContainsKey(name)) { _existFunction = false; MSharpErrors.OnError(string.Format("La funcion {0} no ha sido declarada", _name)); } }
internal static void SaveFunction(string name, FunctionArithmetic function) { if (AnalizeFunction(name, function) == false) { return; } if (ExistName(name)) { MSharpErrors.OnError(string.Format("Existe ya otro tipo con el nombre {0}", name)); return; } Memory.DataFunction.Add(name, function); }
private static bool AnalizeFunction(string name, FunctionArithmetic function) { if (name == null || function == null) { if (name == null) { MSharpErrors.OnError(string.Format("Compilation Error. Nombre de variable no puede ser null", name)); } else { MSharpErrors.OnError(string.Format("Compilation Error. La funcion {0} no puede ser null", name)); } return(false); } return(true); }
public void Execute(List <Expression> instruction) { //Eliminar keyword de tipo IExecutable. No lo necesito para compilar. instruction.RemoveAt(0); if (SyntacticAnalysis(instruction)) { FunctionArithmetic tempFunction = ConvertToConditionalFunction.FetchFunction(instruction); if (tempFunction != null) { //Guardar la funcion Memory.SaveFunction(name, ConvertToConditionalFunction.FetchFunction(instruction)); } } }
public void Execute(List <Expression> instruction) { //Eliminar keyword de tipo IExecutable. No lo necesito para compilar. instruction.RemoveAt(0); if (SyntacticAnalysis(instruction)) { if (instruction.Count == 1 && (instruction[0] is Text)) { if ((instruction[0] as Text).isOnlyText) { Display._output.Text += string.Format("{0}\n", (instruction[0] as Text).Value); } else { Display._output.Text += string.Format("{0}\n", Memory.GetText((instruction[0] as Text).Name)); } } else { FunctionArithmetic ecuation = ConvertToConditionalFunction.FetchFunction(instruction); float toShow = 0; if (ecuation != null) { toShow = ecuation.Evaluate(0); } if (!Compiler._haveError) { Display._output.Text += string.Format("{0}\n", toShow); } } } }
/// <summary> /// Constructor de Funcion /// </summary> /// <param name="body">Cuerpo de la funcion</param> /// <param name="proposition">Proposicion a evaluar</param> /// <param name="ptrElse">Puntero a otra funcion condicional</param> public ConditionalFunction(FunctionArithmetic body, FunctionBoolean proposition, ConditionalFunction ptrElse) { this.body = body; this.proposition = proposition; this.ptrElse = ptrElse; }
public Relational(FunctionArithmetic left, FunctionArithmetic right) { this.left = left; this.right = right; }
public LessOrEqual(FunctionArithmetic left, FunctionArithmetic right) : base(left, right) { }
public Elemental(FunctionArithmetic term) : base(term) { }
public RelationalComposite(FunctionArithmetic left, FunctionArithmetic right) : base(left, right) { }
public Exp(FunctionArithmetic function) : base(function) { }
public Atan(FunctionArithmetic function) : base(function) { }
public Sum(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth) { }
public Power(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth) { }
/// <summary> /// Constructor de la funcion Promedio. Recibe tres tipos de funciones aritmeticas las cuales sera promediadas /// </summary> /// <param name="first">Primera FunctionAritmetic</param> /// <param name="second">Segunda FunctionAritmetic</param> /// <param name="third">Tercera FunctionAritmetic</param> public Average(FunctionArithmetic first, FunctionArithmetic second, FunctionArithmetic third) { this._first = first; this._second = second; this._third = third; }
public Arccos(FunctionArithmetic function) : base(function) { }
/// <summary> /// Representa una Funcion Binaria /// </summary> /// <param name="left">El primer operando de tipo FunctionArithmeti</param> /// <param name="right">El segundo operando de tipo FunctionArithmeti</param> public BinaryFunction(FunctionArithmetic left, FunctionArithmetic right) { this.left = left; this.right = right; }
public Different(FunctionArithmetic left, FunctionArithmetic right) : base(left, right) { }
public LogNep(FunctionArithmetic function) : base(function) { }
public Arcsin(FunctionArithmetic function) : base(function) { }
public Cot(FunctionArithmetic function) : base(function) { }
public UnaryFunction(FunctionArithmetic function) { this._function = function; }
public Negative(FunctionArithmetic function) : base(function) { }
public Division(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth) { }
public Trigonometric(FunctionArithmetic term) : base(term) { }
public RelationalSimple(FunctionArithmetic left, FunctionArithmetic right) : base(left, right) { }
public Derivate(FunctionArithmetic function) : base(function) { }
public GreaterOrEqual(FunctionArithmetic left, FunctionArithmetic right) : base(left, right) { }
public Multiplication(FunctionArithmetic left, FunctionArithmetic rigth) : base(left, rigth) { }