public Rule_CompareExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            // <Concat Exp> LIKE String
            // <Concat Exp> '=' <Compare Exp>
            // <Concat Exp> '<>' <Compare Exp>
            // <Concat Exp> '>' <Compare Exp>
            // <Concat Exp> '>=' <Compare Exp>
            // <Concat Exp> '<' <Compare Exp>
            // <Concat Exp> '<=' <Compare Exp>
            // <Concat Exp>

            this.ConcatExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                op = pToken.Tokens[1].ToString();

                if (pToken.Tokens[1].ToString().Equals("LIKE", StringComparison.OrdinalIgnoreCase))
                {
                    this.STRING = pToken.Tokens[2].ToString().Trim(new char[] { '"' });
                }
                else
                {
                    this.CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
                }
            }
        }
Ejemplo n.º 2
0
        public Rule_CompareExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            // <Concat Exp> LIKE String
            // <Concat Exp> '=' <Compare Exp>
            // <Concat Exp> '<>' <Compare Exp>
            // <Concat Exp> '>' <Compare Exp>
            // <Concat Exp> '>=' <Compare Exp>
            // <Concat Exp> '<' <Compare Exp>
            // <Concat Exp> '<=' <Compare Exp>
            // <Concat Exp>

            this.ConcatExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                op = pToken.Tokens[1].ToString().ToLower();

                if (pToken.Tokens[1].ToString() == "LIKE")
                {
                    this.STRING     = pToken.Tokens[2].ToString();
                    this.CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
                }
                else
                {
                    this.CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
                }
            }
        }
 public Rule_Program(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //<Program> ::= <CheckCodeBlocks> | !Eof
     if (pToken.Tokens.Length > 0)
     {
         CheckCodeBlocks = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
     }
 }
Ejemplo n.º 4
0
        public Rule_PowExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*  ::= <Negate Exp> '^' <Negate Exp>  | <Negate Exp> */

            this.NegateExp1 = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.NegateExp2 = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
        public Rule_AndExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            // <Not Exp> AND <And Exp>
            // <Not Exp>

            this.NotExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.AndExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
Ejemplo n.º 6
0
 public Rule_Begin_Before_Statement(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //<Begin_Before_statement> ::= Begin-Before <Statements> End | Begin-Before End |!Null
     if (pToken.Tokens.Length > 2)
     {
         //NonterminalToken T = (NonterminalToken)pToken.Tokens[1];
         //this.Statements = new Rule_Statements(pContext, T);
         this.Statements = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
     }
 }
        public Rule_ExprList(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*::= <Expression> ',' <Expr List> | <Expression> */

            this.Expression = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            if (pToken.Tokens.Length > 1)
            {
                this.ExprList = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
        public Rule_Define_Statement_Group(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //<Define_Statement_Group> ::= <Define_Statement_Type> <Define_Statement_Group> | <Define_Statement_Type>

            Define_Statement_Type = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            if (pToken.Tokens.Length > 1)
            {
                Define_Statement_Group = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            }
        }
        public Rule_DefineVariables_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);

            //<DefineVariables_Statement> ::= DefineVariables <Define_Statement_Group> End-DefineVariables
            if (pToken.Tokens.Length > 2)
            {
                //define_Statements_Group = new Rule_Define_Statement_Group(pContext, (NonterminalToken)pToken.Tokens[1]);
                define_Statements_Group = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            }
        }
Ejemplo n.º 10
0
        public Rule_ConcatExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*::= <Add Exp> '&' <Concat Exp>
             | <Add Exp>*/

            this.AddExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.op = pToken.Tokens[1].ToString();

                this.ConcatExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
Ejemplo n.º 11
0
 public Rule_NotExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
 {
     //<Not Exp> ::= NOT <Compare Exp> | <Compare Exp>
     if (pToken.Tokens.Length == 1)
     {
         CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
     }
     else
     {
         CompareExp          = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
         this.isNotStatement = true;
     }
 }
