Ejemplo n.º 1
0
        private void collection(STypeCollection sTypeCol)
        {
            // Left brackett
            SToken oneToken = SLexer.Tokenizer(_dataStream);

            // lbound
            oneToken        = SLexer.Tokenizer(_dataStream);
            sTypeCol.LBound = getBound(oneToken);
            oneToken        = SLexer.Tokenizer(_dataStream);
            oneToken        = SLexer.Tokenizer(_dataStream);
            sTypeCol.UBound = getBound(oneToken);
            // right bracket
            oneToken = SLexer.Tokenizer(_dataStream);
            // of
            oneToken = SLexer.Tokenizer(_dataStream);
            // type
            oneToken = SLexer.Tokenizer(_dataStream);
            SParamType sp = SParameter.TokenTypeToAttribType(oneToken.TokenType);

            switch (oneToken.TokenType)
            {
            case STokenType.BOOLEAN:
            case STokenType.REAL:
            case STokenType.INTEGER:
            case STokenType.LOGICAL:
            case STokenType.NUMBER:
            case STokenType.STRING:
            case STokenType.ARRAY:
            case STokenType.LIST:
            case STokenType.SET:
            case STokenType.BAG:
                sTypeCol.CollectionType = sp;
                sTypeCol.CollectionName = SParameter.TypeToString(sp);
                break;

            case STokenType.SIMPLEID:
                sTypeCol.CollectionName = oneToken.StringValue;
                break;

            default:
                if (_logFile != null)
                {
                    _logFile.WriteLine(oneToken.TokenType.ToString() + " : " + oneToken.StringValue);
                }
                break;
            }
        }
Ejemplo n.º 2
0
        private SParameter ProcessParameter()
        {
            SToken oneToken = SLexer.Tokenizer(_dataStream);
            bool isOptional = false;

            if (oneToken.TokenType == STokenType.OPTIONAL)
            {
                oneToken = SLexer.Tokenizer(_dataStream);
                isOptional = true;
            }

            bool isUnique = false;
            if (oneToken.TokenType == STokenType.UNIQUE)
            {
                isUnique = true;
                oneToken = SLexer.Tokenizer(_dataStream);
            }

            SParamType stype = SParameter.TokenTypeToAttribType(oneToken.TokenType);

            SParameter sParam;

            if (stype == SParamType.SET ||
                stype == SParamType.LIST ||
                stype == SParamType.ARRAY ||
                stype == SParamType.BAG)
            {
                sParam = new SParamCollection(stype);
                var sParamCol = sParam as SParamCollection;
                // get leftbracket
                oneToken = SLexer.Tokenizer(_dataStream);

                // after adding lower bound, upper bound lexer
                oneToken = SLexer.Tokenizer(_dataStream);
                sParamCol.LBound = getBound(oneToken);

                // get colon
                oneToken = SLexer.Tokenizer(_dataStream);
                // get upper bound
                oneToken = SLexer.Tokenizer(_dataStream);
                sParamCol.UBound = getBound(oneToken);

                // get rightbracket
                oneToken = SLexer.Tokenizer(_dataStream);
                // get of
                oneToken = SLexer.Tokenizer(_dataStream);
                sParamCol.ParamReference = ProcessParameter();
            }
            else if (stype == SParamType.NAMED)
            { sParam = new SParamNamed(oneToken.StringValue); }
            else
            { sParam = new SParameter(stype); }

            sParam.IsUnique = isUnique;
            sParam.IsOptional = isOptional;

            // either semi colon or left parenthesis
            //oneToken = SLexer.Tokenizer(DataStream);
            if (!(sParam is SParamCollection))
            {
                oneToken = SLexer.Tokenizer(_dataStream);
                if (oneToken.TokenType == STokenType.LEFTPARENTHESIS)
                {
                    oneToken = SLexer.Tokenizer(_dataStream); // integer
                    // add integer
                    sParam.TypeLength = (short)oneToken.IntegerValue;
                    oneToken = SLexer.Tokenizer(_dataStream); // right parenthesis
                    oneToken = SLexer.Tokenizer(_dataStream);
                    if (oneToken.TokenType == STokenType.FIXED)
                    {
                        // process fixed
                        sParam.IsFixed = true;
                        // semicolon
                        oneToken = SLexer.Tokenizer(_dataStream);
                    }
                }
            }

            //SAttribute oneAttribute = new SAttribute(AttributeName, sParam);

            return sParam;
        }
