Ejemplo n.º 1
0
        private void SetFrequencyOption(NonterminalToken pToken)
        {
            switch (pToken.Rule.Rhs[0].ToString())
            {
            case "STRATAVAR":
                this.StratvarList.AddRange(AnalysisRule.SpliIdentifierList(this.GetCommandElement(pToken.Tokens, 2).Trim()));
                break;

            case "WEIGHTVAR":
                this.WeightVar = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            case "OUTTABLE":
                this.OutTable = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            case "PSUVAR":
                this.PSUVar = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            case "NOWRAP":
                this.NoWrap = "NOWRAP";
                break;

            case "COLUMNSIZE":
                this.ColumnSize = this.GetCommandElement(pToken.Tokens, 2);
                break;
            }
        }
Ejemplo n.º 2
0
        private void SetFreqOpt(NonterminalToken pT)
        {
            /* <FreqOpt>                           ::= <WeightOpt>
             | <FreqOptStrata>
             | <OutTableOpt>
             | <SetClause>
             | <FreqOptNoWrap>
             | <FreqOptColumnSize>
             | <FreqOptPsuvar>
             |
             | <WeightOpt>                         ::= WEIGHTVAR '=' Identifier
             | <FreqOptStrata>                     ::= STRATAVAR '=' <IdentifierList>
             | <FreqOptNoWrap>                     ::= NOWRAP
             | <FreqOptColumnSize>                     ::= COLUMNSIZE '=' DecLiteral
             | <FreqOptPsuvar>                     ::= PSUVAR '=' Identifier*/

            switch (pT.Rule.Rhs[0].Name.ToString())
            {
            case "WEIGHTVAR":
                this.WeightVar = this.GetCommandElement(pT.Tokens, 2).Trim(new char[] { '[', ']' });
                //inputVariableList.Add("WEIGHTVAR", this.GetCommandElement(pT.Tokens, 2).Trim(new char[] { '[', ']' }));
                break;

            case "STRATAVAR":
                //this.Stratvar = this.GetCommandElement(pT.Tokens, 2);
                this.Stratvar = AnalysisRule.SpliIdentifierList(this.GetCommandElement(pT.Tokens, 2));
                //StringBuilder temp2 = new StringBuilder();


                break;

            case "STATISTICS":
                if (this.GetCommandElement(pT.Tokens, 2).Equals("NONE"))
                {
                    this.tablesShowStatistics = false;
                }
                break;

            case "OUTTABLE":
                this.OutTable = this.GetCommandElement(pT.Tokens, 2).Trim(new char[] { '[', ']' });
                //inputVariableList.Add("OUTTABLE", this.GetCommandElement(pT.Tokens, 2).Trim(new char[] { '[', ']' }));
                break;

            case "<SetClause>":
                break;

            case "<FreqOptNoWrap>":
                //this.op
                break;

            case "<FreqOptColumnSize>":
                break;

            case "PSUVAR":
                this.PSUVar = this.GetCommandElement(pT.Tokens, 2).Trim(new char[] { '[', ']' });
                //inputVariableList.Add("PSUVAR", this.GetCommandElement(pT.Tokens, 2).Trim(new char[] { '[', ']' }));
                break;
            }
        }
        private void SetOption(NonterminalToken pToken)
        {
            /*
             * <CoxOpt> ::= WEIGHTVAR '=' Identifier
             | TIMEUNIT '=' String
             | GRAPHTYPE '=' String
             | OUTTABLE '=' Identifier
             | STRATAVAR '=' <IdentifierList>
             | GRAPH '=' <IdentifierList>
             | DIALOG
             | SHOWOBSERVED
             | PVALUE '=' Percentage
             | PVALUE '=' RealLiteral
             */
            switch (pToken.Rule.Rhs[0].ToString())
            {
            case "WEIGHTVAR":
                this.weightvar = this.GetCommandElement(pToken.Tokens, 2).Trim('"').Trim(new char[] { '[', ']' });
                break;

            case "TIMEUNIT":
                this.time_unit = this.GetCommandElement(pToken.Tokens, 2).Trim('"').Trim(new char[] { '[', ']' });
                break;

            case "GRAPHTYPE":
                this.graph_type = this.GetCommandElement(pToken.Tokens, 2).Trim('"').Trim(new char[] { '[', ']' });
                break;

            case "OUTTABLE":
                this.out_table = this.GetCommandElement(pToken.Tokens, 2).Trim('"').Trim(new char[] { '[', ']' });
                break;

            case "STRATAVAR":
                this.StrataVarList.AddRange(AnalysisRule.SpliIdentifierList(this.GetCommandElement(pToken.Tokens, 2)));
                break;

            case "GRAPH":
                this.GraphVariableList.AddRange(AnalysisRule.SpliIdentifierList(this.GetCommandElement(pToken.Tokens, 2)));
                break;

            case "DIALOG":
            case "SHOWOBSERVED":
            case "PVALUE":
                this.p_value = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            default:
                // do nothing
                break;
            }
        }
        public Rule_Write(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            // <Write_All_Statement>    ::= WRITE <WriteMode> <FileDataFormat> <OutTarget> '*'
            // <Write_Some_Statement>   ::= WRITE <WriteMode> <FileDataFormat> <OutTarget> <IdentifierList>
            // <Write_Except_Statement> ::= WRITE <WriteMode> <FileDataFormat> <OutTarget> '*' EXCEPT <IdentifierList>
            // <WriteMode>              ::= APPEND| REPLACE	| !Null
            // <FileDataFormat>         ::= '"Epi7"'
            //                          | '"Epi2000"'
            //                          | '"Epi 2000"'
            //                          | '"Excel 8.0"'
            //                          | '"Text"'
            // <OutTarget>              ::= Identifier | File ':' Identifier | File | BraceString ':' Identifier

            this.WriteMode      = this.GetCommandElement(pToken.Tokens, 1);
            this.FileDataFormat = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '"' });

            NonterminalToken T = (NonterminalToken)pToken.Tokens[3];

            GetOutTarget(pToken.Tokens[3]);

            /*
             * this.OutTarget = this.GetCommandElement(pToken.Tokens, 3).Trim(new char[] { '{','}' });
             *
             * if (((TerminalToken)T.Tokens[0]).Symbol.ToString() == "BraceString")
             * {
             *  this.OutTarget = this.OutTarget.Replace("}","");
             *  isConnectionString = true;
             * }*/

            if (pToken.Tokens.Length <= 5)
            {
                //this.IdentifierList = this.GetCommandElement(pToken.Tokens, 4).Replace(" . ", ".").Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                //this.IdentifierListRule = AnalysisRule.BuildStatments(pContext, pToken.Tokens[4]);
                this.IdentifierList = AnalysisRule.SpliIdentifierList(this.GetCommandElement(pToken.Tokens, 4));
            }
            else
            {
                //this.IdentifierList = this.GetCommandElement(pToken.Tokens, 6).Replace(" . ", ".").Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                //this.IdentifierListRule = AnalysisRule.BuildStatments(pContext, pToken.Tokens[6]);
                this.IdentifierList = AnalysisRule.SpliIdentifierList(this.GetCommandElement(pToken.Tokens, 6));
                isExceptionList     = true;
            }
        }
