public OperatorTypeMismatch(QSType type1, QSType type2, string op, int line) { this._type1 = type1; this._type2 = type2; this._operator = op; this._line = line; }
public TypeMismatchError(QSType type1, QSType type2, int line) { // TODO: Complete member initialization this._type1 = type1; this._type2 = type2; this._line = line; }
public UnaryOperatorTypeMismatch(QSType type1, string op, int line) { // TODO: Complete member initialization this._type1 = type1; this._operator = op; this._line = line; }
public Question(QSType type, string text, string id, int lineNr) { this._type = type; this._text = text; this._id = id; this._lineNr = lineNr; }
public QSType GetType(string id) { QSType type = null; this._memory.TryGetValue(id, out type); return(type); }
public ComputedQuestion(string text, string id, QSExpression expr, QSType type, int lineNr) { this._type = type; this._text = text; this._id = id; this._lineNr = lineNr; this._expression = expr; }
public bool TryDeclare(string name, QSType type) { if (this._memory.ContainsKey(name)) return false; else { this._memory.Add(name, type); return true; } }
public bool TryDeclare(string identifier, QSType type, int lineNr) { bool isDeclared = this._typeMem.TryDeclare(identifier, type); if (!isDeclared) { this._errorList.Add(new DuplicateDeclarationError(identifier, lineNr)); return(false); } return(isDeclared); }
public bool TryDeclare(string name, QSType type) { if (this._memory.ContainsKey(name)) { return(false); } else { this._memory.Add(name, type); return(true); } }
public bool Visit(Unary_Expression expression) { bool result = expression.Internal.Accept <bool>(this); QSType operatorType = expression.GetType(this._typeMem); QSType internalType = expression.GetInternalType(this._typeMem); if (!operatorType.IsCompatible(internalType)) { // type of unary is not compatible with it's expression result = false; this._errorList.Add(new UnaryOperatorTypeMismatch(internalType, expression.GetOperator(), expression.Line)); } return(result); }
public bool Visit(Binary_Expression expression) { bool result = true; result &= expression.Left.Accept <bool>(this); result &= expression.Right.Accept <bool>(this); QSType exprType = expression.GetType(this._typeMem); QSType leftType = expression.GetLeftType(this._typeMem); QSType rightType = expression.GetRightType(this._typeMem); if (!leftType.IsCompatible(rightType)) { this._errorList.Add(new OperatorTypeMismatch(leftType, rightType, expression.GetOperator(), expression.Line)); result = false; } if (!leftType.IsCompatible(exprType)) { this._errorList.Add(new TypeMismatchError(leftType, rightType, expression.Line)); result = false; } return(result); }
public override bool IsCompatible(QSType type) { return(type.IsInteger()); }
public abstract bool IsCompatible(QSType type);
public override bool IsCompatible(QSType type) { return(type.IsBoolean()); }