示例#1
0
        public static void TestWriter()
        {
            var instanceDB   = new InstanceDB();
            var simpleRecord = new SimpleRecord("IFCORGANIZATION", instanceDB);

            simpleRecord.ParameterList.Add(new ParamNullValue());
            simpleRecord.ParameterList.Add(new ParamString("Georgia Tech"));
            simpleRecord.ParameterList.Add(new ParamNullValue());
            simpleRecord.ParameterList.Add(new ParamNullValue());
            simpleRecord.ParameterList.Add(new ParamNullValue());
            var instanceSimple = new InstanceSimple(10);

            instanceSimple.Record = simpleRecord;
            instanceDB.DataList.Add(instanceSimple.EntityInstanceName, instanceSimple);
        }
示例#2
0
 public static void WriteSimpleRecord(SimpleRecord aRecord, BinaryWriter aBinaryWriter, InstanceDB DataSet)
 {
     //aBinaryWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
     aBinaryWriter.Write(aRecord.Keyword);
     //aBinaryWriter.Write(aRecord.GetKeyword(DataSet));
     //byte[] aTemp = BitConverter.GetBytes('(');
     aBinaryWriter.Write('(');
     for (int i = 0; i < aRecord.ParameterList.Count; i++)
     {
         if (i > 0)
         {
             aBinaryWriter.Write(',');
         }
         WriteParameter(aRecord.ParameterList[i], aBinaryWriter, DataSet);
     }
     aBinaryWriter.Write(')');
 }
示例#3
0
        SimpleRecord AddSimpleRecord(Instance cInstance, String EntityName)
        {
            SimpleRecord aRecord = new SimpleRecord(EntityName, this);
            Token        aToken  = Lexer.Tokenizer(DataStream);

            if (aToken.TokenTypeValue != TokenType.LEFTPARENTHESIS)
            {
                Console.WriteLine("Syntax error in parameter values ");
            }
            else
            {
                aToken = Lexer.Tokenizer(DataStream);
                while (aToken.TokenTypeValue != TokenType.RIGHTPARENTHESIS)
                {
                    aRecord.ParameterList.Add(AddParameterValue(cInstance, aToken));
                    aToken = Lexer.Tokenizer(DataStream);
                }
            }
            return(aRecord);
        }
