示例#1
0
 void MultExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     UnaryExpr(out arg1);
     expr = arg1;
     if (la.kind == 41 || la.kind == 42 || la.kind == 43)
     {
         if (la.kind == 41)
         {
             Get();
             UnaryExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Multi, arg1, arg2);
         }
         else if (la.kind == 42)
         {
             Get();
             UnaryExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Divide, arg1, arg2);
         }
         else
         {
             Get();
             UnaryExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Modulus, arg1, arg2);
         }
     }
 }
示例#2
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;
        }
    }
示例#3
0
 void BitExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     EqlExpr(out arg1);
     expr = arg1;
     if (la.kind == 28 || la.kind == 29 || la.kind == 30)
     {
         if (la.kind == 28)
         {
             Get();
             EqlExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.BitAnd, arg1, arg2);
         }
         else if (la.kind == 29)
         {
             Get();
             EqlExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.BitXor, arg1, arg2);
         }
         else
         {
             Get();
             EqlExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.BitOr, arg1, arg2);
         }
     }
 }
示例#4
0
 void RelExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     MinMaxExpr(out arg1);
     expr = arg1;
     if (StartOf(6))
     {
         if (la.kind == 33)
         {
             Get();
             MinMaxExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Larger, arg1, arg2);
         }
         else if (la.kind == 34)
         {
             Get();
             MinMaxExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.LargerEqual, arg1, arg2);
         }
         else if (la.kind == 35)
         {
             Get();
             MinMaxExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Smaller, arg1, arg2);
         }
         else
         {
             Get();
             MinMaxExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.SmallEqual, arg1, arg2);
         }
     }
 }
示例#5
0
    void UnaryExpr(out uppaal2c.Expression expr)
    {
        uppaal2c.Expression arg1 = null; expr = null;
        switch (la.kind)
        {
        case 1:
        case 2:
        case 3:
        case 5:
        case 6:
        case 47: {
            PostfixExpr(out arg1);
            expr = arg1;
            break;
        }

        case 39: {
            Get();
            PostfixExpr(out arg1);
            expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.UniPlus, arg1, null);
            break;
        }

        case 40: {
            Get();
            PostfixExpr(out arg1);
            expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.UniMinus, arg1, null);
            break;
        }

        case 44: {
            Get();
            PostfixExpr(out arg1);
            expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.UniPlusPlusPre, arg1, null);
            break;
        }

        case 45: {
            Get();
            PostfixExpr(out arg1);
            expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.UniMinusMinusPre, arg1, null);
            break;
        }

        case 46: {
            Get();
            UnaryExpr(out arg1);
            expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.LogicalNot, arg1, null);
            break;
        }

        default: SynErr(56); break;
        }
    }
示例#6
0
 void LogAndExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     BitExpr(out arg1);
     expr = arg1;
     if (la.kind == 27)
     {
         Get();
         BitExpr(out arg2);
         expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.LogicalAnd, arg1, arg2);
     }
 }
示例#7
0
 void LogWordOrExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     LogWordAndExpr(out arg1);
     expr = arg1;
     if (la.kind == 21)
     {
         Get();
         LogWordAndExpr(out arg2);
         expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.LogicalOr, arg1, arg2);
     }
 }
示例#8
0
 void ChanExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     Primary(out arg1);
     expr = arg1;
     if (la.kind == 11)
     {
         Get();
         Expression(out arg2);
         Expect(12);
         expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.ArrayIndex, arg1, arg2);
     }
 }
示例#9
0
 void CondExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null, arg3 = null;
     LogOrExpr(out arg1);
     expr = arg1;
     if (la.kind == 24)
     {
         Get();
         CondExpr(out arg2);
         Expect(25);
         CondExpr(out arg3);
         expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.IfThenElse, arg1, arg2, arg3);
     }
 }
