Пример #1
0
        public override void EnterAss(LatteParser.AssContext context)
        {
            var id = context.ID().GetText();

            if (!_environment.NameToVarDef.ContainsKey(id))
            {
                StateUtils.InterruptWithMessage(
                    context.start.Line,
                    context.ID().Symbol.Column,
                    ErrorMessages.VarNotDefined(id));
            }

            var variable = _environment.NameToVarDef[id];
            var exprType = new ExpressionTypeVisitor().Visit(context.expr());

            if (!variable.Type.Equals(exprType) && !IsTypeParent(exprType, variable.Type))
            {
                StateUtils.InterruptWithMessage(
                    context.start.Line,
                    context.ID().Symbol.Column,
                    ErrorMessages.VarExprTypesMismatch(id));
            }
        }
Пример #2
0
 public Ass(LatteParser.AssContext context)
 {
     Id   = context.ID().GetText();
     Expr = Exprs.Utils.ExprFromExprContext(context.expr());
 }