Ejemplo n.º 3
0
 public override string ToString()
 {
     return(string.Format("{0}:{1}", Name, SParameter.TypeToString(Kind)));
 }
Ejemplo n.º 4
0
 public STypeCollection(string TypeName, STokenType DataType)
     : base(TypeName)
 {
     this.Kind = SParameter.TokenTypeToAttribType(DataType);
 }
Ejemplo n.º 5
0
 public SAttributeDerived(string Name, SParameter Type)
     : base(Name, Type)
 {
 }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        private SParameter ProcessInverseParameter()
        {
            SToken oneToken   = SLexer.Tokenizer(_dataStream);
            bool   isOptional = false;

            if (oneToken.TokenType == STokenType.OPTIONAL)
            {
                oneToken   = SLexer.Tokenizer(_dataStream);
                isOptional = true;
            }

            bool isUnique = false;

            if (oneToken.TokenType == STokenType.UNIQUE)
            {
                isUnique = true;
                oneToken = SLexer.Tokenizer(_dataStream);
            }

            SParamType stype = SParameter.TokenTypeToAttribType(oneToken.TokenType);

            SParameter sParam;

            if (stype == SParamType.SET ||
                stype == SParamType.LIST ||
                stype == SParamType.ARRAY ||
                stype == SParamType.BAG)
            {
                sParam = new SParamCollection(stype);
                var sParamCol = sParam as SParamCollection;
                // get leftbracket
                oneToken = SLexer.Tokenizer(_dataStream);

                // after adding lower bound, upper bound lexer
                oneToken         = SLexer.Tokenizer(_dataStream);
                sParamCol.LBound = getBound(oneToken);

                // get colon
                oneToken = SLexer.Tokenizer(_dataStream);
                // get upper bound
                oneToken         = SLexer.Tokenizer(_dataStream);
                sParamCol.UBound = getBound(oneToken);

                // get rightbracket
                oneToken = SLexer.Tokenizer(_dataStream);
                // get of
                oneToken = SLexer.Tokenizer(_dataStream);
                sParamCol.ParamReference = ProcessInverseParameter();
            }
            else if (stype == SParamType.NAMED)
            {
                sParam = new SParamNamed(oneToken.StringValue);
            }
            else
            {
                sParam = new SParameter(stype);
            }

            sParam.IsUnique   = isUnique;
            sParam.IsOptional = isOptional;


            // either semi colon or left parenthesis
            //oneToken = SLexer.Tokenizer(DataStream);
            //if (!(sParam is SParamCollection))
            //{
            //    oneToken = SLexer.Tokenizer(_dataStream);
            //    if (oneToken.TokenType == STokenType.LEFTPARENTHESIS)
            //    {
            //        oneToken = SLexer.Tokenizer(_dataStream); // integer
            //        // add integer
            //        sParam.TypeLength = (short)oneToken.IntegerValue;
            //        oneToken = SLexer.Tokenizer(_dataStream); // right parenthesis
            //        oneToken = SLexer.Tokenizer(_dataStream);
            //        if (oneToken.TokenType == STokenType.FIXED)
            //        {
            //            // process fixed
            //            sParam.IsFixed = true;
            //            // semicolon
            //            oneToken = SLexer.Tokenizer(_dataStream);
            //        }
            //    }
            //}



            //SAttribute oneAttribute = new SAttribute(AttributeName, sParam);

            return(sParam);
        }
Ejemplo n.º 8
0
 public SAttribute(string Name, SParameter Type)
 {
     this.Name = Name;
     this.Type = Type;
 }
Ejemplo n.º 9
0
        //public SEntity ReferencingEntity { get; set; }


        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        public SAttributeInverse(string name, SParameter type) : base(name, type)
        {
        }
Ejemplo n.º 10
0
 public SAttribute(string Name, SParameter Type)
 {
     this.Name = Name;
     this.Type = Type;
 }
Ejemplo n.º 11
0
 //public SEntity ReferencingEntity { get; set; }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 public SAttributeInverse(string name, SParameter type)
     : base(name, type)
 {
 }