Example #1
0
        public Epi.Core.EnterInterpreter.Rule_Context GetCheckCodeObj(System.Xml.Linq.XDocument xdoc, System.Xml.Linq.XDocument xdocResponse, string FormCheckCode)
        {
            Epi.Core.EnterInterpreter.EpiInterpreterParser EIP    = new Epi.Core.EnterInterpreter.EpiInterpreterParser(Epi.Core.EnterInterpreter.EpiInterpreterParser.GetEnterCompiledGrammarTable());
            Epi.Core.EnterInterpreter.Rule_Context         result = (Epi.Core.EnterInterpreter.Rule_Context)EIP.Context;
            result.LoadTemplate(xdoc, xdocResponse);
            EIP.Execute(FormCheckCode);

            return(result);
        }
Example #2
0
        public Epi.Core.EnterInterpreter.Rule_Context GetRelateCheckCodeObj(List <Epi.Web.Common.Helper.RelatedFormsObj> Obj, string FormCheckCode)
        {
            Epi.Core.EnterInterpreter.EpiInterpreterParser EIP    = new Epi.Core.EnterInterpreter.EpiInterpreterParser(Epi.Core.EnterInterpreter.EpiInterpreterParser.GetEnterCompiledGrammarTable());
            Epi.Core.EnterInterpreter.Rule_Context         result = (Epi.Core.EnterInterpreter.Rule_Context)EIP.Context;
            foreach (var item in Obj)
            {
                result.LoadTemplate(item.MetaData, item.Response);
            }
            EIP.Execute(FormCheckCode);

            return(result);
        }
        private void Init(Stream stream, IScope pScope = null)
        {
            CGTReader reader = new CGTReader(stream);

            parser = reader.CreateNewParser();

            parser.StoreTokens    = LALRParser.StoreTokensMode.NoUserObject;
            parser.TrimReductions = false;
            parser.OnReduce      += new LALRParser.ReduceHandler(ReduceEvent);
            parser.OnTokenRead   += new LALRParser.TokenReadHandler(TokenReadEvent);
            parser.OnAccept      += new LALRParser.AcceptHandler(AcceptEvent);
            parser.OnTokenError  += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError  += new LALRParser.ParseErrorHandler(ParseErrorEvent);

            /*
             * Configuration config = null;
             *
             * // check to see if config is already loaded
             * // if NOT then load default
             * try
             * {
             *  config = Configuration.GetNewInstance();
             *
             *  if (config == null)
             *  {
             *      Configuration.Load(Configuration.DefaultConfigurationPath);
             *  }
             * }
             * catch
             * {
             *  // It may throw an error in the Configuration.GetNewInstanc()
             *  // so try this from the default config path
             *  Configuration.Load(Configuration.DefaultConfigurationPath);
             * }*/


            if (pScope == null)
            {
                mContext = new Rule_Context();
            }
            else
            {
                mContext = new Rule_Context(pScope);
            }
        }
Example #4
0
 public EnterRule(Rule_Context pContext)
 {
     this.Context = pContext;
 }
