Esempio n. 1
0
 /// <summary>
 /// Called by updateFlatList, recursive function to add all supertypes of entity
 /// </summary>
 /// <param name="sEntity">entity to start from</param>
 /// <param name="hierarchyStack">hierarcy stack to contain supertypes of base entity</param>
 private void recurseSuper(SEntity sEntity, Stack <SEntity> hierarchyStack)
 {
     foreach (SEntity aEntity in sEntity.SubTypesOf)
     {
         hierarchyStack.Push(aEntity);
         if (aEntity.SubTypesOf.Count > 0)
         {
             recurseSuper(aEntity, hierarchyStack);
         }
     }
 }
Esempio n. 2
0
        private SEntity getEntity(string SimpleID)
        {
            SEntity aEntity;

            if (SchemaSet.EntityList.ContainsKey(SimpleID))
            {
                aEntity = SchemaSet.EntityList[SimpleID];
            }
            else
            {
                aEntity = new SEntity(SimpleID);
                SchemaSet.EntityList.Add(SimpleID, aEntity);
            }
            return(aEntity);
        }
Esempio n. 3
0
        private void ProcessAttribute(
            SEntity oneEntity,
            string AttributeName)
        {
            SAttribute satt     = new SAttribute(AttributeName);
            SToken     oneToken = SLexer.Tokenizer(_dataStream);

            if (oneToken.TokenType != STokenType.COLON)
            {
                throw new Exception("Error in attribute : " + SLexer.CurrentRow + " : " + SLexer.CurrentColumn);
            }

            satt.Type = ProcessParameter();
            oneEntity.ParameterList.Add(satt);
        }
Esempio n. 4
0
        private void ProcessInverse(SEntity sEntity, SToken sToken)
        {
            SAttributeInverse sAttributeInverse = new SAttributeInverse(sToken.StringValue);
            SToken            oneToken          = SLexer.Tokenizer(_dataStream);

            if (oneToken.TokenType != STokenType.COLON)
            {
                throw new Exception("Error in inverse attribute : " + SLexer.CurrentRow + " : " + SLexer.CurrentColumn);
            }

            sAttributeInverse.Type = ProcessInverseParameter();
            oneToken = SLexer.Tokenizer(_dataStream);
            // referencing entity's attribute name
            oneToken = SLexer.Tokenizer(_dataStream);
            sAttributeInverse.InversingAttributeName = oneToken.StringValue;
            sEntity.InverseList.Add(sAttributeInverse);
            // semi colon
            oneToken = SLexer.Tokenizer(_dataStream);
        }
Esempio n. 5
0
        private void ProcessSupertypeOf(SEntity aEntity)
        {
            //319 supertype_constraint = abstract_entity_declaration |
            //    abstract_supertype_declaration | supertype_rule .
            //164 abstract_entity_declaration = ABSTRACT .
            //166 abstract_supertype_declaration = ABSTRACT SUPERTYPE [ subtype_constraint ] .
            //313 subtype_constraint = OF ’(’ supertype_expression ’)’ .
            //320 supertype_expression = supertype_factor { ANDOR supertype_factor } .
            //321 supertype_factor = supertype_term { AND supertype_term } .
            //323 supertype_term = entity_ref | one_of | ’(’ supertype_expression ’)’ .
            //263 one_of = ONEOF ’(’ supertype_expression { ’,’ supertype_expression } ’)’ .
            //322 supertype_rule = SUPERTYPE subtype_constraint .


            int parenthesisCounter = 0;

            SToken oneToken = SLexer.Tokenizer(_dataStream);

            if (oneToken.TokenType != STokenType.LEFTPARENTHESIS)
            {
                throw new Exception("Syntax Error : Supertype Definition (");
            }
            else
            {
                parenthesisCounter += 1;
            }


            while (parenthesisCounter != 0)
            {
                oneToken = SLexer.Tokenizer(_dataStream);

                switch (oneToken.TokenType)
                {
                case STokenType.LEFTPARENTHESIS:
                    parenthesisCounter += 1;
                    break;

                case STokenType.RIGHTPARENTHESIS:
                    parenthesisCounter -= 1;
                    break;

                case STokenType.ONEOF:
                case STokenType.COMMA:
                    break;

                case STokenType.SIMPLEID:
                    aEntity.SuperTypesOf.Add(getEntity(oneToken.StringValue));
                    break;

                default:
                    string logout = String.Format("Undefined supertype definition at row : {0}, column : {1}",
                                                  SLexer.CurrentRow,
                                                  SLexer.CurrentColumn);
                    if (_logFile != null)
                    {
                        _logFile.WriteLine(logout);
                    }
                    break;
                }
            }

            //if (oneToken.TokenType != SchemaTokenType.ONEOF)
            //    throw new Exception("Syntax Error : Supertype Definition oneof");

            //oneToken = SchemaLexer.Tokenizer(DataStream);

            //if (oneToken.TokenType != SchemaTokenType.LEFTPARENTHESIS)
            //    throw new Exception("Syntax Error : Supertype Definition (2");

            //oneToken = SchemaLexer.Tokenizer(DataStream);

            //if (oneToken.TokenType != SchemaTokenType.SIMPLEID)
            //    throw new Exception("Syntax Error : Supertype Definition simpleId");

            //aEntity.SuperTypesOf.Add(getEntity(oneToken.StringValue));

            //oneToken = SchemaLexer.Tokenizer(DataStream);

            //while (oneToken.TokenType != SchemaTokenType.RIGHTPARENTHESIS)
            //{
            //    if (oneToken.TokenType != SchemaTokenType.COMMA)
            //        throw new Exception("Syntax Error : Supertype Definition ,");
            //    oneToken = SchemaLexer.Tokenizer(DataStream);
            //    if (oneToken.TokenType != SchemaTokenType.SIMPLEID)
            //        throw new Exception("Syntax Error : Supertype Definition simpleid2");
            //    aEntity.SuperTypesOf.Add(getEntity(oneToken.StringValue));
            //    oneToken = SchemaLexer.Tokenizer(DataStream);
            //}
            //// for second parenthesis
            //oneToken = SchemaLexer.Tokenizer(DataStream);
        }
