Ejemplo n.º 1
0
        private void ProcessType()
        {
            SToken oneToken = SLexer.Tokenizer(_dataStream);

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

            SType st = ProcessTypeSub(oneToken);

            oneToken = SLexer.Tokenizer(_dataStream);

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

            while (oneToken.TokenType != STokenType.END_TYPE)
            {
                IgnoredToken(oneToken);
                oneToken = SLexer.Tokenizer(_dataStream);
            }
            CleanUpSemiColon();

            SchemaSet.TypeList.Add(st.Name, st);
        }
Ejemplo n.º 2
0
 private void UpdateTypeAttribute(SType sType)
 {
     if (sType is STypeSimple)
     {
         var ss = (STypeSimple)sType;
         ss.SimpleTypeReference = FindNamedSItem(ss.SimpleName);
     }
     else if (sType is STypeCollection)
     {
         var so = (STypeCollection)sType;
         if (so.CollectionType == SParamType.UNSET)
         {
             so.CollectionReference = FindNamedSItem(so.CollectionName);
         }
         if (so.CollectionReference is SType)
         {
             so.CollectionType = SParamType.TYPE;
         }
         else if (so.CollectionReference is SEntity)
         {
             so.CollectionType = SParamType.ENTITY;
         }
     }
     else if (sType is STypeSelect)
     {
         var st    = (STypeSelect)sType;
         var il    = st.SelectList.Keys;
         var ilNew = il.ToList();
         foreach (var s in ilNew)
         {
             st.SelectList [s] = FindNamedSItem(s);
         }
     }
 }
Ejemplo n.º 3
0
 private SType getType(string SimpleID)
 {
     if (SchemaSet.TypeList.ContainsKey(SimpleID))
     {
         return(SchemaSet.TypeList[SimpleID]);
     }
     else
     {
         SType at = new SType(SimpleID);
         SchemaSet.TypeList.Add(SimpleID, at);
         return(at);
     }
 }
Ejemplo n.º 4
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.º 5
0
 private SType getType(string SimpleID)
 {
     if (SchemaSet.TypeList.ContainsKey(SimpleID))
     {
         return SchemaSet.TypeList[SimpleID];
     }
     else
     {
         SType at = new SType(SimpleID);
         SchemaSet.TypeList.Add(SimpleID, at);
         return at;
     }
 }
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 void UpdateTypeAttribute(SType sType)
 {
     if (sType is STypeSimple) {
         var ss = (STypeSimple)sType;
         ss.SimpleTypeReference = FindNamedSItem (ss.SimpleName);
     } else if (sType is STypeCollection) {
         var so = (STypeCollection)sType;
         if (so.CollectionType == SParamType.UNSET)
             so.CollectionReference = FindNamedSItem (so.CollectionName);
         if (so.CollectionReference is SType)
             so.CollectionType = SParamType.TYPE;
         else if (so.CollectionReference is SEntity)
             so.CollectionType = SParamType.ENTITY;
     } else if (sType is STypeSelect) {
         var st = (STypeSelect)sType;
         var il = st.SelectList.Keys;
         var ilNew = il.ToList ();
         foreach (var s in ilNew) {
             st.SelectList [s] = FindNamedSItem (s);
         }
     }
 }