Ejemplo n.º 1
0
        // NOTHING TODO
        #endregion

        #region StringLiteral
        // NOTHING TODO
        #endregion

        #region DbObject
        public virtual bool Action(DbObject child)
        {
            if (child.Identifiers != null)
            {
                Stringifier str = new Stringifier();
                child.Assembly(str);
                _HTML += str.Statement;
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static object GetProcessed(GrammarNode node)
        {
            if (_Stringifier == null)
            {
                _Stringifier = new Stringifier();
            }

            _Stringifier.Statement = "";
            node.Assembly(_Stringifier);
            return(_Stringifier.Statement);
        }
Ejemplo n.º 3
0
        public override bool Action(GrammarNode child)
        {
            Stringifier str = new Stringifier();

            if (child.ReplacedNode != null)
            {
                FindOldNode(child.ReplacedNode);
            }
            else
            {
            }
            child.Assembly(str);
            _HTML += string.Format("{0}", str.Statement);

            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="translated"></param>
        /// <param name="writer"></param>
        /// <param name="varTokenizer"></param>
        void PrintOutput(Statement translated, TextWriter writer, Tokenizer tokenizer)
        {
            if (translated == null)
            {
                return;
            }

            String output = string.Empty;

            if (Config.Formatter)
            {
                Formatter formatter = new Formatter();
                formatter.Add(translated);
                output = formatter.Statement;
            }
            else
            {
                Stringifier stringifier = new Stringifier();
                stringifier.Add(translated);
                output = stringifier.Statement;
            }

            writer.Write(tokenizer.detokenizeInputStatements(output));
        }
Ejemplo n.º 5
0
        void TranslateStatements(IList <Statement> statements)
        {
            string outputFile = Config.OutputFile;
            Dictionary <string, string> msgs = new Dictionary <string, string>();
            int errStatement = 0;

            msgs[Note.CASEFIXER]     = ResStr.MSG_CORRECTED_IDENTIFIERS;
            msgs[Note.ERR_CASEFIXER] = ResStr.MSG_COLUMNS_NOT_FOUND;
            msgs[Note.STRINGIFIER]   = ResStr.MSG_SUMINFO_UNSUPPORTED_FEATURES;
            msgs[Note.ERR_MODIFIER]  = ResStr.MSG_ERRORS_LIMITATIONS;

            if (outputFile != "")
            {
                using (StreamWriter writer = CreateOutputFile(outputFile))
                {
                    CharacterCaseFixer fixer = new CharacterCaseFixer(Config.DBServer, Config.DBSchema, Config.DBUser, Config.DBPasswd);
                    NotesScanner       ns    = new NotesScanner(writer);

                    ns.SetFilter(Config.CommentsFilter);
                    ns.WriteNotesToWritter(false);

                    bool displayWarning = true;
                    int  idx            = 1;


                    Console.WriteLine(ResStr.MSG_TRANSLATING_QUERY, idx++, statements.Count);
                    Modifier       md = new Modifier();
                    BlockStatement RootStatement;
                    if (Config.CreateProcedure && !(statements[1] is CreateProcedureStatement))
                    {
                        CreateProcedureStatement procedure = new CreateProcedureStatement(new DbObject(new Identifier(IdentifierType.Plain, md.ProcPool.GetNewProcedureName())), -1,
                                                                                          new List <ProcedureParameter> {
                        }, null, false, statements as List <Statement>);
                        procedure.Declarations = new BlockStatement();
                        RootStatement          = new BlockStatement(procedure);
                    }
                    else
                    {
                        RootStatement = new BlockStatement(statements);
                    }
                    md.Scan(RootStatement);

                    ns.ClearSummaryInfo();
                    ns.SetFilter(Config.CommentsFilter);

                    Statement translated = md.Statement;

                    if (translated != null)
                    {
                        if (translated is BlockStatement)
                        {
                            foreach (Statement st in ((BlockStatement)translated).Statements)
                            {
                                fixer.ClearIdentifiersTables();
                                fixer.Scan(st);

                                if (Config.UseCaseFixer && (translated is SqlStartStatement) == false)
                                {
                                    string res = fixer.CorrectIdentifiers();
                                    if (!string.IsNullOrEmpty(res) && displayWarning)
                                    {
                                        Console.WriteLine(ResStr.MSG_UNABLE_TO_VERIFY_IDENTFIERS);
                                        Console.WriteLine(ResStr.MSG_TECHNICAL_INFO + " " + res);
                                        displayWarning = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            fixer.ClearIdentifiersTables();
                            fixer.Scan(translated);

                            if (Config.UseCaseFixer && (translated is SqlStartStatement) == false)
                            {
                                string res = fixer.CorrectIdentifiers();
                                if (!string.IsNullOrEmpty(res) && displayWarning)
                                {
                                    Console.WriteLine(ResStr.MSG_UNABLE_TO_VERIFY_IDENTFIERS);
                                    Console.WriteLine(ResStr.MSG_TECHNICAL_INFO + " " + res);
                                    displayWarning = false;
                                }
                            }
                        }

                        if (Config.Formatter)
                        {
                            Formatter formatter = new Formatter();
                            formatter.Add(translated);
                            writer.Write(formatter.Statement);
                        }
                        else
                        {
                            Stringifier stringifier = new Stringifier();
                            stringifier.Add(translated);
                            writer.Write(stringifier.Statement);
                        }

                        ns.Scan(translated);
                    }

                    ns.SetFilter(Config.InfoFilter);
                    ns.DisplaySummaryInfo(Console.Out, msgs);

                    if (ns.NotesCount(Note.STRINGIFIER) > 0 || ns.NotesCount(Note.ERR_MODIFIER) > 0 || ns.NotesCount(Note.ERR_CASEFIXER) > 0)
                    {
                        ++errStatement;
                    }
                }

                DbUtil.ReleaseSingleton();

                Console.WriteLine("=================================================================");
                Console.WriteLine(ResStr.MSG_NUM_OF_OK_QUERIES, statements.Count - errStatement);
                Console.WriteLine(ResStr.MSG_NUM_OF_NOK_QUERIES, errStatement);
                Console.WriteLine(ResStr.MSG_NUM_OF_QUERIES, statements.Count);
            }
        }