Tup.Cobar4Net.Parser.Recognizer.Mysql.Syntax.MySqlDdlParser.ColumnDefinition C# (CSharp) Method

ColumnDefinition() private method

private ColumnDefinition ( ) : ColumnDefinition
return Tup.Cobar4Net.Parser.Ast.Fragment.Ddl.ColumnDefinition
        private DdlColumnDefinition ColumnDefinition()
        {
            var dataType = DataType();
            var notNull = false;
            IExpression defaultVal = null;
            var autoIncrement = false;
            var sindex = SpecialIndex.None;
            var format = ColumnFormat.None;
            LiteralString comment = null;
            if (lexer.Token() == MySqlToken.KwNot)
            {
                lexer.NextToken();
                Match(MySqlToken.LiteralNull);
                notNull = true;
            }
            else
            {
                if (lexer.Token() == MySqlToken.LiteralNull)
                {
                    lexer.NextToken();
                }
            }
            if (lexer.Token() == MySqlToken.KwDefault)
            {
                lexer.NextToken();
                defaultVal = exprParser.Expression();
                if (!(defaultVal is Literal))
                {
                    throw new SqlSyntaxErrorException("default value of column must be a literal: " +
                                                      defaultVal);
                }
            }
            if (lexer.Token() == MySqlToken.Identifier && "AUTO_INCREMENT".Equals(lexer.GetStringValueUppercase()))
            {
                lexer.NextToken();
                autoIncrement = true;
            }
            switch (lexer.Token())
            {
                case MySqlToken.KwUnique:
                {
                    if (lexer.NextToken() == MySqlToken.KwKey)
                    {
                        lexer.NextToken();
                    }
                    sindex = SpecialIndex.Unique;
                    break;
                }

                case MySqlToken.KwPrimary:
                {
                    lexer.NextToken();
                    goto case MySqlToken.KwKey;
                }

                case MySqlToken.KwKey:
                {
                    Match(MySqlToken.KwKey);
                    sindex = SpecialIndex.Primary;
                    break;
                }
            }
            if (lexer.Token() == MySqlToken.Identifier && "COMMENT".Equals(lexer.GetStringValueUppercase()))
            {
                lexer.NextToken();
                comment = (LiteralString)exprParser.Expression();
            }
            if (lexer.Token() == MySqlToken.Identifier && "COLUMN_FORMAT".Equals(lexer.GetStringValueUppercase()))
            {
                switch (lexer.NextToken())
                {
                    case MySqlToken.KwDefault:
                    {
                        lexer.NextToken();
                        format = ColumnFormat.Default;
                        break;
                    }

                    case MySqlToken.Identifier:
                    {
                        var si = specialIdentifiers.GetValue(lexer.GetStringValueUppercase());
                        if (si != SpecialIdentifier.None)
                        {
                            switch (si)
                            {
                                case SpecialIdentifier.Fixed:
                                {
                                    lexer.NextToken();
                                    format = ColumnFormat.Fixed;
                                    break;
                                }

                                case SpecialIdentifier.Dynamic:
                                {
                                    lexer.NextToken();
                                    format = ColumnFormat.Dynamic;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }
            return new DdlColumnDefinition(dataType, notNull,
                defaultVal, autoIncrement, sindex, comment, format);
        }