Ejemplo n.º 12
0
 public Rule_CheckCodeBlocks(Rule_Context pContext, NonterminalToken pToken)
 {
     //<CheckCodeBlocks> ::= <CheckCodeBlock> <CheckCodeBlocks> | <CheckCodeBlock>
     if (pToken.Tokens.Length > 1)
     {
         CheckCodeBlock  = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
         CheckCodeBlocks = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
     }
     else
     {
         CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
     }
 }
        public Rule_MultipleFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<EnterRule> pList) : base(pContext)
        {
            //<MultipleFunctionParameterList> ::= <NonEmptyFunctionParameterList> ',' <Expression>

            NonterminalToken nonEmptyToken = (NonterminalToken)pToken.Tokens[0];
            NonterminalToken ExpressionToken = (NonterminalToken)pToken.Tokens[2];
           // nonEmptyList = new Rule_NonEmptyFunctionParameterList(pContext, nonEmptyToken, pList);
            //this.Expression = new Rule_Expression(pContext, ExpressionToken);

            pList.Push(EnterRule.BuildStatments(pContext, nonEmptyToken));
            pList.Push(EnterRule.BuildStatments(pContext, ExpressionToken));

            //pList.Push(this.Expression);
        }
        public Rule_AddExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*::= <Mult Exp> '+' <Add Exp>
             | <Mult Exp> '-' <Add Exp>
             | <Mult Exp>*/

            this.MultExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            if (pToken.Tokens.Length > 1)
            {
                operation   = pToken.Tokens[1].ToString();
                this.AddExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
        public Rule_Subroutine_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);

            //<Subroutine_Statement> ::= Sub Identifier <Statements> End | Sub Identifier End
            this.Identifier = this.GetCommandElement(pToken.Tokens, 1);
            if (pToken.Tokens.Length > 3)
            {
                //NonterminalToken T = (NonterminalToken)pToken.Tokens[2];
                //this.Statements = new Rule_Statements(pContext, T);
                this.Statements = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
Ejemplo n.º 16
0
        public Rule_Expression(Rule_Context pContext, NonterminalToken pTokens) : base(pContext)
        {
            /*::= <And Exp> OR <Expression>
             | <And Exp> XOR <Expression>
             | <And Exp> */

            this.CommandText = this.ExtractTokens(pTokens.Tokens);

            And_Exp = EnterRule.BuildStatments(pContext, pTokens.Tokens[0]);
            if (pTokens.Tokens.Length > 1)
            {
                op         = pTokens.Tokens[1].ToString().ToUpper();
                Expression = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
            }
        }
        public Rule_NegateExp(Rule_Context pContext, NonterminalToken pTokens) : base(pContext)
        {
            //<Negate Exp> ::= '-' <Value>
            // or
            //<Negate Exp> ::= <Value>

            if (pTokens.Tokens.Length > 1)
            {
                this.op    = this.GetCommandElement(pTokens.Tokens, 0);
                this.Value = EnterRule.BuildStatments(pContext, pTokens.Tokens[1]);
            }
            else
            {
                this.Value = EnterRule.BuildStatments(pContext, pTokens.Tokens[0]);
            }
        }
Ejemplo n.º 18
0
        public Rule_MultExp(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*::= <Pow Exp> '*' <Mult Exp>
             | <Pow Exp> '/' <Mult Exp>
             | <Pow Exp> MOD <Mult Exp>
             | <Pow Exp> '%' <Mult Exp>
             | <Pow Exp>*/

            this.PowExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.op = pToken.Tokens[1].ToString();

                this.MultExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
        public Rule_Field_Checkcode_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //<Field_Checkcode_Statement> ::=  Field Identifier <Begin_Before_statement> <Begin_After_statement> <Begin_Click_statement>  End

            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);

            this.Identifier = this.GetCommandElement(pToken.Tokens, 1).Trim(new char[] { '[', ']' });
            if (pContext.IsVariableValidationEnable)
            {
                if (!string.IsNullOrEmpty(Identifier))
                {
                    if (!this.Context.CommandVariableCheck.ContainsKey(Identifier.ToLowerInvariant()))
                    {
                        this.Context.CommandVariableCheck.Add(Identifier, "Field");
                    }
                }
            }
            if (Context.ParsedFieldNames.Contains(Identifier.ToLowerInvariant()) == false)
            {
                Context.ParsedFieldNames.Add(Identifier.ToLowerInvariant());
            }

            for (int i = 2; i < pToken.Tokens.Length; i++)
            {
                if (pToken.Tokens[i] is NonterminalToken)
                {
                    NonterminalToken T = (NonterminalToken)pToken.Tokens[i];
                    switch (T.Symbol.ToString())
                    {
                    case "<Begin_Before_statement>":
                        this.BeginBefore = EnterRule.BuildStatments(pContext, T);
                        break;

                    case "<Begin_After_statement>":
                        this.BeginAfter = EnterRule.BuildStatments(pContext, T);
                        break;

                    case "<Begin_Click_statement>":
                        this.BeginClick = EnterRule.BuildStatments(pContext, T);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public Rule_Define_Statement_Type(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*<Define_Statement_Type> ::= <Define_Variable_Statement>
             | <Define_Dll_Statement>
             | <Define_Group_Statement> */

            this.define_command = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            /*
             * if (((NonterminalToken)pToken.Tokens[0]).Symbol.ToString() == "<Define_Dll_Statement>")
             * {
             *  this.define_command = new Rule_DLL_Statement(pContext, (NonterminalToken) pToken.Tokens[0]);
             * }
             * else
             * {
             *  this.define_command = new Rule_Define(pContext, (NonterminalToken) pToken.Tokens[0]);
             * }*/
        }
Ejemplo n.º 21
0
        public Rule_Define(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            //DEFINE Identifier <Variable_Scope> <VariableTypeIndicator> <Define_Prompt>
            //DEFINE Identifier '=' <Expression>

            Identifier = GetCommandElement(pToken.Tokens, 1);
            if (GetCommandElement(pToken.Tokens, 2) == "=")
            {
                this.Expression = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
                // set some defaults
                Variable_Scope        = "STANDARD";
                VariableTypeIndicator = "";
                Define_Prompt         = "";
            }
            else
            {
                Variable_Scope = GetCommandElement(pToken.Tokens, 2);//STANDARD | GLOBAL | PERMANENT |!NULL

                VariableTypeIndicator = GetCommandElement(pToken.Tokens, 3);
                Define_Prompt         = GetCommandElement(pToken.Tokens, 4);
            }
        }
        public Rule_View_Checkcode_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);
            // <View_Checkcode_Statement> ::= View <Begin_Before_statement> <Begin_After_statement> End
            for (int i = 1; i < pToken.Tokens.Length; i++)
            {
                if (pToken.Tokens[i] is NonterminalToken)
                {
                    NonterminalToken T = (NonterminalToken)pToken.Tokens[i];
                    switch (T.Symbol.ToString())
                    {
                    case "<Begin_Before_statement>":
                        this.BeginBefore = EnterRule.BuildStatments(pContext, pToken.Tokens[i]);
                        break;

                    case "<Begin_After_statement>":
                        this.BeginAfter = EnterRule.BuildStatments(pContext, pToken.Tokens[i]);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public Rule_Statements(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            //<Statements> ::= <Statements> <Statement> | <Statement>

            if (pToken.Tokens.Length > 1)
            {
                //NonterminalToken T;
                //T = (NonterminalToken)pToken.Tokens[0];
                //this.statements = new Rule_Statements(pContext, T);
                this.statements = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

                //T = ((NonterminalToken)pToken.Tokens[1]);
                //this.statement = new Rule_Statement(pContext, T);
                this.statement = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            }
            else
            {
                //NonterminalToken T;
                //T = (NonterminalToken)pToken.Tokens[0];
                //this.statement = new Rule_Statement(pContext, T);
                this.statement = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            }
        }
Ejemplo n.º 24
0
        public Rule_Else_If_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*
             *
             * <Else_If_Statement>          ::=  Else-If <Expression> Then <Statements>
             | Else-If <Expression> Then <Statements> Else <Statements>
             | Else-If <Expression> Then <Statements> <Else_If_Statement>
             */

            Expression  = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            Statements1 = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
            if (pToken.Tokens.Length > 4)
            {
                if (this.GetCommandElement(pToken.Tokens, 4).Equals("Else", StringComparison.OrdinalIgnoreCase))
                {
                    Statements2 = EnterRule.BuildStatments(pContext, pToken.Tokens[5]);
                }
                else
                {
                    Statements2 = EnterRule.BuildStatments(pContext, pToken.Tokens[4]);
                }
            }
        }
        public Rule_CheckCodeBlock(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /* <CheckCodeBlock> ::=   <DefineVariables_Statement>
             | <View_Checkcode_Statement>
             | <Record_Checkcode_Statement>
             | <Page_Checkcode_Statement>
             | <Field_Checkcode_Statement>
             | <Subroutine_Statement>  */
            switch (pToken.Rule.Rhs[0].ToString())
            {
            case "<DefineVariables_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<View_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Record_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Page_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Field_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Subroutine_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;
            }
        }
        //object ReturnResult = null;

        public Rule_Assign(Rule_Context pContext, NonterminalToken pTokens) : base(pContext)
        {
            //ASSIGN <Qualified ID> '=' <Expression>
            //<Let_Statement> ::= LET Identifier '=' <Expression>
            //<Simple_Assign_Statement> ::= Identifier '=' <Expression>
            //<Assign_DLL_Statement> ::= ASSIGN <Qualified ID> '=' identifier'!'<FunctionCall>
            string[]         temp;
            NonterminalToken T;
            int  number;
            bool isNumeric;

            switch (pTokens.Rule.Lhs.ToString())
            {
            case "<Assign_Statement>":
                T = (NonterminalToken)pTokens.Tokens[1];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }
                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[3]);


                if (pContext.IsVariableValidationEnable)
                {
                    for (int i = 0; pTokens.Tokens.Length > i; i++)
                    {
                        var IdentifierList = this.GetCommandElement(pTokens.Tokens, i).ToString().Split(' ');
                        IdentifierList = RemoveOp(IdentifierList);
                        if (IdentifierList.Length > 0)
                        {
                            foreach (var Identifier in IdentifierList)
                            {
                                isNumeric = int.TryParse(Identifier, out number);
                                if (!string.IsNullOrEmpty(Identifier) && !this.Context.CommandVariableCheck.ContainsKey(Identifier.ToLowerInvariant()) && !isNumeric)
                                {
                                    this.Context.CommandVariableCheck.Add(Identifier, "assign");
                                }
                            }
                        }
                    }
                }


                break;

            case "<Let_Statement>":
                T = (NonterminalToken)pTokens.Tokens[1];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }


                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[3]);
                if (pContext.IsVariableValidationEnable)
                {
                    for (int i = 0; pTokens.Tokens.Length > i; i++)
                    {
                        var IdentifierList = this.GetCommandElement(pTokens.Tokens, i).ToString().Split(' ');
                        IdentifierList = RemoveOp(IdentifierList);
                        if (IdentifierList.Length > 0)
                        {
                            foreach (var Identifier in IdentifierList)
                            {
                                isNumeric = int.TryParse(Identifier, out number);
                                if (!string.IsNullOrEmpty(Identifier) && !this.Context.CommandVariableCheck.ContainsKey(Identifier.ToLowerInvariant()) && !isNumeric)
                                {
                                    this.Context.CommandVariableCheck.Add(Identifier, "assign");
                                }
                            }
                        }
                    }
                }
                break;

            case "<Simple_Assign_Statement>":
                //Identifier '=' <Expression>
                //T = (NonterminalToken)pTokens.Tokens[1];
                T = (NonterminalToken)pTokens.Tokens[0];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else if (T.Symbol.ToString() == "<GridFieldId>")
                {
                    /*<GridFieldId> ::= Identifier'[' <Number>',' Identifier ']'
                     | Identifier '[' <Number> ',' <Number> ']'
                     | Identifier '[' <Number> ',' <Literal_String> ']'*/
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                    int Int_temp;
                    if (int.TryParse(this.GetCommandElement(T.Tokens, 2), out Int_temp))
                    {
                        this.Index0 = Int_temp;
                    }


                    if (int.TryParse(this.GetCommandElement(T.Tokens, 4), out Int_temp))
                    {
                        this.Index1 = Int_temp;
                    }
                    else
                    {
                        //this.Index1 = this.GetCommandElement(T.Tokens, 4);
                        //this.Index1 = this.ExtractTokens(((NonterminalToken)T.Tokens[4]).Tokens);
                        this.Index1 = new Rule_Value(this.Context, T.Tokens[4]);
                    }
                    this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
                    break;
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }


                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
                if (pContext.IsVariableValidationEnable)
                {
                    if (!string.IsNullOrEmpty(this.QualifiedId) && !this.Context.CommandVariableCheck.ContainsKey(this.QualifiedId.ToLowerInvariant()))
                    {
                        this.Context.CommandVariableCheck.Add(this.QualifiedId.ToLowerInvariant(), this.QualifiedId.ToLowerInvariant());
                    }
                }
                break;
            }
        }
        public Rule_If_Then_Else_End(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*
             *
             * <If_Statement>                  ::=   IF <Expression> THEN  <Statements>  END-IF
             | IF <Expression> THEN  <Statements>  END
             | <If_Else_Statement>              ::=  IF <Expression> THEN  <Statements> <Else_If_Statement>  END-IF
             | IF <Expression> THEN  <Statements>  <Else_If_Statement>  END
             |                                      IF <Expression> THEN <Statements> ELSE  <Statements>  END-IF
             | IF <Expression> THEN <Statements> ELSE  <Statements>  END
             */

            IfClause = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);

            if (pContext.IsVariableValidationEnable)
            {
                var IdentifierList = this.GetCommandElement(pToken.Tokens, 1).ToString().Split(' ');

                IdentifierList = RemoveOp(IdentifierList);
                List <string> NewList = new List <string>();
                if (IdentifierList.Length > 0)
                {//if 1
                    try
                    {
                        for (int i = 0; IdentifierList.Length > i; i++)
                        { // for 2
                            int  IndexStart    = 0;
                            int  IndexEnd      = 0;
                            bool StartsAndEnds = false;
                            if (IdentifierList[i].StartsWith("\"") && IdentifierList[i].EndsWith("\""))
                            {
                                NewList.Add(IdentifierList[i]);
                                StartsAndEnds = true;
                            }
                            if (!StartsAndEnds)
                            {
                                if (IdentifierList[i].Contains("\""))
                                {// if 2
                                    IndexStart = i;
                                    for (int j = i + 1; IdentifierList.Length > j; j++)
                                    {
                                        if (IdentifierList[j].Contains("\""))
                                        {
                                            IndexEnd = j;
                                            break;
                                        }
                                    }


                                    i = IndexEnd;
                                }//if 2
                                if (IndexEnd > 0)
                                {
                                    for (int k = IndexStart; IdentifierList.Length > k; k++)
                                    {
                                        if (IndexEnd >= k)
                                        {
                                            NewList.Add(IdentifierList[k]);
                                        }
                                    }
                                }
                            }
                        }// for 2
                        foreach (var item in IdentifierList)
                        {
                            if (IdentifierList.Length > 0)
                            {
                                if (!string.IsNullOrEmpty(item) && !this.Context.CommandVariableCheck.ContainsKey(item.ToLowerInvariant()) && !NewList.Contains(item))
                                {
                                    this.Context.CommandVariableCheck.Add(item, "If");
                                }
                            }
                        }
                    }
                    catch (Exception ex) {
                        throw ex;
                    }
                }//if 1
            }



            ThenClause = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
            if (this.GetCommandElement(pToken.Tokens, 4).Equals("Else", StringComparison.OrdinalIgnoreCase))
            {
                ElseClause = EnterRule.BuildStatments(pContext, pToken.Tokens[5]);
            }

            //var temp =   (( Rule_Value)((( Rule_CompareExp)(IfClause)).CompareExp)).Id;

            /*
             * else
             * {
             * ElseClause = EnterRule.BuildStatments(pContext, pToken.Tokens[4]);
             * }*/
        }