Example #5
0
        public static List<EnterRule> GetFunctionParameters(Rule_Context pContext, Token pToken)
        {
            List<EnterRule> result = new List<EnterRule>();

            if (pToken is NonterminalToken)
            {

                NonterminalToken NT = (NonterminalToken)pToken;

                switch (NT.Symbol.ToString())
                {
                    case "<NonEmptyFunctionParameterList>":

                        //this.paramList.Push(new Rule_NonEmptyFunctionParameterList(T, this.paramList));
                        result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                        break;
                    case "<SingleFunctionParameterList>":

                        result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                        break;
                    case "<EmptyFunctionParameterList>":
                        //this.paramList = new Rule_EmptyFunctionParameterList(T);
                        // do nothing the parameterlist is empty
                        break;
                    case "<MultipleFunctionParameterList>":

                        //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken);
                        //<NonEmptyFunctionParameterList> ',' <Expression>
                        //result.Add(AnalysisRule.BuildStatments(pContext, NT.Tokens[0]));
                        result.AddRange(EnterRule.GetFunctionParameters(pContext, NT.Tokens[0]));
                        result.Add(EnterRule.BuildStatments(pContext, NT.Tokens[2]));
                        break;
                    case "<FuncName2>":
                    case "<Expression>":
                    case "<expression>":
                    case "<FunctionCall>":
                    default:
                        result.Add(EnterRule.BuildStatments(pContext, NT));
                        break;
                }
            }
            else
            {
                TerminalToken TT = (TerminalToken)pToken;
                if (TT.Text != ",")
                {
                    result.Add(new Rule_Value(pContext, pToken));
                }
            }

            /*
                <FunctionCall> ::= Identifier '(' <FunctionParameterList> ')'
                   | FORMAT '(' <FunctionParameterList> ')'
                    | <FuncName2>
                !           | <FuncName1> '(' <FunctionCall> ')'
                <FunctionParameterList> ::= <EmptyFunctionParameterList> | <NonEmptyFunctionParameterList>
                <NonEmptyFunctionParameterList> ::= <MultipleFunctionParameterList> | <SingleFunctionParameterList>

                <MultipleFunctionParameterList> ::= <NonEmptyFunctionParameterList> ',' <Expression>
                <SingleFunctionParameterList> ::= <expression>
                <EmptyFunctionParameterList> ::=
             */
            /*
            foreach (Token T in pToken.Tokens)
            {
                if (T is NonterminalToken)
                {

                    NonterminalToken NT = (NonterminalToken)T;

                    switch (NT.Rule.Lhs.ToString())
                    {
                        case "<NonEmptyFunctionParameterList>":

                            //this.paramList.Push(new Rule_NonEmptyFunctionParameterList(T, this.paramList));
                            result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                            break;
                        case "<SingleFunctionParameterList>":

                            result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                            break;
                        case "<EmptyFunctionParameterList>":
                            //this.paramList = new Rule_EmptyFunctionParameterList(T);
                            // do nothing the parameterlist is empty
                            break;
                        case "<MultipleFunctionParameterList>":

                            //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken);
                            result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                            break;
                        case "<FuncName2>":
                        case "<Expression>":
                        case "<expression>":
                        case "<FunctionCall>":

                            result.Add(EnterRule.BuildStatments(pContext, NT));
                            break;
                        default:
                            result.Add(new Rule_Value(pContext, T));
                            break;
                    }
                }
                else
                {
                    TerminalToken TT = (TerminalToken)T;
                    if (TT.Text != ",")
                    {
                        result.Add(new Rule_Value(pContext, TT));
                    }
                }
            }*/

            return result;
        }
Example #6
0
 public EnterRule()
 {
     this.Context = new Rule_Context();
 }
Example #7
0
 public Rule_SingleFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<EnterRule> pList)
     : base(pContext)
 {
     //<SingleFunctionParameterList> ::= <Expression>
     this.Expression = new Rule_Expression(pContext, (NonterminalToken)pToken.Tokens[0]);
     pList.Push(this.Expression);
 }
Example #8
0
        public Rule_NonEmptyFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<EnterRule> pList)
            : base(pContext)
        {
            //<NonEmptyFunctionParameterList> ::= <MultipleFunctionParameterList>
            //<NonEmptyFunctionParameterList> ::= <SingleFunctionParameterList>
            NonterminalToken T = (NonterminalToken) pToken.Tokens[0];

            switch (T.Rule.Lhs.ToString())
            {
                case "<MultipleFunctionParameterList>":
                    new Rule_MultipleFunctionParameterList(pContext, T, pList);

                    break;
                case "<SingleFunctionParameterList>":
                    new Rule_SingleFunctionParameterList(pContext, T, pList);
                    break;
                default:

                    break;
            }

            if (pToken.Tokens.Length > 2)
            {
                Rule_Expression Expression = new Rule_Expression(pContext, (NonterminalToken)pToken.Tokens[2]);
                pList.Push(Expression);
            }
        }
Example #9
0
 public EnterRule(Rule_Context pContext)
 {
     this.Context = pContext;
 }
Example #10
0
        /// <summary>
        /// Constructor for Rule_FunctionParameterList
        /// </summary>
        /// <param name="pToken">The token to build the reduction with.</param>
        public Rule_FunctionParameterList(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //<FunctionParameterList> ::= <EmptyFunctionParameterList>
            //<FunctionParameterList> ::= <NonEmptyFunctionParameterList>

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

            switch (T.Rule.Lhs.ToString())
            {
                case "<NonEmptyFunctionParameterList>":
                    this.paramList = new Stack<EnterRule>();

                    //this.paramList.Push(new Rule_NonEmptyFunctionParameterList(T, this.paramList));
                    new Rule_NonEmptyFunctionParameterList(pContext, T, this.paramList);
                    break;
                case "<SingleFunctionParameterList>":
                    this.paramList = new Stack<EnterRule>();
                    new Rule_SingleFunctionParameterList(pContext, T, this.paramList);
                    break;
                case "<EmptyFunctionParameterList>":
                    //this.paramList = new Rule_EmptyFunctionParameterList(T);
                    // do nothing the parameterlist is empty
                    break;
                case "<MultipleFunctionParameterList>":
                    this.paramList = new Stack<EnterRule>();
                    //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken);
                    new Rule_MultipleFunctionParameterList(pContext, T, this.paramList);
                    break;
            }
        }
