/// <summary> /// This level of abstraction of an expression includes relational expressions. /// Called everywhere where a relational or normal expression can be expected to be. /// </summary> void EXP_R() { EXP(); if (StartOf(5)) { OP(); SemanticCubeUtilities.Operators op = SemanticCubeUtilities.GetOperatorFromString(t.val); QuadrupleManager.PushOperator(op); EXP(); try { QuadrupleManager.PopOperator(SemanticCubeUtilities.OperatorToPriority(op)); } catch (Exception e) { SemErr(e.Message); } } }
/// <summary> /// Function that receives two <see cref="SemanticCubeUtilities.DataTypes"/> and a <see cref="SemanticCubeUtilities.Operators"/> /// and returns the resulting data type of combining the given types with the given operator. /// Called by <see cref="QuadrupleManager"/> to get the resulting data type of two operands /// and an operator. /// </summary> /// <param name="typeOne"></param> /// <param name="typeTwo"></param> /// <param name="op"></param> /// <returns> /// A <see cref="SemanticCubeUtilities.DataTypes"/> type. /// </returns> public static SemanticCubeUtilities.DataTypes AnalyzeSemantics(SemanticCubeUtilities.DataTypes typeOne, SemanticCubeUtilities.DataTypes typeTwo, SemanticCubeUtilities.Operators op) { // handle the negative operator as a special case since it only uses one operand if (op == SemanticCubeUtilities.Operators.negative) { if (Cube.TryGetValue(new TypeTypeOperator(typeOne, typeTwo, op), out SemanticCubeUtilities.DataTypes resultType)) { return(resultType); } else { return(SemanticCubeUtilities.DataTypes.invalidDataType); } } if (typeOne.Equals(SemanticCubeUtilities.DataTypes.invalidDataType) || typeTwo.Equals(SemanticCubeUtilities.DataTypes.invalidDataType) || op.Equals(SemanticCubeUtilities.Operators.invalidOperator)) { return(SemanticCubeUtilities.DataTypes.invalidDataType); } SemanticCubeUtilities.DataTypes type; if (Cube.TryGetValue(new TypeTypeOperator(typeOne, typeTwo, op), out type)) { return(type); } else { throw new Exception(String.Format("The specified key <{0},{1},{2}> was not found in the Semantic Cube", typeOne, typeTwo, op)); } }
/// <summary> /// Sets <see cref="Operator"/>'s value. /// </summary> /// <param name="Operator"></param> public void SetOperator(SemanticCubeUtilities.Operators Operator) { this.Operator = Operator; }
public TypeTypeOperator(SemanticCubeUtilities.DataTypes DataTypeOne, SemanticCubeUtilities.DataTypes DataTypeTwo, SemanticCubeUtilities.Operators Operator) { this.DataTypeOne = DataTypeOne; this.DataTypeTwo = DataTypeTwo; this.Operator = Operator; }