Ejemplo n.º 28
0
        public Rule_Statement(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            if (pToken.Tokens[0] is TerminalToken)
            {
                return;
            }
            NonterminalToken T = (NonterminalToken)pToken.Tokens[0];

            this.Context.ProgramText.Append(pToken.Tokens[0].ToString());

            this.reduction = EnterRule.BuildStatments(pContext, T);

            //switch (pToken.Rule.Rhs[0].ToString())
            //{
            //    // H1N1
            //    case "<Always_Statement>":
            //        this.reduction = new Rule_Always(pContext, T);
            //        break;

            //    case "<Simple_Assign_Statement>":
            //    case "<Let_Statement>":
            //    case "<Assign_Statement>":
            //        this.reduction = new Rule_Assign(pContext, T);
            //        break;
            //    case "<Assign_DLL_Statement>":
            //        this.reduction = new Rule_Assign_DLL_Statement(pContext, T);
            //        break;
            //    case "<If_Statement>":
            //    case "<If_Else_Statement>":
            //        this.reduction = new Rule_If_Then_Else_End(pContext, T);
            //        break;

            //    case "<Define_Variable_Statement>":
            //        this.reduction = new Rule_Define(pContext, T);
            //        break;

            //    case "<FunctionCall>":
            //        this.reduction = new Rule_FunctionCall(pContext, T);
            //        break;

            //    case "<Hide_Some_Statement>":
            //    case "<Hide_Except_Statement>":
            //        this.reduction = new Rule_Hide(pContext, T);
            //        break;

            //    case "<Unhide_Some_Statement>":
            //    case "<Unhide_Except_Statement>":
            //        this.reduction = new Rule_UnHide(pContext, T);
            //        break;

            //    case "<Go_To_Variable_Statement>":
            //    case "<Go_To_Page_Statement>":
            //        this.reduction = new Rule_GoTo(pContext, T);
            //        break;

            //    case "<Simple_Dialog_Statement>":
            //    case "<Numeric_Dialog_Implicit_Statement>":
            //    case "<Numeric_Dialog_Explicit_Statement>":
            //    case "<TextBox_Dialog_Statement>":
            //    case "<Db_Values_Dialog_Statement>":
            //    case "<YN_Dialog_Statement>":
            //    case "<Db_Views_Dialog_Statement>":
            //    case "<Databases_Dialog_Statement>":
            //    case "<Db_Variables_Dialog_Statement>":
            //    case "<Multiple_Choice_Dialog_Statement>":
            //    case "<Dialog_Read_Statement>":
            //    case "<Dialog_Write_Statement>":
            //    case "<Dialog_Read_Filter_Statement>":
            //    case "<Dialog_Write_Filter_Statement>":
            //    case "<Dialog_Date_Statement>":
            //    case "<Dialog_Date_Mask_Statement>":
            //        this.reduction = new Rule_Dialog(pContext, T);
            //        break;
            //    //case "<Comment_Line>":
            //    //    this.reduction = new Rule_CommentLine(pContext, T);
            //    //    break;
            //    case "<Simple_Execute_Statement>":
            //    case "<Execute_File_Statement>":
            //    case "<Execute_Url_Statement>":
            //    case "<Execute_Wait_For_Exit_File_Statement>":
            //    case "<Execute_Wait_For_Exit_String_Statement>":
            //    case "<Execute_Wait_For_Exit_Url_Statement>":
            //    case "<Execute_No_Wait_For_Exit_File_Statement>":
            //    case "<Execute_No_Wait_For_Exit_String_Statement>":
            //    case "<Execute_No_Wait_For_Exit_Url_Statement>":
            //        this.reduction = new Rule_Execute(pContext, T);
            //        break;
            //    case "<Beep_Statement>":
            //        this.reduction = new Rule_Beep(pContext, T);
            //        break;
            //    case "<Auto_Search_Statement>":
            //        this.reduction = new Rule_AutoSearch(pContext, T);
            //        break;
            //    case "<Quit_Statement>":
            //        this.reduction = new Rule_Quit(pContext);
            //        break;
            //    case "<Clear_Statement>":
            //        this.reduction = new Rule_Clear(pContext, T);
            //        break;
            //    case "<New_Record_Statement>":
            //        this.reduction = new Rule_NewRecord(pContext, T);
            //        break;
            //    case "<Simple_Undefine_Statement>":
            //        this.reduction = new Rule_Undefine(pContext, T);
            //        break;
            //    case "<Geocode_Statement>":
            //        this.reduction = new Rule_Geocode(pContext, T);
            //        break;
            //    case "<DefineVariables_Statement>":
            //        this.reduction = new Rule_DefineVariables_Statement(pContext, T);
            //        break;
            //    case "<Field_Checkcode_Statement>":
            //        this.reduction = new Rule_Field_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<View_Checkcode_Statement>":
            //        this.reduction = new Rule_View_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Record_Checkcode_Statement>":
            //        this.reduction = new Rule_Record_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Page_Checkcode_Statement>":
            //        this.reduction = new Rule_Page_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Subroutine_Statement>":
            //        this.reduction = new Rule_Subroutine_Statement(pContext, T);
            //        break;
            //    case "<Call_Statement>":
            //        this.reduction = new Rule_Call(pContext, T);
            //        break;
            //    case "<Simple_Run_Statement>":
            //    default:
            //        break;
            //}
        }
