Example #1
0
        private SToken ProcessSuperSub(SToken oneToken, SEntity aEntity)
        {
            if (oneToken.TokenType == STokenType.ABSTRACT)
            {
                aEntity.IsAbstract = true;
                //get new token for next step
                oneToken = SLexer.Tokenizer(_dataStream);
            }

            if (oneToken.TokenType == STokenType.SUPERTYPE)
            {   // remove OF token after supertype token
                oneToken = SLexer.Tokenizer(_dataStream);
                ProcessSupertypeOf(aEntity);
                //get new token for next step
                oneToken = SLexer.Tokenizer(_dataStream);
            }

            if (oneToken.TokenType == STokenType.SUBTYPE)
            {   // remove of token after supertype token
                oneToken = SLexer.Tokenizer(_dataStream);
                ProcessSubtypeOf(aEntity);
                //get new token for next step
                oneToken = SLexer.Tokenizer(_dataStream);
            }

            return SLexer.Tokenizer(_dataStream);
        }
Example #2
0
        private SType ProcessTypeSub(SToken oneToken)
        {
            SType ret;
            string t_TypeName = oneToken.StringValue;

            // tokenlist for syntax checking
            List<SToken> tokenList = new List<SToken>();

            oneToken = SLexer.Tokenizer(_dataStream);
            #region switch
            switch (oneToken.TokenType)
            {
                case STokenType.BOOLEAN:
                case STokenType.REAL:
                case STokenType.INTEGER:
                case STokenType.LOGICAL:
                case STokenType.NUMBER:
                    ret = new SType(t_TypeName, SParameter.TokenTypeToAttribType(oneToken.TokenType));
                    CleanUpSemiColon();
                    break;
                case STokenType.STRING:
                    ret = new STypeString(t_TypeName);
                    ret.Kind = SParameter.TokenTypeToAttribType(oneToken.TokenType);
                    oneToken = SLexer.Tokenizer(_dataStream);
                    if (oneToken.TokenType == STokenType.LEFTPARENTHESIS)
                    {
                        // process width
                        oneToken = SLexer.Tokenizer(_dataStream);

                        ((STypeString)ret).StringLength = (short)oneToken.IntegerValue;
                        oneToken = SLexer.Tokenizer(_dataStream); // right parenthesis
                        oneToken = SLexer.Tokenizer(_dataStream);

                        if (oneToken.TokenType == STokenType.FIXED)
                        {
                            // process fixed
                            ((STypeString)ret).IsFixed = true;
                            // semicolon
                            oneToken = SLexer.Tokenizer(_dataStream);
                        }
                    }

                    break;
                case STokenType.SIMPLEID:
                    ret = new STypeSimple(t_TypeName, oneToken.StringValue);
                    ret.Kind = SParameter.TokenTypeToAttribType(oneToken.TokenType);
                    CleanUpSemiColon();
                    break;
                case STokenType.ARRAY:
                case STokenType.LIST:
                case STokenType.SET:
                case STokenType.BAG:
                    ret = new STypeCollection(t_TypeName, oneToken.TokenType);
                    ret.Kind = SParameter.TokenTypeToAttribType(oneToken.TokenType);
                    collection((STypeCollection)ret);
                    break;
                case STokenType.ENUMERATION:
                    ret = new STypeEnum(t_TypeName);
                    ret.Kind = SParameter.TokenTypeToAttribType(oneToken.TokenType);
                    oneToken = SLexer.Tokenizer(_dataStream);
                    if (oneToken.TokenType != STokenType.OF)
                    { throw new Exception("Syntax error in Schema Name Definition"); }

                    GetInsideSingleParenthesis(tokenList);
                    foreach (SToken aToken in tokenList)
                    {
                        if (aToken.TokenType == STokenType.SIMPLEID)
                        { ((STypeEnum)ret).EnumList.Add(aToken.StringValue); }
                        else
                        { throw new Exception("Syntax error in Enumeration Type Definition : " + ret.Name); }
                    }
                    CleanUpSemiColon();
                    break;
                case STokenType.SELECT:
                    ret = new STypeSelect(t_TypeName);
                    ret.Kind = SParameter.TokenTypeToAttribType(oneToken.TokenType);
                    GetInsideSingleParenthesis(tokenList);
                    foreach (SToken aToken in tokenList)
                    {
                        if (aToken.TokenType == STokenType.SIMPLEID)
                        {
                            ((STypeSelect)ret).SelectList.Add(aToken.StringValue, null);
                        }
                        else
                        { throw new Exception("Syntax error in Select Type Definition : " + ret.Name); }
                    }

                    CleanUpSemiColon();

                    break;

                default:
                    ret = null;
                    if (_logFile != null)
                        _logFile.WriteLine(oneToken.TokenType.ToString() + " : " + oneToken.StringValue);
                    break;
            }
            #endregion // switch
            return ret;
        }
Example #3
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);
        }
Example #4
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);
            }
        }
