Example #1
0
    void VarNameDecl(uppaal2c.TypeDecl type)
    {
        string name; uppaal2c.Expression arg1 = null, arg2 = null;

        Ident(out name);
        uppaal2c.VarDecl vardecl = new uppaal2c.VarDecl(name, type); decls.Add(vardecl);
        if (la.kind == 11)
        {
            Get();
            Expression(out arg1);
            Expect(12);
            int low = 0, length = 0;
            if (!decls.getArrSizeValue(arg1, out low, out length))
            {
                throw new FatalError("Could not calculate array size!");
            }
            vardecl.IsArray   = true;
            vardecl.ArrLow    = low;
            vardecl.ArrLength = length;
        }
        if (la.kind == 13)
        {
            Get();
            Expression(out arg2);
            vardecl.Expr = arg2; vardecl.HasExpr = true;
        }
    }
Example #2
0
 public VarDecl(string name, TypeDecl type)
 {
     Name      = name;
     Type      = type;
     IsArray   = false;
     ArrLow    = 0;
     ArrLength = 0;
     HasExpr   = false;
     Expr      = null;
 }
        public TypeDecl normalizeType(TypeDecl decl, string name)
        {
            TypedefDecl exists = getTypeDef(name);

            if (exists == null)
            {
                throw new ParseException("Invalid type " + name);
            }

            decl.merge(exists.Type);

            return(decl);
        }
Example #4
0
        public void merge(TypeDecl typedef)
        {
            Type = typedef.Type;
            if (typedef.Const)
            {
                Const = true;
            }
            if (typedef.Urgent)
            {
                Urgent = true;
            }
            if (typedef.Broadcast)
            {
                Broadcast = true;
            }

            sanitizeFlags();
        }
Example #5
0
 void TypeDecl(out uppaal2c.TypeDecl data)
 {
     data = new uppaal2c.TypeDecl(); string tname; uppaal2c.Expression arg1 = null, arg2 = null;
     while (StartOf(4))
     {
         if (la.kind == 14)
         {
             Get();
             data.Const = true;
         }
         else if (la.kind == 15)
         {
             Get();
             data.Urgent = true;
         }
         else if (la.kind == 16)
         {
             Get();
             data.Broadcast = true;
         }
         else
         {
             Get();
         }
     }
     if (la.kind == 18)
     {
         Get();
         data.Type = uppaal2c.VarType.Int;
     }
     else if (la.kind == 19)
     {
         Get();
         data.Type = uppaal2c.VarType.Int;
     }
     else if (la.kind == 20)
     {
         Get();
         data.Type = uppaal2c.VarType.Clock;
     }
     else if (la.kind == 8)
     {
         Get();
         data.Type = uppaal2c.VarType.Channel;
     }
     else if (la.kind == 1)
     {
         Ident(out tname);
         data = decls.normalizeType(data, tname);
     }
     else
     {
         SynErr(54);
     }
     if (la.kind == 11)
     {
         Get();
         Expression(out arg1);
         Expect(10);
         Expression(out arg2);
         Expect(12);
         int low, high;
         if (!decls.getExprValue(arg1, out low) || !decls.getExprValue(arg2, out high))
         {
             throw new uppaal2c.ParseException("Array ranges must evaluate to consts!");
         }
         data.SetRange(low, high);
     }
 }