Ejemplo n.º 1
0
        public override void EnterStructIncr(LatteParser.StructIncrContext context)
        {
            var objectType = new ExpressionTypeVisitor().GetFieldType(context.expr(), context.ID().GetText(), context.start.Line);

            if (!objectType.Equals(new LatteParser.TIntContext()))
            {
                StateUtils.InterruptWithMessage(
                    context.start.Line,
                    context.ID().Symbol.Column,
                    ErrorMessages.DecrFieldOnlyOnInt(objectType.GetText(), context.ID().GetText()));
            }
        }
Ejemplo n.º 2
0
 public static Stmt StmtFromStmtContext(LatteParser.StmtContext context)
 {
     return(context switch
     {
         LatteParser.AssContext assContext => new Ass(assContext),
         LatteParser.BlockStmtContext blockStmtContext => new Block(blockStmtContext),
         LatteParser.CondContext condContext => new Cond(condContext),
         LatteParser.CondElseContext condElseContext => new CondElse(condElseContext),
         LatteParser.DeclContext declContext => new Decl(declContext),
         LatteParser.DecrContext decrContext => new Decr(decrContext),
         LatteParser.EmptyContext _ => new Empty(),
         LatteParser.IncrContext incrContext => new Incr(incrContext),
         LatteParser.RetContext retContext => new Ret(retContext),
         LatteParser.SExpContext sExpContext => new ExpStmt(sExpContext),
         LatteParser.StructAssContext structAssContext => new StructAss(structAssContext),
         LatteParser.StructDecrContext structDecrContext => new StructDecr(structDecrContext),
         LatteParser.StructIncrContext structIncrContext => new StructIncr(structIncrContext),
         LatteParser.VRetContext vRetContext => new Ret(vRetContext),
         LatteParser.WhileContext whileContext => new While(whileContext),
         _ => throw new ArgumentOutOfRangeException(nameof(context))
     });
Ejemplo n.º 3
0
 public StructIncr(LatteParser.StructIncrContext context)
 {
     IdExpr = Exprs.Utils.ExprFromExprContext(context.expr());
     Id     = context.ID().GetText();
 }