Example #11
0
        /// <summary>
        /// Constructor for Rule_FunctionCall
        /// </summary>
        /// <param name="pToken">The token to build the reduction with.</param>
        public Rule_FunctionCall(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*
            <FunctionCall> ::= <FuncName1> '(' <FunctionParameterList> ')'
                | <FuncName1> '(' <FunctionCall> ')'
                | <FuncName2>
             */

            NonterminalToken T;
            if (pToken.Tokens.Length == 1)
            {
                if (pToken.Rule.ToString().Equals("<FunctionCall>"))
                {
                    T = (NonterminalToken)pToken.Tokens[0];
                }
                else
                {
                    T = pToken;
                }
            }
            else
            {
                T = (NonterminalToken)pToken.Tokens[2];
            }

            string temp = null;
            string[] temp2 = null;

            if (pToken.Tokens[0] is NonterminalToken)
            {
                temp = this.ExtractTokens(((NonterminalToken)pToken.Tokens[0]).Tokens).Replace(" . ", ".");
                temp2 = temp.Split('.');

            }
            else
            {
                temp = ((TerminalToken)pToken.Tokens[0]).Text.Replace(" . ", ".");
            }

            if(temp2 != null && temp2.Length > 1)
            {
                this.ClassName = temp2[0].Trim();
                this.MethodName = temp2[1].Trim();

                this.ParameterList = EnterRule.GetFunctionParameters(pContext, (NonterminalToken)pToken.Tokens[2]);
            }
            else
            {
                functionName = this.GetCommandElement(pToken.Tokens, 0).ToString();

                switch (functionName.ToUpper())
                {
                    case "ABS":
                        functionCall = new Rule_Abs(pContext, T);
                        break;
                    case "COS":
                        functionCall = new Rule_Cos(pContext, T);
                        break;
                    case "CURRENTUSER":
                        functionCall = new Rule_CurrentUser(pContext, T);
                        break;
                    case "DAY":
                        functionCall = new Rule_Day(pContext, T);
                        break;
                    case "DAYS":
                        functionCall = new Rule_Days(pContext, T);
                        break;
                    case "FORMAT":
                        functionCall = new Rule_Format(pContext, T);
                        break;
                    case "HOUR":
                        functionCall = new Rule_Hour(pContext, T);
                        break;
                    case "HOURS":
                        functionCall = new Rule_Hours(pContext, T);
                        break;
                    case "ISUNIQUE":
                        functionCall = new Rule_IsUnique(pContext, T);
                        break;
                    case "LINEBREAK":
                        functionCall = new Rule_LineBreak(pContext, T);
                        break;
                    case "MINUTE":
                        functionCall = new Rule_Minute(pContext, T);
                        break;
                    case "MINUTES":
                        functionCall = new Rule_Minutes(pContext, T);
                        break;
                    case "MONTH":
                        functionCall = new Rule_Month(pContext, T);
                        break;
                    case "MONTHS":
                        functionCall = new Rule_Months(pContext, T);
                        break;
                    case "NUMTODATE":
                        functionCall = new Rule_NumToDate(pContext, T);
                        break;
                    case "NUMTOTIME":
                        functionCall = new Rule_NumToTime(pContext, T);
                        break;
                    case "RECORDCOUNT":
                        functionCall = new Rule_RecordCount(pContext, T);
                        break;
                    case "SECOND":
                        functionCall = new Rule_Second(pContext, T);
                        break;
                    case "SECONDS":
                        functionCall = new Rule_Seconds(pContext, T);
                        break;
                    case "SQRT":
                        functionCall = new Rule_SQRT_Func(pContext, T);
                        break;
                    case "SYSTEMDATE":
                        functionCall = new Rule_SystemDate(pContext, T);
                        break;
                    case "SYSTEMTIME":
                        functionCall = new Rule_SystemTime(pContext, T);
                        break;
                    case "TXTTODATE":
                        functionCall = new Rule_TxtToDate(pContext, T);
                        break;
                    case "TXTTONUM":
                        functionCall = new Rule_TxtToNum(pContext, T);
                        break;
                    case "YEAR":
                        functionCall = new Rule_Year(pContext, T);
                        break;
                    case "YEARS":
                        functionCall = new Rule_Years(pContext, T);
                        break;
                    case "SUBSTRING":
                        functionCall = new Rule_Substring(pContext, T);
                        break;
                    case "RND":
                        functionCall = new Rule_Rnd(pContext, T);
                        break;
                    case "EXP":
                        functionCall = new Rule_Exp_Func(pContext, T);
                        break;
                    case "LN":
                        functionCall = new Rule_LN_Func(pContext, T);
                        break;
                    case "ROUND":
                        functionCall = new Rule_Round(pContext, T);
                        break;
                    case "LOG":
                        functionCall = new Rule_LOG_Func(pContext, T);
                        break;
                    case "SIN":
                        functionCall = new Rule_Sin(pContext, T);
                        break;
                    case "TAN":
                        functionCall = new Rule_Tan(pContext, T);
                        break;
                    case "TRUNC":
                        functionCall = new Rule_TRUNC(pContext, T);
                        break;
                    case "STEP":
                        functionCall = new Rule_Step(pContext, T);
                        break;
                    case "UPPERCASE":
                        functionCall = new Rule_UpperCase(pContext, T);
                        break;
                    case "FINDTEXT":
                        functionCall = new Rule_FindText(pContext, T);
                        break;
                    case "ENVIRON":
                        functionCall = new Rule_FindText(pContext, T);
                        break;
                    case "EXISTS":
                        functionCall = new Rule_Exists(pContext, T);
                        break;
                    case "FILEDATE":
                        functionCall = new Rule_FileDate(pContext, T);
                        break;
                    case "ZSCORE":
                        functionCall = new Rule_ZSCORE(pContext, T);
                        break;
                    case "PFROMZ":
                        functionCall = new Rule_PFROMZ(pContext, T);
                        break;
                    case "EPIWEEK":
                        functionCall = new Rule_EPIWEEK(pContext, T);
                        break;
                    case "STRLEN":
                        functionCall = new Rule_STRLEN(pContext, T);
                        break;
                    case "GETCOORDINATES":
                        functionCall = new Rule_GetCoordinates(pContext, T);
                        break;
                    case "SENDSMS":
                        functionCall = new Rule_SendSMS(pContext, T);
                        break;
                    default:
                        throw new Exception("Function name " + functionName.ToUpper() + " is not a recognized function.");
                }
            }
        }
