コード例 #1
0
ファイル: StateMachine.cs プロジェクト: thomas13335/smg
        /// <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;
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: thomas13335/smg
        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.");
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: thomas13335/smg
 void VariableDefinition(StateType stype)
 {
     string name;
     Identifier(out name);
     SM.AddVariable(name, stype);
 }
コード例 #4
0
ファイル: Variable.cs プロジェクト: thomas13335/smg
 public Variable(string id, StateType decl)
 {
     Name = id;
     Type = decl;
     // InitialCondition = new StateCondition(this, 0);
 }