Example #1
0
 public OperatorTypeMismatch(QSType type1, QSType type2, string op, int line)
 {
     this._type1    = type1;
     this._type2    = type2;
     this._operator = op;
     this._line     = line;
 }
Example #2
0
 public TypeMismatchError(QSType type1, QSType type2, int line)
 {
     // TODO: Complete member initialization
     this._type1 = type1;
     this._type2 = type2;
     this._line  = line;
 }
Example #3
0
 public UnaryOperatorTypeMismatch(QSType type1, string op, int line)
 {
     // TODO: Complete member initialization
     this._type1    = type1;
     this._operator = op;
     this._line     = line;
 }
 public OperatorTypeMismatch(QSType type1, QSType type2, string op, int line)
 {
     this._type1 = type1;
     this._type2 = type2;
     this._operator = op;
     this._line = line;
 }
 public UnaryOperatorTypeMismatch(QSType type1, string op, int line)
 {
     // TODO: Complete member initialization
     this._type1 = type1;
     this._operator = op;
     this._line = line;
 }
Example #6
0
 public Question(QSType type, string text, string id, int lineNr)
 {
     this._type   = type;
     this._text   = text;
     this._id     = id;
     this._lineNr = lineNr;
 }
Example #7
0
        public QSType GetType(string id)
        {
            QSType type = null;

            this._memory.TryGetValue(id, out type);
            return(type);
        }
Example #8
0
 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;
     }
 }
Example #10
0
        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);
        }
Example #11
0
 public bool TryDeclare(string name, QSType type)
 {
     if (this._memory.ContainsKey(name))
     {
         return(false);
     }
     else
     {
         this._memory.Add(name, type);
         return(true);
     }
 }
Example #12
0
        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);
        }
Example #13
0
        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);
        }
Example #14
0
 public override bool IsCompatible(QSType type)
 {
     return(type.IsInteger());
 }
Example #15
0
 public abstract bool IsCompatible(QSType type);
Example #16
0
 public override bool IsCompatible(QSType type)
 {
     return(type.IsBoolean());
 }