Beispiel #1
0
        private void FormatSingleVarInitialization(VarDecl vd, Declarations decl)
        {
            string name = getUniqueName(vd);

            if (!vd.HasExpr)
            {
                return;
            }

            int val;

            if (!decl.getExprValue(vd.Expr, out val))
            {
                throw new CodeGenException(String.Format("Cannot use non const variable!"));
            }

            app("\t{0}.{1} = {2};", StateStructName, name, val);
        }
Beispiel #2
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);
     }
 }