Esempio n. 6
0
        /// <summary>
        /// not a complete derive implementation
        /// intended to identify omitted value in instance population
        /// </summary>
        /// <param name="oneEntity"></param>
        /// <param name="AttributeName"></param>
        private void ProcessDerivedAttribute(
            SEntity oneEntity,
            SToken mToken)
        {
            SAttributeDerived drvAtt;

            //SParam sParam;

            if (mToken.TokenType == STokenType.SELF)
            {
                //drvAtt = new SAttributeDerived(AttribType.DERIVED);
                // defines self drived attribute

                // reverse_solidus
                mToken = SLexer.Tokenizer(_dataStream);

                // super entity
                mToken = SLexer.Tokenizer(_dataStream);
                if (mToken.TokenType != STokenType.SIMPLEID)
                {
                    throw new InvalidDataException(string.Format(
                                                       "schema is not in syntax at {0} : {1}",
                                                       oneEntity.Name, mToken.TokenType.ToString()));
                }

                string orgSuperTypeName = mToken.StringValue;

                // period
                mToken = SLexer.Tokenizer(_dataStream);
                // attribute name
                mToken = SLexer.Tokenizer(_dataStream);

                string sAttName = mToken.StringValue;

                drvAtt = new SAttributeDerived(sAttName);
                drvAtt.OriginatingSuperType = orgSuperTypeName;
                drvAtt.Name        = sAttName;
                drvAtt.isInherited = true;

                // colon
                mToken      = SLexer.Tokenizer(_dataStream);
                drvAtt.Type = ProcessParameter();
                oneEntity.DerivedList.Add(drvAtt);
            }
            else //if (mToken.TokenType == SchemaTokenType.SIMPLEID)
            {
                string sAttName = mToken.StringValue;

                drvAtt             = new SAttributeDerived(sAttName);
                drvAtt.Name        = sAttName;
                drvAtt.isInherited = false;

                mToken = SLexer.Tokenizer(_dataStream);

                drvAtt.Type = ProcessParameter();
                oneEntity.DerivedList.Add(drvAtt);
            }

            //mToken = SLexer.Tokenizer(DataStream);
            //oneEntity.AttributeList.Add(oneAttribute);
            while (mToken.TokenType != STokenType.SEMICOLON)
            {
                mToken = SLexer.Tokenizer(_dataStream);
            }
        }
Esempio n. 7
0
        private void ProcessEntity()
        {
            SToken oneToken = SLexer.Tokenizer(_dataStream);

            if (oneToken.TokenType != STokenType.SIMPLEID)
            {
                throw new Exception("Syntax error in Entity Definition");
            }

            SEntity aEntity = getEntity(oneToken.StringValue);

            oneToken = SLexer.Tokenizer(_dataStream);
            if (oneToken.TokenType == STokenType.SEMICOLON)
            {   //get new token for next step
                oneToken = SLexer.Tokenizer(_dataStream);
            }

            if (oneToken.TokenType == STokenType.ABSTRACT ||
                oneToken.TokenType == STokenType.SUPERTYPE ||
                oneToken.TokenType == STokenType.SUBTYPE)
            {
                oneToken = ProcessSuperSub(oneToken, aEntity);
            }

            if (oneToken.TokenType == STokenType.SIMPLEID)
            {
                while (oneToken.TokenType == STokenType.SIMPLEID)
                {
                    ProcessAttribute(aEntity, oneToken.StringValue);
                    oneToken = SLexer.Tokenizer(_dataStream);
                }
            }

            if (oneToken.TokenType == STokenType.DERIVE)
            {
                // oneToken = DummySubLoop();
                // next one after derived
                oneToken = SLexer.Tokenizer(_dataStream);

                while (oneToken.TokenType == STokenType.SIMPLEID || oneToken.TokenType == STokenType.SELF)
                {
                    ProcessDerivedAttribute(aEntity, oneToken);
                    oneToken = SLexer.Tokenizer(_dataStream);
                }
            }

            if (oneToken.TokenType == STokenType.INVERSE)
            {
                //oneToken = DummySubLoop();
                oneToken = SLexer.Tokenizer(_dataStream);

                while (oneToken.TokenType == STokenType.SIMPLEID)
                {
                    ProcessInverse(aEntity, oneToken);
                    oneToken = SLexer.Tokenizer(_dataStream);
                }
            }

            if (oneToken.TokenType == STokenType.UNIQUE)
            {
                oneToken = DummySubLoop();
            }

            if (oneToken.TokenType == STokenType.UNDEFINED)
            {
                oneToken = DummySubLoop();
            }

            if (oneToken.TokenType == STokenType.WHERE)
            {
                oneToken = DummySubLoop();
            }

            if (oneToken.TokenType == STokenType.END_ENTITY)
            {
                oneToken = SLexer.Tokenizer(_dataStream); // semi colon
            }
        }