/// <summary> /// Adds a new variable to the state machine. /// </summary> /// <param name="id">The identifier of the variable.</param> /// <param name="declaration">The state type.</param> /// <returns>The resulting variable object.</returns> public Variable AddVariable(string id, StateType declaration) { if(_variables.ContainsKey(id)) { throw new CompilerException(ErrorCode.VariableRedefinition, "variable '" + id + "' already exists."); } var result = new Variable(id, declaration); result.Index = _variables.Count; result.Address = _nextaddress; _nextaddress += result.Cardinality; _variables.Add(id, result); return result; }
void TypeReference(out StateType stype) { stype = null; string name; Identifier(out name); stype = SM.GetStateType(name); if (la.kind == 29) { Get(); if(null != stype) throw new CompilerException(ErrorCode.TypeRedefinition, "type '" + name + "' is already defined."); stype = SM.AddSimpleType(name); IdList list; IdentifierList(out list); stype.AddStateNames(list); Expect(30); stype.Freeze(); } if(null == stype) throw new CompilerException(ErrorCode.UndefinedType, "type '" + name + "' is undefined."); }
void VariableDefinition(StateType stype) { string name; Identifier(out name); SM.AddVariable(name, stype); }
public Variable(string id, StateType decl) { Name = id; Type = decl; // InitialCondition = new StateCondition(this, 0); }