private void AcceptEvent(LALRParser parser, AcceptEventArgs args) { NonterminalToken T = (NonterminalToken)args.Token; mContext.AnalysisCheckCodeInterface = this.AnalysisCheckCodeInterface; this.Context.AnalysisInterpreterHost = this; AnalysisRule program = AnalysisRule.BuildStatments(mContext, T); if (this.IsExecuteMode) { program.Execute(); } this.ProgramStart = null; }
static public List <AnalysisRule> GetFunctionParameters(Rule_Context context, Token token) { List <AnalysisRule> result = new List <AnalysisRule>(); if (token is NonterminalToken) { NonterminalToken nonterminal = (NonterminalToken)token; switch (nonterminal.Symbol.ToString()) { case "<NonEmptyFunctionParameterList>": result.AddRange(AnalysisRule.GetFunctionParameters(context, nonterminal)); break; case "<SingleFunctionParameterList>": result.AddRange(AnalysisRule.GetFunctionParameters(context, nonterminal)); break; case "<EmptyFunctionParameterList>": break; case "<MultipleFunctionParameterList>": result.AddRange(AnalysisRule.GetFunctionParameters(context, nonterminal.Tokens[0])); result.Add(AnalysisRule.BuildStatments(context, nonterminal.Tokens[2])); break; case "<FuncName2>": case "<Expression>": case "<expression>": case "<FunctionCall>": default: result.Add(AnalysisRule.BuildStatments(context, nonterminal)); break; } } else { TerminalToken terminal = (TerminalToken)token; if (terminal.Text != ",") { result.Add(new Rule_Value(context, token)); } } return(result); }
public TreeNode(AnalysisRule pValue) { this.Value = pValue; }
public Rule_SingleFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<AnalysisRule> pList) : base(pContext) { //<SingleFunctionParameterList> ::= <Expression> this.Expression = new Rule_Expression(pContext, (NonterminalToken)pToken.Tokens[0]); pList.Push(this.Expression); }
/// <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 = AnalysisRule.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 "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 "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 "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 "STRLEN": functionCall = new Rule_STRLEN(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 "SQRT": functionCall = new Rule_SQRT_Func(pContext, T); break; case "POISSONLCL": functionCall = new Rule_POISSONLCL_Func(pContext, T); break; case "POISSONUCL": functionCall = new Rule_POISSONUCL_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_Environ(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; default: throw new Exception("Function name " + functionName.ToUpper() + " is not a recognized function."); } } }
static public AnalysisRule BuildStatments(Rule_Context context, Token token) { AnalysisRule result = null; if (token is NonterminalToken) { NonterminalToken nonterminal = (NonterminalToken)token; switch (nonterminal.Symbol.ToString()) { case "<Statements>": result = new Rule_Statements(context, nonterminal); break; case "<Statement>": result = new Rule_Statement(context, nonterminal); break; case "<Always_Statement>": result = new Rule_Always(context, nonterminal); break; case "<Simple_Assign_Statement>": case "<Let_Statement>": case "<Assign_Statement>": result = new Rule_Assign(context, nonterminal); break; case "<Assign_DLL_Statement>": result = new Rule_Assign_DLL_Statement(context, nonterminal); break; case "<If_Statement>": case "<If_Else_Statement>": result = new Rule_If_Then_Else_End(context, nonterminal); break; case "<Define_Variable_Statement>": result = new Rule_Define(context, nonterminal); break; case "<FuncName2>": case "<FunctionCall>": result = new Rule_FunctionCall(context, nonterminal); 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>": result = new Rule_Dialog(context, nonterminal); break; case "<Read_Epi_Statement>": case "<Simple_Read_Statement>": case "<Read_Epi_File_Spec_Statement>": case "<Read_Sql_Statement>": case "<Read_Excel_File_Statement>": case "<Read_Db_Table_Statement>": result = new Rule_Read(context, nonterminal); break; case "<Merge_Table_Statement>": case "<Merge_Db_Table_Statement>": case "<Merge_File_Statement>": case "<Merge_Excel_File_Statement>": result = new Rule_Merge(context, nonterminal); break; case "<Write_All_Statement>": case "<Write_Some_Statement>": case "<Write_Except_Statement>": result = new Rule_Write(context, nonterminal); break; case "<Select_Statement>": case "<Cancel_Select_By_Selecting_Statement>": case "<Cancel_Select_Statement>": result = new Rule_Select(context, nonterminal); break; case "<Recode_Statement>": result = new Rule_Recode(context, nonterminal); break; case "<Comment_Line>": result = new Rule_CommentLine(context, nonterminal); break; case "<Execute_Statement>": result = new Rule_Execute(context, nonterminal); break; case "<Report_Display_Statement>": case "<Report_File_Statement>": case "<Report_Print_Statement>": result = new Rule_Report(context, nonterminal); break; case "<List_Statement>": result = new Rule_List(context, nonterminal); break; case "<Simple_Tables_Statement>": case "<Tables_One_Variable_Statement>": case "<Row_All_Tables_Statement>": case "<Row_Except_Tables_Statement>": case "<Column_All_Tables_Statement>": case "<Column_Except_Tables_Statement>": case "<Row_Column_Tables_Statement>": result = new Rule_Tables(context, nonterminal); break; case "<Freq_All_Statement>": case "<Freq_Columns_Statement>": case "<Freq_All_Except_Statement>": result = new Rule_Freq(context, nonterminal); break; case "<Cancel_Sort_By_Sorting_Statement>": case "<Cancel_Sort_Statement>": case "<Sort_Statement>": result = new Rule_Sort(context, nonterminal); break; case "<Means_Statement>": result = new Rule_Means(context, nonterminal); break; case "<Relate_Epi_Table_Statement>": case "<Relate_Table_Statement>": case "<Relate_Db_Table_With_Identifier_Statement>": case "<Relate_Db_Table_Statement>": case "<Relate_File_Statement>": case "<Relate_Excel_File_Statement>": result = new Rule_Relate(context, nonterminal); break; case "<Beep_Statement>": result = new Rule_Beep(context, nonterminal); break; case "<Quit_Statement>": result = new Rule_Quit(context, nonterminal); break; case "<Delete_Table_Long_Statement>": result = new Rule_Delete_Table_Long(context, nonterminal); break; case "<Delete_File_Statement>": result = new Rule_Delete_File(context, nonterminal); break; case "<Delete_Table_Statement>": result = new Rule_Delete_Table(context, nonterminal); break; case "<Type_Out_String_Statement>": case "<Type_Out_File_Statement>": case "<Type_Out_String_With_Font_Statement>": case "<Type_Out_File_With_Font_Statement>": result = new Rule_Typeout(context, nonterminal); break; case "<Simple_Routeout_Statement>": case "<Replace_Routeout_Statement>": case "<Append_Routeout_Statement>": result = new Rule_RouteOut(context, nonterminal); break; case "<Close_Out_Statement>": result = new Rule_CloseOut(context, nonterminal); break; case "<Variables_Display_Statement>": case "<Views_Display_Statement>": case "<Tables_Display_Statement>": result = new Rule_Display(context, nonterminal); break; case "<Header_Title_String_Statement>": case "<Header_Title_Font_Statement>": case "<Header_Title_String_And_Font_Statement>": result = new Rule_Header(context, nonterminal); break; case "<Simple_Undefine_Statement>": result = new Rule_Undefine(context, nonterminal); break; case "<Run_File_PGM_Statement>": result = new Rule_Run_File_PGM_Statement(context, nonterminal); break; case "<Run_String_Statement>": result = new Rule_Run_String_Statement(context, nonterminal); break; case "<Run_PGM_In_Db_Statement>": result = new Rule_Run_PGM_In_Db_Statement(context, nonterminal); break; case "<Delete_Records_All_Statement>": result = new Rule_Delete_Records_All_Statement(context, nonterminal); break; case "<Delete_Records_Selected_Statement>": result = new Rule_Delete_Records_Selected_Statement(context, nonterminal); break; case "<Simple_Print_Out_Statement>": case "<File_Print_Out_Statement>": result = new Rule_Printout(context, nonterminal); break; case "<SQL_Execute_Command>": result = new Rule_SQLExec(context, nonterminal); break; case "<RecordSet_Command>": result = new Rule_RecordSet(context, nonterminal); break; case "<Define_Connection_Command>": result = new Rule_Define_Connection(context, nonterminal); break; case "<Regress_Statement>": result = new Rule_LinearRegression(context, nonterminal); break; case "<Logistic_Statement>": result = new Rule_LogisticRegression(context, nonterminal); break; case "<CoxPH_Statement>": result = new Rule_CoxPH(context, nonterminal); break; case "<KM_Survival_Statement>": result = new Rule_KMSurvival(context, nonterminal); break; case "<Define_Dll_Statement>": result = new Rule_DLL_Statement(context, nonterminal); break; case "<Define_Group_Statement>": result = new Rule_Define_Group(context, nonterminal); break; case "<Summarize_Statement>": result = new Rule_Summarize(context, nonterminal); break; case "<Set_Statement>": result = new Rule_Set(context, nonterminal); break; case "<Match_Row_All_Statement>": case "<Match_Row_Except_Statement>": case "<Match_Column_All_Statement>": case "<Match_Column_Except_Statement>": case "<Match_Row_Column_Statement>": result = new Rule_Match(context, nonterminal); break; case "<Graph_Statement>": case "<Simple_Graph_Statement>": case "<Strata_Var_Graph_Statement>": case "<Weight_Var_Graph_Statement>": case "<Stra_Wei_Var_Graph_Statement>": case "<Graph_Opt_1_Statement>": case "<Graph_Opt_2_Statement>": case "<Graph_Opt_3_Statement>": case "<Graph_Opt_4_Statement>": case "<Graph_Opt_5_Statement>": case "<Graph_Generic_Opt_Statement>": result = new Rule_Graph(context, nonterminal); break; case "<Expr List>": result = new Rule_ExprList(context, nonterminal); break; case "<Expression>": result = new Rule_Expression(context, nonterminal); break; case "<And Exp>": result = new Rule_AndExp(context, nonterminal); break; case "<Not Exp>": result = new Rule_NotExp(context, nonterminal); break; case "<Compare Exp>": result = new Rule_CompareExp(context, nonterminal); break; case "<Concat Exp>": result = new Rule_ConcatExp(context, nonterminal); break; case "<Add Exp>": result = new Rule_AddExp(context, nonterminal); break; case "<Mult Exp>": result = new Rule_MultExp(context, nonterminal); break; case "<Pow Exp>": result = new Rule_PowExp(context, nonterminal); break; case "<Negate Exp>": result = new Rule_NegateExp(context, nonterminal); break; default: case "<Value>": result = new Rule_Value(context, nonterminal); break; case "<Undelete_All_Statement>": result = new Rule_UnDelete(context, nonterminal); break; case "<QualifiedIdList>": result = new Rule_QualifiedIdList(context, nonterminal); break; case "<Subroutine_Statement>": result = new Rule_Subroutine_Statement(context, nonterminal); break; case "<Call_Statement>": result = new Rule_Call(context, nonterminal); break; //**these are not yet implemented; move up when completed //**these are not yet implemented; move up when completed //**these are not yet implemented; move up when completed //**these are not yet implemented; move up when completed //**these are not yet implemented; move up when completed case "<Simple_Run_Statement>": case "<About_Statement>": case "<Browser_Statement>": case "<Browser_Size_Statement>": case "<Button_Offset_Size_1_Statement>": case "<Button_Offset_Size_2_Statement>": case "<Button_Offset_1_Statement>": case "<Button_Offset_2_Statement>": case "<Simple_CMD_Statement>": case "<CMD_Line_Statement>": case "<Delete_Table_Short_Statement>": case "<Exit_Statement>": case "<File_Dialog_Statement>": case "<Get_Path_Statement>": case "<Help_File_Statement>": case "<Simple_Help_Statement>": case "<Link_Statement>": case "<Link_Remove_Statement>": case "<Map_AVG_Statement>": case "<Map_Case_Statement>": case "<Map_Sum_Statement>": case "<Map_Count_Statement>": case "<Map_Min_Statement>": case "<Map_Max_Statement>": case "<Map_Opt_1_Statement>": case "<Map_Opt_2_Statement>": case "<Map_Opt_3_Statement>": case "<Map_Opt_4_Statement>": case "<Map_Opt_5_Statement>": case "<Menu_Statement>": case "<Menu_Command_Statement>": case "<Menu_Dialog_Statement>": case "<Menu_Execute_Statement>": case "<Menu_Item_Block_Name_Statement>": case "<Menu_Item_Separator_Statement>": case "<Menu_Replace_Statement>": case "<Move_Buttons_Statement>": case "<New_Page_Statement>": case "<On_Browser_Exit_Block>": case "<Picture_Statement>": case "<Picture_Size_Statement>": case "<Popup_Statement>": case "<Repeat_Statement>": case "<Screen_Text_Statement>": case "<Set_Buttons_Statement>": case "<Set_DB_Version_Statement>": case "<Set_DOS_Win_Statement>": case "<Set_Import_Year_Statement>": case "<Set_Ini_Dir_Statement>": case "<Set_Language_Statement>": case "<Set_Picture_Statement>": case "<Set_Work_Dir_Statement>": case "<ShutDown_Block>": case "<Startup_Block>": case "<Sys_Info_Statement>": case "<All_Standard_Undefine_Statement>": case "<All_Global_Undefine_Statement>": case "<Wait_For_Statement>": case "<Wait_For_Exit_Statement>": case "<Wait_For_File_Exists_Statement>": case "<Command_Block>": case "<On_Browser_Exit_Empty_Block>": case "<Startup_Empty_Block>": case "<ShutDown_Empty_Block>": case "<Menu_Empty_Block>": case "<Popup_Empty_Block>": case "<Empty_Command_Block>": break; } } else // terminal token { TerminalToken terminal = (TerminalToken)token; switch (terminal.Symbol.ToString()) { case "<Value>": default: result = new Rule_Value(context, terminal); break; } } return(result); }
public Rule_RecodeList(Rule_Context pContext, NonterminalToken pToken) : base(pContext) { //<Recode> //<RecodeList> <Recode> NonterminalToken RecodeToken = (NonterminalToken)pToken.Tokens[0]; if (pToken.Tokens.Length > 1) { this.RecodeList = new Rule_RecodeList(pContext, (NonterminalToken)pToken.Tokens[0]); RecodeToken = (NonterminalToken)pToken.Tokens[1]; } //"<Recode_F> | <Recode_G> | <Recode_H> | <Recode_I> | <Recode_J> | <Recode_K> | <Recode_L> | <Recode_M> | <Recode_N>" switch (RecodeToken.Rule.Rhs[0].ToString()) { case "<Recode_A>": this.Recode = new Rule_Recode_A(pContext, RecodeToken); break; case "<Recode_B>": this.Recode = new Rule_Recode_B(pContext, RecodeToken); break; case "<Recode_C>": this.Recode = new Rule_Recode_C(pContext, RecodeToken); break; case "<Recode_D>": this.Recode = new Rule_Recode_D(pContext, RecodeToken); break; case "<Recode_E>": this.Recode = new Rule_Recode_E(pContext, RecodeToken); break; case "<Recode_F>": this.Recode = new Rule_Recode_F(pContext, RecodeToken); break; case "<Recode_G>": this.Recode = new Rule_Recode_G(pContext, RecodeToken); break; case "<Recode_H>": this.Recode = new Rule_Recode_H(pContext, RecodeToken); break; case "<Recode_I>": this.Recode = new Rule_Recode_I(pContext, RecodeToken); break; case "<Recode_J>": this.Recode = new Rule_Recode_J(pContext, RecodeToken); break; case "<Recode_K>": this.Recode = new Rule_Recode_K(pContext, RecodeToken); break; case "<Recode_L>": this.Recode = new Rule_Recode_L(pContext, RecodeToken); break; case "<Recode_M>": this.Recode = new Rule_Recode_M(pContext, RecodeToken); break; case "<Recode_N>": this.Recode = new Rule_Recode_N(pContext, RecodeToken); break; default: //Should not be here break; } }