示例#10
0
    void Primary(out uppaal2c.Expression expr)
    {
        uppaal2c.Expression arg1 = null; expr = null;
        switch (la.kind)
        {
        case 1: {
            Get();
            expr = new uppaal2c.Expression(t.val);
            break;
        }

        case 2: {
            Get();
            expr = new uppaal2c.Expression(Int32.Parse(t.val));
            break;
        }

        case 3: {
            Get();
            expr = new uppaal2c.Expression(Int32.Parse(t.val, NumberStyles.HexNumber));
            break;
        }

        case 5: {
            Get();
            expr = new uppaal2c.Expression(false);
            break;
        }

        case 6: {
            Get();
            expr = new uppaal2c.Expression(true);
            break;
        }

        case 47: {
            Get();
            Expression(out arg1);
            Expect(48);
            expr = arg1;
            break;
        }

        default: SynErr(57); break;
        }
    }
示例#11
0
 void ChanPriorityDecl()
 {
     uppaal2c.Expression expr = null;
     if (StartOf(3))
     {
         ChanExpr(out expr);
         decls.setChannelPriority(expr);
     }
     else if (la.kind == 49)
     {
         Get();
         decls.setChannelDefaultPriority();
     }
     else
     {
         SynErr(52);
     }
     while (la.kind == 10 || la.kind == 35)
     {
         if (la.kind == 10)
         {
             Get();
         }
         else
         {
             Get();
             decls.nextChannelPriority();
         }
         if (StartOf(3))
         {
             ChanExpr(out expr);
             decls.setChannelPriority(expr);
         }
         else if (la.kind == 49)
         {
             Get();
             decls.setChannelDefaultPriority();
         }
         else
         {
             SynErr(53);
         }
     }
 }
示例#12
0
 void PostfixExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     Primary(out arg1);
     expr = arg1;
     if (StartOf(7))
     {
         if (la.kind == 11)
         {
             Get();
             Expression(out arg2);
             Expect(12);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.ArrayIndex, arg1, arg2);
         }
         else if (la.kind == 47)
         {
             Get();
             List <uppaal2c.Expression> funcArgs = new List <uppaal2c.Expression>();
             if (StartOf(8))
             {
                 Expression(out arg2);
                 funcArgs.Add(arg2);
                 while (la.kind == 10)
                 {
                     Get();
                     Expression(out arg2);
                 }
                 funcArgs.Add(arg2);
             }
             Expect(48);
             expr = uppaal2c.Expression.CreateCustomFunc(arg1, funcArgs);
         }
         else if (la.kind == 44)
         {
             Get();
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.UniPlusPlusPost, arg1, null);
         }
         else
         {
             Get();
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.UniMinusMinusPost, arg1, null);
         }
     }
 }
示例#13
0
 void LogWordNotExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null; expr = null;
     if (la.kind == 23)
     {
         Get();
         CondExpr(out arg1);
         expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.LogicalNot, arg1);
     }
     else if (StartOf(5))
     {
         CondExpr(out arg1);
         expr = arg1;
     }
     else
     {
         SynErr(55);
     }
 }
示例#14
0
 void EqlExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     RelExpr(out arg1);
     expr = arg1;
     if (la.kind == 31 || la.kind == 32)
     {
         if (la.kind == 31)
         {
             Get();
             RelExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Equal, arg1, arg2);
         }
         else
         {
             Get();
             RelExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.NotEqual, arg1, arg2);
         }
     }
 }
示例#15
0
 void AddExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     MultExpr(out arg1);
     expr = arg1;
     if (la.kind == 39 || la.kind == 40)
     {
         if (la.kind == 39)
         {
             Get();
             MultExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.BinPlus, arg1, arg2);
         }
         else
         {
             Get();
             MultExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.BinMinus, arg1, arg2);
         }
     }
 }
示例#16
0
 void MinMaxExpr(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null, arg2 = null;
     AddExpr(out arg1);
     expr = arg1;
     if (la.kind == 37 || la.kind == 38)
     {
         if (la.kind == 37)
         {
             Get();
             AddExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Min, arg1, arg2);
         }
         else
         {
             Get();
             AddExpr(out arg2);
             expr = new uppaal2c.Expression(uppaal2c.Expression.Funcs.Max, arg1, arg2);
         }
     }
 }
示例#17
0
 void Expression(out uppaal2c.Expression expr)
 {
     uppaal2c.Expression arg1 = null;
     LogWordOrExpr(out arg1);
     expr = arg1;
 }
示例#18
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);
     }
 }