示例#4
0
        public static void WriteSimpleRecord(SimpleRecord aRecord, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
        {
            if (IsDictionaryType)
            {
                strWriter.Write("@{0}", aRecord.IntKeyword.ToString());
            }
            else
            {
                //strWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
                strWriter.Write(aRecord.Keyword);
            }
            //byte[] aTemp = BitConverter.GetBytes('(');

            strWriter.Write('(');
            for (int i = 0; i < aRecord.ParameterList.Count; i++)
            {
                if (i > 0)
                {
                    strWriter.Write(',');
                }
                WriteParameter(aRecord.ParameterList[i], strWriter, DataSet, IsDictionaryType);
            }
            strWriter.Write(')');
        }
示例#5
0
 SimpleRecord AddSimpleRecord(Instance cInstance, String EntityName)
 {
     SimpleRecord aRecord = new SimpleRecord(EntityName, this);
     Token aToken = Lexer.Tokenizer(DataStream);
     if (aToken.TokenTypeValue != TokenType.LEFTPARENTHESIS)
     {
         Console.WriteLine("Syntax error in parameter values ");
     }
     else
     {
         aToken = Lexer.Tokenizer(DataStream);
         while (aToken.TokenTypeValue != TokenType.RIGHTPARENTHESIS)
         {
             aRecord.ParameterList.Add(AddParameterValue(cInstance, aToken));
             aToken = Lexer.Tokenizer(DataStream);
         }
     }
     return aRecord;
 }
示例#6
0
 public static void TestWriter()
 {
     var instanceDB = new InstanceDB();
     var simpleRecord = new SimpleRecord("IFCORGANIZATION", instanceDB);
     simpleRecord.ParameterList.Add(new ParamNullValue());
     simpleRecord.ParameterList.Add(new ParamString("Georgia Tech"));
     simpleRecord.ParameterList.Add(new ParamNullValue());
     simpleRecord.ParameterList.Add(new ParamNullValue());
     simpleRecord.ParameterList.Add(new ParamNullValue());
     var instanceSimple = new InstanceSimple(10);
     instanceSimple.Record = simpleRecord;
     instanceDB.DataList.Add(instanceSimple.EntityInstanceName, instanceSimple);
 }
示例#7
0
        public static void WriteSimpleRecord(SimpleRecord aRecord, StreamWriter strWriter, InstanceDB DataSet, bool IsDictionaryType)
        {
            if (IsDictionaryType)
            { strWriter.Write("@{0}", aRecord.IntKeyword.ToString()); }
            else
            {
                //strWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
                strWriter.Write(aRecord.Keyword);
            }
            //byte[] aTemp = BitConverter.GetBytes('(');

            strWriter.Write('(');
            for (int i = 0; i < aRecord.ParameterList.Count; i++)
            {
                if (i > 0)
                { strWriter.Write(','); }
                WriteParameter(aRecord.ParameterList[i], strWriter, DataSet, IsDictionaryType);
            }
            strWriter.Write(')');
        }
示例#8
0
        public static void WriteSimpleRecord(SimpleRecord aRecord, BinaryWriter aBinaryWriter, InstanceDB DataSet)
        {
            //aBinaryWriter.Write(DataSet.GetKeyword((int)aRecord.IntKeyword));
            aBinaryWriter.Write(aRecord.Keyword);
            //aBinaryWriter.Write(aRecord.GetKeyword(DataSet));
            //byte[] aTemp = BitConverter.GetBytes('(');
            aBinaryWriter.Write('(');
            for (int i = 0; i < aRecord.ParameterList.Count; i++)
            {
                if (i > 0)
                {

                    aBinaryWriter.Write(',');
                }
                WriteParameter(aRecord.ParameterList[i], aBinaryWriter, DataSet);
            }
            aBinaryWriter.Write(')');
        }
示例#9
0
        /// <summary>
        /// Process Token
        /// </summary>
        /// <param name="TokenToAdd"></param>
        /// <param name="InstanceData"></param>
        /// <param name="DataStream"></param>
        void ProcessToken(Token TokenToAdd)
        {
            switch (TokenToAdd.TokenTypeValue)
            {
            case TokenType.ISO1030321:
                Lexer.Tokenizer(DataStream);
                currStatus = ParserStatus.ISO;
                break;

            case TokenType.ISO1030321END:
                Lexer.Tokenizer(DataStream);
                currStatus = ParserStatus.READY;
                break;

            case TokenType.HEADER:
                Lexer.Tokenizer(DataStream);
                //InstanceData.aHeaderSection = new HeaderSection();
                currStatus = ParserStatus.HEADER;

                break;

            case TokenType.ENDSEC:
                Lexer.Tokenizer(DataStream);
                currStatus = ParserStatus.ISO;
                break;

            case TokenType.ENTITYINSTANCENAME:
                switch (currStatus)
                {
                case ParserStatus.DATA:
                    Token oneToken = Lexer.Tokenizer(DataStream);
                    if (oneToken.TokenTypeValue != TokenType.EQUAL)
                    {
                        Console.WriteLine("Syntax Error in Entity Instance : #" + TokenToAdd.IntegerValue.ToString());
                        return;
                    }
                    oneToken = Lexer.Tokenizer(DataStream);
                    if (oneToken.TokenTypeValue == TokenType.KEYWORD)
                    {
                        SortedDictionary <uint, Instance> toAdd = DataList;
                        if (toAdd.ContainsKey((uint)TokenToAdd.IntegerValue))
                        {
                            // when instance is already created by other caller
                            //P21Instance a =   toAdd[(uint)TokenToAdd.IntegerValue];
                            InstanceSimple aSimpleInstance = (InstanceSimple)toAdd[(uint)TokenToAdd.IntegerValue];
                            ModifySimpleInstanceRecord(aSimpleInstance, oneToken.StringValue);
                        }
                        else
                        {
                            // when it is the first time of parsing entity instance name #???
                            InstanceSimple aSimpleInstance = AddSimpleInstance((uint)TokenToAdd.IntegerValue, oneToken.StringValue);
                            toAdd.Add((uint)TokenToAdd.IntegerValue, aSimpleInstance);
                        }


                        // adding instances to instanceByType according to instance type
                        if (InstanceByType.ContainsKey(oneToken.StringValue))
                        {
                            List <uint> existingList = InstanceByType[oneToken.StringValue];
                            existingList.Add((uint)TokenToAdd.IntegerValue);
                        }
                        else
                        {
                            List <uint> newList = new List <uint>();
                            newList.Add((uint)TokenToAdd.IntegerValue);
                            InstanceByType.Add(oneToken.StringValue, newList);
                        }
                    }
                    else if (oneToken.TokenTypeValue == TokenType.LEFTPARENTHESIS)
                    {
                        // need update for complex type
                        SortedDictionary <uint, Instance> toAdd = DataList;
                        InstanceComplex aComplexInstance        = AddComplexInstance((uint)TokenToAdd.IntegerValue);
                        if (toAdd.ContainsKey((uint)TokenToAdd.IntegerValue))
                        {
                            toAdd[(uint)TokenToAdd.IntegerValue] = aComplexInstance;
                        }
                        else
                        {
                            toAdd.Add((uint)TokenToAdd.IntegerValue, aComplexInstance);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Syntax Error at value defintion in Entity Instance : #" + TokenToAdd.IntegerValue.ToString());
                        return;
                    }
                    break;

                default:
                    Console.WriteLine("Parser Error : Not defined parsing condition in Entity Instance Name : " + currStatus);
                    break;
                }
                break;

            case TokenType.KEYWORD:
                switch (currStatus)
                {
                case ParserStatus.HEADER:
                    SimpleRecord aSimpleRecord = AddSimpleRecord(null, TokenToAdd.StringValue);
                    HeaderList.Add(aSimpleRecord);

                    Lexer.Tokenizer(DataStream);         // cleans semicolon at the end of header instance
                    break;

                case ParserStatus.DATA:
                    Console.WriteLine("Syntax Error : Instance without Entity Instance Name");
                    break;

                default:
                    Console.WriteLine("Parser Error : Not defined parsing condition in Keyword");
                    break;
                }
                break;

            case TokenType.DATA:
                Lexer.Tokenizer(DataStream);
                currStatus = ParserStatus.DATA;

                //theDataSet.aDataSectionList.Add(new DataSection());


                break;

            default:
                Console.WriteLine("not defined condition : " + TokenToAdd.TokenTypeValue.ToString());
                break;
            }
        }