Ejemplo n.º 5
0
        private void SetTableOptions(NonterminalToken pToken)
        {
            for (int i = 0; i < pToken.Tokens.Length; i++)
            {
                NonterminalToken T = (NonterminalToken)pToken.Tokens[i];
                switch (T.Rule.Rhs[0].ToString())
                {
                case "<FreqOpts>":
                case "<WeightOpt>":
                case "<FreqOpt>":
                    for (int j = 0; j < T.Tokens.Length; j++)
                    {
                        string   temp = this.ExtractTokens(((NonterminalToken)T.Tokens[j]).Tokens);
                        string[] tmp  = temp.Split('=');

                        switch (tmp[0].ToUpperInvariant().Trim())
                        {
                        case "STRATAVAR":
                            this.Stratvar = AnalysisRule.SpliIdentifierList(tmp[1].Trim());
                            break;

                        case "WEIGHTVAR":
                            this.WeightVar = tmp[1].Trim();
                            break;
                        }
                    }
                    break;

                case "<OutTableOpt>":
                    this.OutTable = this.GetCommandElement(T.Tokens, 2);
                    break;

                case "<FreqOptPsuvar>":
                    this.PSUVar = this.GetCommandElement(T.Tokens, 2);
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        private void SetFrequencyOption(NonterminalToken pToken)
        {
            /*
             * WEIGHTVAR '=' Identifier
             | STRATAVAR '=' <Freq_Variable_List>
             |NOWRAP
             |COLUMNSIZE '=' DecLiteral
             |PSUVAR '=' Identifier
             | OUTTABLE '=' Identifier
             | <SetClause>
             */


            switch (pToken.Rule.Rhs[0].ToString())
            {
            case "STRATAVAR":
                this.StratvarList = AnalysisRule.SpliIdentifierList(this.GetCommandElement(pToken.Tokens, 2).Trim());
                break;

            case "WEIGHTVAR":
                this.WeightVar = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            case "OUTTABLE":
                this.OutTable = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            case "PSUVAR":
                this.PSUVar = this.GetCommandElement(pToken.Tokens, 2).Trim(new char[] { '[', ']' });
                break;

            case "<SetClause>":
                this.SetSetClause((NonterminalToken)pToken.Tokens[0]);
                break;
            }
        }
Ejemplo n.º 7
0
        public Rule_Freq(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            this.IdentifierList = new List <string>();

            /*<Freq_Variable_List> ::= Identifier | Identifier <Freq_Variable_List>
             *
             * <Freq_All_Statement>            ::= FREQ '*'
             | FREQ '*' <FreqOpts>
             | FREQ <Freq_Variable_List>
             | FREQ <Freq_Variable_List> <FreqOpts>
             | FREQ '*' EXCEPT <Freq_Variable_List>
             | FREQ '*' EXCEPT <Freq_Variable_List> <FreqOpts>
             |
             | <FreqOpts>                          ::= <FreqOpts> <FreqOpt> | <FreqOpt>
             |
             | <FreqOpt>   ::=  WEIGHTVAR '=' Identifier
             | STRATAVAR '=' <Freq_Variable_List>
             |NOWRAP
             |COLUMNSIZE '=' DecLiteral
             |PSUVAR '=' Identifier
             | OUTTABLE '=' Identifier
             | <SetClause>
             */

            commandText = this.ExtractTokens(pToken.Tokens);
            foreach (Token T in pToken.Tokens)
            {
                if (T is NonterminalToken)
                {
                    NonterminalToken NT = (NonterminalToken)T;
                    switch (NT.Symbol.ToString())
                    {
                    case "<Freq_Variable_List>":
                        this.IdentifierList.AddRange(AnalysisRule.SpliIdentifierList(this.ExtractTokens(NT.Tokens).Trim()));
                        break;

                    case "<FreqOpts>":
                        this.SetFrequencyOptions(NT);
                        break;

                    case "<FreqOpt>":
                        this.SetFrequencyOption(NT);
                        break;
                    }
                }
                else
                {
                    TerminalToken TT = (TerminalToken)T;
                    switch (TT.Symbol.ToString())
                    {
                    case "*":
                        this.IdentifierList.AddRange("*".Split(' '));
                        break;

                    case "EXCEPT":
                        this.isExceptionList = true;
                        break;
                    }
                }
            }

            /*
             *          if (pToken.Tokens.Length == 2)
             *          {
             *              this.IdentifierList = this.GetCommandElement(pToken.Tokens, 1).Split(' ');
             *          }
             *          else if (pToken.Tokens.Length <= 3)
             *          {
             *              this.IdentifierList = this.GetCommandElement(pToken.Tokens, 1).Split(' ');
             *              NonterminalToken T = (NonterminalToken)pToken.Tokens[2];
             *
             *              this.SetFrequencyOptions(T);
             *
             *          }
             *          else
             *          {
             *              this.IdentifierList = this.GetCommandElement(pToken.Tokens, 3).Split(' ');
             *              //this.isExceptionList = true;
             *              this.SetFrequencyOptions((NonterminalToken)pToken.Tokens[4]);
             *          }*/



            //<OutTableOpt> ::= OUTTABLE '=' Identifier <KeyVarList>
            //<KeyVarList> ::= KEYVARS '=' <IdentifierList>


            /*
             * !***             Freq Statement          ***!
             * <Freq_All_Statement>							::= FREQ '*' <FreqOpts>
             * <Freq_Columns_Statement>                         ::= FREQ <IdentifierList> <FreqOpts>
             * <Freq_All_Except_Statement>                  ::= FREQ '*' EXCEPT <IdentifierList> <FreqOpts>
             *
             * <FreqOpts>							::= <FreqOpts> <FreqOpt> | <FreqOpt> | !Null
             *
             * <FreqOpt>                            ::= <WeightOpt>
             | <FreqOptStrata>
             | <OutTableOpt>
             | <SetClause>
             | <FreqOptNoWrap>
             | <FreqOptColumnSize>
             | <FreqOptPsuvar>
             |
             | <WeightOpt>							::= WEIGHTVAR '=' Identifier
             | <FreqOptStrata>						::= STRATAVAR '=' <IdentifierList>
             | <FreqOptNoWrap>						::= NOWRAP
             | <FreqOptColumnSize>						::= COLUMNSIZE '=' DecLiteral
             | <FreqOptPsuvar>						::= PSUVAR '=' Identifier
             |
             | !***             End                     ***!
             */
        }