Example #12
0
 public Rule_EmptyFunctionParameterList(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //<EmptyFunctionParameterList> ::=
 }
 public Rule_Context()
 {
     this.currentScope = new SymbolTable("global", null);
     Rule_Context.LoadPermanentVariables(this.currentScope);
     this.Initialize();
 }
Example #14
0
        public static EnterRule BuildStatments(Rule_Context pContext, Token pToken)
        {
            EnterRule result = null;
            if (pToken is NonterminalToken)
            {
                NonterminalToken NT = (NonterminalToken)pToken;

                switch (NT.Symbol.ToString())
                {
                    // H1N1
                    case "<Program>":
                        result = new Rule_Program(pContext, NT);
                        break;
                    case "<Always_Statement>":
                        result  = new Rule_Always(pContext, NT);
                        break;

                    case "<Simple_Assign_Statement>":
                    case "<Let_Statement>":
                    case "<Assign_Statement>":
                        result  = new Rule_Assign(pContext, NT);
                        break;
                    case "<Assign_DLL_Statement>":
                        result  = new Rule_Assign_DLL_Statement(pContext, NT);
                        break;
                    case "<If_Statement>":
                    case "<If_Else_Statement>":
                        result  = new Rule_If_Then_Else_End(pContext, NT);
                        break;
                    case "<Else_If_Statement>":
                        result = new Rule_Else_If_Statement(pContext, NT);
                        break;
                    case "<Define_Variable_Statement>":
                        result  = new Rule_Define(pContext, NT);
                        break;
                    case "<Define_Dll_Statement>":
                        result = new Rule_DLL_Statement(pContext, NT);
                        break;
                    case "<FuncName2>":
                    case "<FunctionCall>":
                        result = new Rule_FunctionCall(pContext, NT);
                        break;

                    case "<Hide_Some_Statement>":
                    case "<Hide_Except_Statement>":
                        result  = new Rule_Hide(pContext, NT);
                        break;

                    case "<Unhide_Some_Statement>":
                    case "<Unhide_Except_Statement>":
                        result  = new Rule_UnHide(pContext, NT);
                        break;

                    case "<Go_To_Variable_Statement>":
                    case "<Go_To_Page_Statement>":
                    case "<Go_To_Form_Statement>":
                        result  = new Rule_GoTo(pContext, NT);
                        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_Time_Statement>":
                    case "<Dialog_DateTime_Statement>":
                    case "<Dialog_Date_Mask_Statement>":
                        result  = new Rule_Dialog(pContext, NT);
                        break;

                    case "<Comment_Line>":
                        result  = new Rule_CommentLine(pContext, NT);
                        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>":
                        result  = new Rule_Execute(pContext, NT);
                        break;
                    case "<Beep_Statement>":
                        result  = new Rule_Beep(pContext, NT);
                        break;
                    case "<Auto_Search_Statement>":
                        result  = new Rule_AutoSearch(pContext, NT);
                        break;
                    case "<Quit_Statement>":
                        result  = new Rule_Quit(pContext);
                        break;
                    case "<Clear_Statement>":
                        result  = new Rule_Clear(pContext, NT);
                        break;
                    case "<New_Record_Statement>":
                        result  = new Rule_NewRecord(pContext, NT);
                        break;
                    case "<Save_Record_Statement>":
                        result = new Rule_SaveRecord(pContext, NT);
                        break;
                    case "<Simple_Undefine_Statement>":
                        result  = new Rule_Undefine(pContext, NT);
                        break;
                    case "<Geocode_Statement>":
                        result  = new Rule_Geocode(pContext, NT);
                        break;
                    case "<DefineVariables_Statement>":
                        result  = new Rule_DefineVariables_Statement(pContext, NT);
                        break;
                    case "<Field_Checkcode_Statement>":
                        result  = new Rule_Field_Checkcode_Statement(pContext, NT);
                        break;
                    case "<View_Checkcode_Statement>":
                        result  = new Rule_View_Checkcode_Statement(pContext, NT);
                        break;
                    case "<Record_Checkcode_Statement>":
                        result  = new Rule_Record_Checkcode_Statement(pContext, NT);
                        break;
                    case "<Page_Checkcode_Statement>":
                        result  = new Rule_Page_Checkcode_Statement(pContext, NT);
                        break;
                    case "<Subroutine_Statement>":
                        result  = new Rule_Subroutine_Statement(pContext, NT);
                        break;
                    case "<Call_Statement>":
                        result  = new Rule_Call(pContext, NT);
                        break;
                    case "<Expr List>":
                        result = new Rule_ExprList(pContext, NT);
                        break;
                    case "<Expression>":
                        result = new Rule_Expression(pContext, NT);
                        break;
                    case "<And Exp>":
                        result = new Rule_AndExp(pContext, NT);
                        break;
                    case "<Not Exp>":
                        result = new Rule_NotExp(pContext, NT);
                        break;
                    case "<Compare Exp>":
                        result = new Rule_CompareExp(pContext, NT);
                        break;
                    case "<Concat Exp>":
                        result = new Rule_ConcatExp(pContext, NT);
                        break;
                    case "<Add Exp>":
                        result = new Rule_AddExp(pContext, NT);
                        break;
                    case "<Mult Exp>":
                        result = new Rule_MultExp(pContext, NT);
                        break;
                    case "<Pow Exp>":
                        result = new Rule_PowExp(pContext, NT);
                        break;
                    case "<Negate Exp>":
                        result = new Rule_NegateExp(pContext, NT);
                        break;
                    case "<Begin_Before_statement>":
                        result = new Rule_Begin_Before_Statement(pContext, NT);
                        break;
                    case "<Begin_After_statement>":
                        result = new Rule_Begin_After_Statement(pContext, NT);
                        break;
                    case "<Begin_Click_statement>":
                        result = new Rule_Begin_Click_Statement(pContext, NT);
                        break;
                    case "<CheckCodeBlock>":
                        result = new Rule_CheckCodeBlock(pContext, NT);
                        break;
                    case "<CheckCodeBlocks>":
                        result = new Rule_CheckCodeBlocks(pContext, NT);
                        break;
                    case "<Simple_Run_Statement>":
                        break;
                    case "<Statements>":
                        result = new Rule_Statements(pContext, NT);
                        break;
                    case "<Statement>":
                        result = new Rule_Statement(pContext, NT);
                        break;
                    case "<Define_Statement_Group>":
                        result = new Rule_Define_Statement_Group(pContext, NT);
                        break;
                    case "<Define_Statement_Type>":
                        result = new Rule_Define_Statement_Type(pContext, NT);
                        break;
                    case "<Highlight_Statement>":
                        result = new Rule_Highlight(pContext, NT);
                        break;
                    case "<UnHighlight_Statement>":
                        result = new Rule_UnHighlight(pContext, NT);
                        break;
                    case "<Enable_Statement>":
                        result = new Rule_Enable(pContext, NT);
                        break;
                    case "<Disable_Statement>":
                        result = new Rule_Disable(pContext, NT);
                        break;
                    case "<Set_Required_Statement>":
                        result = new Rule_SetRequired(pContext, NT);
                        break;
                    case "<Set_Not_Required_Statement>":
                        result = new Rule_SetNOTRequired(pContext, NT);
                        break;
                    case "<Value>":
                    default:
                        result = new Rule_Value(pContext, NT);
                        break;

                        //result = new Rule_Value(pContext, NT);
                        //throw new Exception("Missing rule in EnterRule.BuildStatments " + NT.Symbol.ToString());

                }

            }
            else // terminal token
            {
                TerminalToken TT = (TerminalToken)pToken;

                switch (TT.Symbol.ToString())
                {
                    case "<Value>":
                    default:
                        result = new Rule_Value(pContext, TT);
                        break;
                }
            }

            return result;
        }
