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 Exception(String.Format("Cannot use non const variable!")); } app(" {0}({1}),", name, val); }
void TypeDecl(out model2mbed.TypeDecl data) { data = new model2mbed.TypeDecl(); string tname; model2mbed.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 = model2mbed.VarType.Int; } else if (la.kind == 19) { Get(); data.Type = model2mbed.VarType.Int; } else if (la.kind == 20) { Get(); data.Type = model2mbed.VarType.Clock; } else if (la.kind == 8) { Get(); data.Type = model2mbed.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 model2mbed.ParseException("Array ranges must evaluate to consts!"); } data.SetRange(low, high); } }