Example #5
0
 private void IgnoredToken(SToken aToken)
 {
     aToken.StringValue = string.Format("Unprocessed {0} at Row {1}, Column {2} with String Value '{3}'",
         aToken.TokenType.ToString(), SLexer.CurrentRow, SLexer.CurrentColumn, aToken.StringValue);
     _mIgnoredToken.Add(aToken);
 }
Example #6
0
 short getBound(SToken token)
 {
     short ret;
     if (token.TokenType == STokenType.INTEGER)
     { ret = (short)token.IntegerValue; }
     else if (token.TokenType == STokenType.QUESTIONMARK)
     { ret = -2; }
     else if (token.TokenType == STokenType.SIMPLEID)
     { ret = -3; }
     else
     {
         ret = -4;
         //throw new Exception("Syntax error");
     }
     return ret;
 }
Example #7
0
        public static SToken ProcessUpper(int FirstCharactor, StreamReader DataStream)
        {
            StringBuilder theString = new StringBuilder();
            SToken aToken;
            theString.Append((char)FirstCharactor);

            int peekedChar;
            while (((peekedChar = DataStream.Peek()) >= 65 && peekedChar <= 90)
                || (peekedChar >= 48 && peekedChar <= 57) || peekedChar == 45 || peekedChar == 95
                || (peekedChar >= 97 && peekedChar <= 122))
            {
                theString.Append((char)DataStream.Read());
                CurrentColumn += 1;
            }
            //Console.WriteLine(theString);
            //AddKeywordToken(theString.ToString());

            switch (theString.ToString())
            {
                case @"SCHEMA":
                    aToken = new SToken(STokenType.SCHEMA);
                    break;
                case @"ENTITY":
                    aToken = new SToken(STokenType.ENTITY);
                    break;
                case @"END_ENTITY":
                    aToken = new SToken(STokenType.END_ENTITY);
                    break;
                case @"TYPE":
                    aToken = new SToken(STokenType.TYPE);
                    break;
                case @"END_TYPE":
                    aToken = new SToken(STokenType.END_TYPE);
                    break;
                case @"ABSTRACT":
                    aToken = new SToken(STokenType.ABSTRACT);
                    break;
                case @"SUPERTYPE":
                    aToken = new SToken(STokenType.SUPERTYPE);
                    break;
                case @"SUBTYPE":
                    aToken = new SToken(STokenType.SUBTYPE);
                    break;
                case @"OF":
                    aToken = new SToken(STokenType.OF);
                    break;
                case @"ONEOF":
                    aToken = new SToken(STokenType.ONEOF);
                    break;
                case @"OPTIONAL":
                    aToken = new SToken(STokenType.OPTIONAL);
                    break;
                case @"INTEGER":
                    aToken = new SToken(STokenType.INTEGER);
                    break;
                case @"REAL":
                    aToken = new SToken(STokenType.REAL);
                    break;
                case @"STRING":
                    aToken = new SToken(STokenType.STRING);
                    break;
                case @"BOOLEAN":
                    aToken = new SToken(STokenType.BOOLEAN);
                    break;
                case @"LOGICAL":
                    aToken = new SToken(STokenType.LOGICAL);
                    break;
                case @"NUMBER":
                    aToken = new SToken(STokenType.NUMBER);
                    break;
                case @"ENUMERATION":
                    aToken = new SToken(STokenType.ENUMERATION);
                    break;
                case @"SELECT":
                    aToken = new SToken(STokenType.SELECT);
                    break;
                case @"ARRAY":
                    aToken = new SToken(STokenType.ARRAY);
                    break;
                case @"LIST":
                    aToken = new SToken(STokenType.LIST);
                    break;
                case @"SET":
                    aToken = new SToken(STokenType.SET);
                    break;
                case @"BAG":
                    aToken = new SToken(STokenType.BAG);
                    break;
                case @"WHERE":
                    aToken = new SToken(STokenType.WHERE);
                    break;
                case @"DERIVE":
                    aToken = new SToken(STokenType.DERIVE);
                    break;
                case @"INVERSE":
                    aToken = new SToken(STokenType.INVERSE);
                    break;
                case @"FIXED":
                    aToken = new SToken(STokenType.FIXED);
                    break;
                case @"SELF":
                    aToken = new SToken(STokenType.SELF);
                    break;
                case @"UNIQUE":
                    aToken = new SToken(STokenType.UNIQUE);
                    break;
                case @"FUNCTION":
                    aToken = new SToken(STokenType.FUNCTION);
                    break;
                case @"END_FUNCTION":
                    aToken = new SToken(STokenType.END_FUNCTION);
                    break;
                case @"RULE":
                    aToken = new SToken(STokenType.RULE);
                    break;
                case @"END_RULE":
                    aToken = new SToken(STokenType.END_RULE);
                    break;
                case @"END_SCHEMA":
                    aToken = new SToken(STokenType.END_SCHEMA);
                    break;
                default:
                    aToken = new SToken(theString.ToString());
                    break;
            }
            return aToken;
        }