Example #15
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);
        }
Example #16
0
        static public EnterRule BuildStatments(Rule_Context pContext, Token pToken)
        {
            EnterRule result = null;

            if (pToken is NonterminalToken)
            {
                NonterminalToken NT = (NonterminalToken)pToken;

                switch (NT.Symbol.ToString())
                {
                // H1N1
                case "<Program>":
                    result = new Rule_Program(pContext, NT);
                    break;

                case "<Always_Statement>":
                    result = new Rule_Always(pContext, NT);
                    break;

                case "<Simple_Assign_Statement>":
                case "<Let_Statement>":
                case "<Assign_Statement>":
                    result = new Rule_Assign(pContext, NT);
                    break;

                case "<Assign_DLL_Statement>":
                    result = new Rule_Assign_DLL_Statement(pContext, NT);
                    break;

                case "<If_Statement>":
                case "<If_Else_Statement>":
                    result = new Rule_If_Then_Else_End(pContext, NT);
                    break;

                case "<Else_If_Statement>":
                    result = new Rule_Else_If_Statement(pContext, NT);
                    break;

                case "<Define_Variable_Statement>":
                    result = new Rule_Define(pContext, NT);
                    break;

                case "<Define_Dll_Statement>":
                    result = new Rule_DLL_Statement(pContext, NT);
                    break;

                case "<FuncName2>":
                case "<FunctionCall>":
                    result = new Rule_FunctionCall(pContext, NT);
                    break;

                case "<Hide_Some_Statement>":
                case "<Hide_Except_Statement>":
                    result = new Rule_Hide(pContext, NT);
                    break;

                case "<Unhide_Some_Statement>":
                case "<Unhide_Except_Statement>":
                    result = new Rule_UnHide(pContext, NT);
                    break;

                case "<Go_To_Variable_Statement>":
                case "<Go_To_Page_Statement>":
                case "<Go_To_Form_Statement>":
                    result = new Rule_GoTo(pContext, NT);
                    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_Time_Statement>":
                case "<Dialog_DateTime_Statement>":
                case "<Dialog_Date_Mask_Statement>":
                    result = new Rule_Dialog(pContext, NT);
                    break;

                case "<Comment_Line>":
                    result = new Rule_CommentLine(pContext, NT);
                    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>":
                    result = new Rule_Execute(pContext, NT);
                    break;

                case "<Beep_Statement>":
                    result = new Rule_Beep(pContext, NT);
                    break;

                case "<Auto_Search_Statement>":
                    result = new Rule_AutoSearch(pContext, NT);
                    break;

                case "<Quit_Statement>":
                    result = new Rule_Quit(pContext);
                    break;

                case "<Clear_Statement>":
                    result = new Rule_Clear(pContext, NT);
                    break;

                case "<New_Record_Statement>":
                    result = new Rule_NewRecord(pContext, NT);
                    break;

                case "<Save_Record_Statement>":
                    result = new Rule_SaveRecord(pContext, NT);
                    break;

                case "<Simple_Undefine_Statement>":
                    result = new Rule_Undefine(pContext, NT);
                    break;

                case "<Geocode_Statement>":
                    result = new Rule_Geocode(pContext, NT);
                    break;

                case "<DefineVariables_Statement>":
                    result = new Rule_DefineVariables_Statement(pContext, NT);
                    break;

                case "<Field_Checkcode_Statement>":
                    result = new Rule_Field_Checkcode_Statement(pContext, NT);
                    break;

                case "<View_Checkcode_Statement>":
                    result = new Rule_View_Checkcode_Statement(pContext, NT);
                    break;

                case "<Record_Checkcode_Statement>":
                    result = new Rule_Record_Checkcode_Statement(pContext, NT);
                    break;

                case "<Page_Checkcode_Statement>":
                    result = new Rule_Page_Checkcode_Statement(pContext, NT);
                    break;

                case "<Subroutine_Statement>":
                    result = new Rule_Subroutine_Statement(pContext, NT);
                    break;

                case "<Call_Statement>":
                    result = new Rule_Call(pContext, NT);
                    break;

                case "<Expr List>":
                    result = new Rule_ExprList(pContext, NT);
                    break;

                case "<Expression>":
                    result = new Rule_Expression(pContext, NT);
                    break;

                case "<And Exp>":
                    result = new Rule_AndExp(pContext, NT);
                    break;

                case "<Not Exp>":
                    result = new Rule_NotExp(pContext, NT);
                    break;

                case "<Compare Exp>":
                    result = new Rule_CompareExp(pContext, NT);
                    break;

                case "<Concat Exp>":
                    result = new Rule_ConcatExp(pContext, NT);
                    break;

                case "<Add Exp>":
                    result = new Rule_AddExp(pContext, NT);
                    break;

                case "<Mult Exp>":
                    result = new Rule_MultExp(pContext, NT);
                    break;

                case "<Pow Exp>":
                    result = new Rule_PowExp(pContext, NT);
                    break;

                case "<Negate Exp>":
                    result = new Rule_NegateExp(pContext, NT);
                    break;

                case "<Begin_Before_statement>":
                    result = new Rule_Begin_Before_Statement(pContext, NT);
                    break;

                case "<Begin_After_statement>":
                    result = new Rule_Begin_After_Statement(pContext, NT);
                    break;

                case "<Begin_Click_statement>":
                    result = new Rule_Begin_Click_Statement(pContext, NT);
                    break;

                case "<CheckCodeBlock>":
                    result = new Rule_CheckCodeBlock(pContext, NT);
                    break;

                case "<CheckCodeBlocks>":
                    result = new Rule_CheckCodeBlocks(pContext, NT);
                    break;

                case "<Simple_Run_Statement>":
                    break;

                case "<Statements>":
                    result = new Rule_Statements(pContext, NT);
                    break;

                case "<Statement>":
                    result = new Rule_Statement(pContext, NT);
                    break;

                case "<Define_Statement_Group>":
                    result = new Rule_Define_Statement_Group(pContext, NT);
                    break;

                case "<Define_Statement_Type>":
                    result = new Rule_Define_Statement_Type(pContext, NT);
                    break;

                case "<Highlight_Statement>":
                    result = new Rule_Highlight(pContext, NT);
                    break;

                case "<UnHighlight_Statement>":
                    result = new Rule_UnHighlight(pContext, NT);
                    break;

                case "<Enable_Statement>":
                    result = new Rule_Enable(pContext, NT);
                    break;

                case "<Disable_Statement>":
                    result = new Rule_Disable(pContext, NT);
                    break;

                case "<Set_Required_Statement>":
                    result = new Rule_SetRequired(pContext, NT);
                    break;

                case "<Set_Not_Required_Statement>":
                    result = new Rule_SetNOTRequired(pContext, NT);
                    break;

                case "<Value>":
                default:
                    result = new Rule_Value(pContext, NT);
                    break;

                    //result = new Rule_Value(pContext, NT);
                    //throw new Exception("Missing rule in EnterRule.BuildStatments " + NT.Symbol.ToString());
                }
            }
            else // terminal token
            {
                TerminalToken TT = (TerminalToken)pToken;

                switch (TT.Symbol.ToString())
                {
                case "<Value>":
                default:
                    result = new Rule_Value(pContext, TT);
                    break;
                }
            }

            return(result);
        }