Ejemplo n.º 29
0
 public Rule_Always(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
 {
     // ALWAYS <Statements> END
     this.statements = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
 }
Ejemplo n.º 30
0
        //Epi.View View = null;

        //object ReturnResult = null;

        public Rule_Assign(Rule_Context pContext, NonterminalToken pTokens) : base(pContext)
        {
            //ASSIGN <Qualified ID> '=' <Expression>
            //<Let_Statement> ::= LET Identifier '=' <Expression>
            //<Simple_Assign_Statement> ::= Identifier '=' <Expression>
            //<Assign_DLL_Statement> ::= ASSIGN <Qualified ID> '=' identifier'!'<FunctionCall>
            string[]         temp;
            NonterminalToken T;

            switch (pTokens.Rule.Lhs.ToString())
            {
            case "<Assign_Statement>":
                T = (NonterminalToken)pTokens.Tokens[1];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }
                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[3]);
                if (!this.Context.AssignVariableCheck.ContainsKey(this.QualifiedId.ToLower()))
                {
                    this.Context.AssignVariableCheck.Add(this.QualifiedId.ToLower(), this.QualifiedId.ToLower());
                }
                break;

            case "<Let_Statement>":
                T = (NonterminalToken)pTokens.Tokens[1];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }


                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[3]);
                if (!this.Context.AssignVariableCheck.ContainsKey(this.QualifiedId.ToLower()))
                {
                    this.Context.AssignVariableCheck.Add(this.QualifiedId.ToLower(), this.QualifiedId.ToLower());
                }
                break;

            case "<Simple_Assign_Statement>":
                //Identifier '=' <Expression>
                //T = (NonterminalToken)pTokens.Tokens[1];
                T = (NonterminalToken)pTokens.Tokens[0];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }


                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
                if (!this.Context.AssignVariableCheck.ContainsKey(this.QualifiedId.ToLower()))
                {
                    this.Context.AssignVariableCheck.Add(this.QualifiedId.ToLower(), this.QualifiedId.ToLower());
                }
                break;
            }
        }