Example #17
0
        public Rule_NonEmptyFunctionParameterList(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //<NonEmptyFunctionParameterList> ::= <MultipleFunctionParameterList>
            //<NonEmptyFunctionParameterList> ::= <SingleFunctionParameterList>
            NonterminalToken T = (NonterminalToken) pToken.Tokens[0];

            switch (T.Rule.Lhs.ToString())
            {
                case "<MultipleFunctionParameterList>":
                    this.MultipleParameterList = new Stack<EnterRule>();
                    //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken);
                    new Rule_MultipleFunctionParameterList(pContext, T, this.MultipleParameterList);
                    break;
                case "<SingleFunctionParameterList>":
                    //this.SingleParameterList = new Rule_SingleFunctionParameterList(pToken);
                    new Rule_SingleFunctionParameterList(pContext, T, this.MultipleParameterList);
                    break;
            }
        }
Example #18
0
        static public List <EnterRule> GetFunctionParameters(Rule_Context pContext, Token pToken)
        {
            List <EnterRule> result = new List <EnterRule>();

            if (pToken is NonterminalToken)
            {
                NonterminalToken NT = (NonterminalToken)pToken;

                switch (NT.Symbol.ToString())
                {
                case "<NonEmptyFunctionParameterList>":


                    //this.paramList.Push(new Rule_NonEmptyFunctionParameterList(T, this.paramList));
                    result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                    break;

                case "<SingleFunctionParameterList>":

                    result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
                    break;

                case "<EmptyFunctionParameterList>":
                    //this.paramList = new Rule_EmptyFunctionParameterList(T);
                    // do nothing the parameterlist is empty
                    break;

                case "<MultipleFunctionParameterList>":

                    //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken);
                    //<NonEmptyFunctionParameterList> ',' <Expression>
                    //result.Add(AnalysisRule.BuildStatments(pContext, NT.Tokens[0]));
                    result.AddRange(EnterRule.GetFunctionParameters(pContext, NT.Tokens[0]));
                    result.Add(EnterRule.BuildStatments(pContext, NT.Tokens[2]));
                    break;

                case "<FuncName2>":
                case "<Expression>":
                case "<expression>":
                case "<FunctionCall>":
                default:
                    result.Add(EnterRule.BuildStatments(pContext, NT));
                    break;
                }
            }
            else
            {
                TerminalToken TT = (TerminalToken)pToken;
                if (TT.Text != ",")
                {
                    result.Add(new Rule_Value(pContext, pToken));
                }
            }


            /*
             *  <FunctionCall> ::= Identifier '(' <FunctionParameterList> ')'
             | FORMAT '(' <FunctionParameterList> ')'
             | <FuncName2>
             |  !           | <FuncName1> '(' <FunctionCall> ')'
             |  <FunctionParameterList> ::= <EmptyFunctionParameterList> | <NonEmptyFunctionParameterList>
             |  <NonEmptyFunctionParameterList> ::= <MultipleFunctionParameterList> | <SingleFunctionParameterList>
             |
             |  <MultipleFunctionParameterList> ::= <NonEmptyFunctionParameterList> ',' <Expression>
             |  <SingleFunctionParameterList> ::= <expression>
             |  <EmptyFunctionParameterList> ::=
             */
            /*
             * foreach (Token T in pToken.Tokens)
             * {
             *  if (T is NonterminalToken)
             *  {
             *
             *      NonterminalToken NT = (NonterminalToken)T;
             *
             *      switch (NT.Rule.Lhs.ToString())
             *      {
             *          case "<NonEmptyFunctionParameterList>":
             *
             *
             *              //this.paramList.Push(new Rule_NonEmptyFunctionParameterList(T, this.paramList));
             *              result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
             *              break;
             *          case "<SingleFunctionParameterList>":
             *
             *              result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
             *              break;
             *          case "<EmptyFunctionParameterList>":
             *              //this.paramList = new Rule_EmptyFunctionParameterList(T);
             *              // do nothing the parameterlist is empty
             *              break;
             *          case "<MultipleFunctionParameterList>":
             *
             *              //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken);
             *              result.AddRange(EnterRule.GetFunctionParameters(pContext, NT));
             *              break;
             *          case "<FuncName2>":
             *          case "<Expression>":
             *          case "<expression>":
             *          case "<FunctionCall>":
             *
             *              result.Add(EnterRule.BuildStatments(pContext, NT));
             *              break;
             *          default:
             *              result.Add(new Rule_Value(pContext, T));
             *              break;
             *      }
             *  }
             *  else
             *  {
             *      TerminalToken TT = (TerminalToken)T;
             *      if (TT.Text != ",")
             *      {
             *          result.Add(new Rule_Value(pContext, TT));
             *      }
             *  }
             * }*/



            return(result);
        }
        private void Init(Stream stream, IScope pScope = null)
        {
            CGTReader reader = new CGTReader(stream);

            parser = reader.CreateNewParser();

            parser.StoreTokens = LALRParser.StoreTokensMode.NoUserObject;
            parser.TrimReductions = false;
            parser.OnReduce += new LALRParser.ReduceHandler(ReduceEvent);
            parser.OnTokenRead += new LALRParser.TokenReadHandler(TokenReadEvent);
            parser.OnAccept += new LALRParser.AcceptHandler(AcceptEvent);
            parser.OnTokenError += new LALRParser.TokenErrorHandler(TokenErrorEvent);
            parser.OnParseError += new LALRParser.ParseErrorHandler(ParseErrorEvent);

            Configuration config = null;

            // check to see if config is already loaded
            // if NOT then load default
            try
            {
                config = Configuration.GetNewInstance();

                if (config == null)
                {
                    Configuration.Load(Configuration.DefaultConfigurationPath);
                }
            }
            catch
            {
                // It may throw an error in the Configuration.GetNewInstanc()
                // so try this from the default config path
                Configuration.Load(Configuration.DefaultConfigurationPath);
            }
            if (pScope == null)
            {
                RuleContext = new Rule_Context();
            }
            else
            {
                RuleContext = new Rule_Context(pScope);
            }
        }