public AnalysisStatisticExecuteHost( Rule_Context Context, Dictionary<string, string> SetProperties, IDataSource DataSource, Dictionary<string, string> InputVariableList, string CurrentSQLStatement, IAnalysisInterpreterHost AnalysisInterpreterHost ) { this.mContext = Context; this.mSetProperties = SetProperties; this.mDataSource = DataSource; this.mInputVariableList = InputVariableList; this.mCurrentSQLStatement = CurrentSQLStatement; this.mAnalysisInterpreterHost = AnalysisInterpreterHost; }
/// <summary> /// Fills the inner table by fetching data, adding standard and global variables. /// </summary> /// <returns>DataTable</returns> public DataTable GetData(Rule_Context pContext) { string queryString = "select * " + this.GetSqlStatementPartFrom(pContext) + this.GetSqlStatementPartWhere() + this.GetSqlStatementPartSortBy(); Query query = Db.CreateQuery(queryString); return Db.Select(query); }
public static 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 AnalysisRule(Rule_Context context) { Context = context; }
public Rule_RunPGM(Rule_Context pContext, NonterminalToken pToken) : base(pContext) { }
private void Init(Stream stream) { 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); } mContext = new Rule_Context(); // this is done to ensure that the encourage copying of the Epi.Analysis.Statistics dll // to the build folder; //System.Console.WriteLine(Epi.Analysis.Statistics.Frequency.Equals(null,null)); }
public Rule_Run_PGM_In_Db_Statement(Rule_Context pContext, NonterminalToken pToken) : base(pContext, pToken) { this.file = this.GetCommandElement(pToken.Tokens, 1).Trim(new char[] { '\'', '"' }); this.identifier = this.GetCommandElement(pToken.Tokens, 3).Trim('"'); }
/// <summary> /// Tests the (partial) where clause that the user has entered by trying to execute an sql command /// </summary> /// <remarks> /// This was neccessary because, when the user put in the name of a nonexistant variable /// the user was getting errors from the underlying database that was less than helpful /// At this time it is called by select command and disallows the user to generate a where that doesn't work. /// Defect 187 /// </remarks> /// <param name="expression"></param> /// <returns>bool</returns> public bool ValidWhereClause(Rule_Context pContext, string expression) { try { string testExpression = expression; testExpression = testExpression.Replace(StringLiterals.EPI_REPRESENTATION_OF_TRUE, "1"); testExpression = testExpression.Replace(StringLiterals.EPI_REPRESENTATION_OF_FALSE, "0"); //DataRow[] rows = pContext.GetOutput().Select(testExpression); return true; } catch (Exception) { throw new GeneralException(string.Format(SharedStrings.INVALID_EXPRESSION, "\"" + expression.Trim() + "\"")); } }
/// <summary> /// from part /// </summary> /// <returns></returns> private string GetSqlStatementPartFrom(Rule_Context pContext) { string fromClause = " from " + pContext.CurrentRead.Identifier; foreach (JoinTable joinTable in JoinTableList) { fromClause += " inner join " + joinTable.Table.TableName; fromClause += " on " + joinTable.Condition; } return fromClause; }
/// <summary> /// Gets a count of records in a column /// </summary> /// <param name="columnName">Name of the column</param> /// <returns>Number of records in a column</returns> public int GetRecordCount(Rule_Context pContext, string columnName) { #region Input Validation if (string.IsNullOrEmpty(columnName)) { throw new ArgumentNullException("columnName"); } #endregion Input Validation WordBuilder queryBuilder = new WordBuilder(); queryBuilder.Append("select count" + Util.InsertInParantheses(columnName)); queryBuilder.Append(GetSqlStatementPartFrom(pContext)); if (Db.ColumnExists(PrimaryTable.TableName, ColumnNames.REC_STATUS)) { string whereStatement = GetSqlStatementPartWhere(); queryBuilder.Append(whereStatement); } else if (!string.IsNullOrEmpty(selectCriteria)) { string whereClause = " where " + this.selectCriteria; queryBuilder.Append(whereClause); } Query query = Db.CreateQuery(queryBuilder.ToString()); //recast to int before return to remove cast run time error int result = Int32.Parse((Db.ExecuteScalar(query)).ToString()); return result; }
/// <summary> /// Gets count of all the records in a table /// </summary> /// <returns>Number of records in a table</returns> public int GetRecordCount(Rule_Context pContext) { return GetRecordCount(pContext, StringLiterals.STAR); }
/// <summary> /// Gets the frequency table of a column /// </summary> /// <param name="variable"></param> /// <returns>The frequency table</returns> public DataTable GetFrequency(Rule_Context pContext, IVariable variable) { string columnName = variable.Name; string s = (string.IsNullOrEmpty(this.SqlStatementPartWhere)) ? " where " : " and "; string queryString = "select " + columnName + ", Count(*) AS " + ColumnNames.FREQUENCY; queryString += " From (select "; if (variable.VarType != VariableType.DataSource) { queryString += variable.Expression + " as "; } queryString += columnName + this.GetSqlStatementPartFrom(pContext) + this.GetSqlStatementPartWhere() + ") as TRecode Group by " + columnName; if (string.IsNullOrEmpty(queryString)) { return null; } else { Query query = Db.CreateQuery(queryString); return Db.Select(query); } }
/// <summary> /// Gets the frequencies of an outcome variable stratified by one or more strata /// </summary> /// <param name="var">The outcome variable (IVariable)</param> /// <param name="strata">An array of the names of strata variables</param> /// <param name="weightVar">Weighted variable.</param> /// <returns>The frequency table</returns> public DataSet GetFrequencies(Rule_Context pContext, IVariable var, string[] strata, string weightVar) { StringBuilder sb = new StringBuilder("select "); if (var.VarType != VariableType.DataSource) { sb.Append("(").Append(var.Expression).Append(") AS "); } sb.Append(var.Name).Append(", count(*) AS " + ColumnNames.FREQUENCY); if (!string.IsNullOrEmpty(weightVar)) //if weighted. { sb.Append(", sum(").Append(weightVar).Append(") as ").Append(ColumnNames.WEIGHT); } else { sb.Append(", 1 as ").Append(ColumnNames.WEIGHT); } if (strata != null) { foreach (string stratum in strata) { sb.Append(", ").Append(stratum); } } sb.Append(GetSqlStatementPartFrom(pContext)); string s = null; if (Db.ColumnExists(PrimaryTable.TableName, ColumnNames.REC_STATUS)) { s = GetSqlStatementPartWhere(); } else if (!string.IsNullOrEmpty(selectCriteria)) { s = " where " + this.selectCriteria; } if (!string.IsNullOrEmpty(s)) { sb.Append(s); } if (!Configuration.GetNewInstance().Settings.IncludeMissingValues && strata != null) { sb.Append((string.IsNullOrEmpty(s)) ? " where " : " and "); foreach (string stratum in strata) { sb.Append(stratum).Append(" is not null and "); } sb.Length -= 4; } sb.Append(" group by "); if (var.VarType == VariableType.DataSource) { sb.Append(var.Name); } else { sb.Append(var.Expression); } if (strata != null) { foreach (string stratum in strata) { sb.Append(", ").Append(stratum); } sb.Append(" order by "); foreach (string stratum in strata) { sb.Append(stratum).Append(","); } sb.Append(var.Name).Append(" desc;"); } string queryString = sb.ToString(); if (string.IsNullOrEmpty(queryString)) { return null; } else { DataSet ds = new DataSet("FreqDataSet"); if (strata != null) { ds.Tables.Add(DistinctStrata(pContext, strata)); } DataTable freq = Db.Select(Db.CreateQuery(queryString)); freq.TableName = "Frequencies"; ds.Tables.Add(freq); return ds; } }
/// <summary> /// Returns a 2x2 table for the tables command /// </summary> /// <remarks>The cells are numbered as they are in Epi3</remarks> /// <param name="outcome"></param> /// <param name="exposure"></param> /// <returns>DataTable</returns> public DataSet GetDataSet2x2(Rule_Context pContext, string exposure, string outcome) { DataSet ds = null; try { StringBuilder sb = new StringBuilder("select "); sb.Append(exposure).Append(" AS [").Append(ColumnNames.EXPOSURE).Append("], ["); sb.Append(outcome).Append("] AS [").Append(ColumnNames.OUTCOME); sb.Append("], count([").Append(outcome).Append("]) AS [").Append(ColumnNames.COUNT); sb.Append("] "); sb.Append(GetSqlStatementPartFrom(pContext)); //if there is no project, there will not be a column Rec Status if (PrimaryTable.Columns.Contains(ColumnNames.REC_STATUS)) { sb.Append(ExcludeMissing(GetSqlStatementPartWhere(), new string[] { exposure, outcome })); } //a natively read MDB, and SELECT chosen else if (!string.IsNullOrEmpty(selectCriteria)) { string whereClause = " where " + this.selectCriteria; sb.Append(ExcludeMissing(whereClause, new string[] { exposure, outcome })); } sb.Append(" group by [").Append(exposure).Append("], [").Append(outcome); sb.Append("] order by [").Append(exposure); sb.Append("], [").Append(outcome).Append("];"); DataTable Table2x2 = DBReadExecute.GetDataTable(pContext.CurrentRead.File, sb.ToString()); //Query query = Db.CreateQuery(sb.ToString()); //DataTable Table2x2 = Db.Select(query); Table2x2.TableName = "Table2x2"; ds = new DataSet("dsTable2x2"); ds.Tables.Add(Table2x2); //DataTable distinctOutcomes = DistinctColumn(outcome); //distinctOutcomes.TableName = "DistinctOutcomes"; //ds.Tables.Add(distinctOutcomes); } catch (Exception ex) { throw new GeneralException(SharedStrings.UNABLE_CREATE_2X2, ex); } return ds; }
public Rule_NonEmptyFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<AnalysisRule> 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); } }
public AnalysisOutput(Rule_Context context) { this.context = context; outputPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); outputPath = Path.Combine(outputPath, "AnalysisOutput.xml"); }
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); }
public AnalysisOutput(Rule_Context context, string outputPath) { this.context = context; this.outputPath = outputPath; }
public EpiDataReader(Rule_Context Context, System.Data.IDataReader Reader) { this.mContext = Context; this.mReader = Reader; }
public Rule_EmptyFunctionParameterList(Rule_Context pContext, NonterminalToken pToken) : base(pContext) { //<EmptyFunctionParameterList> ::= }
public Rule_Run_String_Statement(Rule_Context pContext, NonterminalToken pToken) : base(pContext, pToken) { this.identifier = this.GetCommandElement(pToken.Tokens, 1).Trim('"'); }
/// <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."); } } }
public Rule_Run_File_PGM_Statement(Rule_Context pContext, NonterminalToken pToken) : base(pContext, pToken) { this.file = this.GetCommandElement(pToken.Tokens, 1).Trim("'".ToCharArray()); }
/// <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<AnalysisRule>(); //this.paramList.Push(new Rule_NonEmptyFunctionParameterList(T, this.paramList)); new Rule_NonEmptyFunctionParameterList(pContext, T, this.paramList); break; case "<SingleFunctionParameterList>": this.paramList = new Stack<AnalysisRule>(); 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<AnalysisRule>(); //this.MultipleParameterList = new Rule_MultipleFunctionParameterList(pToken); new Rule_MultipleFunctionParameterList(pContext, T, this.paramList); break; } }
public AnalysisRule() { Context = new Rule_Context(); }
public Rule_MultipleFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<AnalysisRule> 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(AnalysisRule.BuildStatments(pContext, nonEmptyToken)); pList.Push(AnalysisRule.BuildStatments(pContext, ExpressionToken)); //pList.Push(this.Expression); }
public AnalysisRule(IMemoryRegion currentModule) { Context = new Rule_Context(currentModule); }
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<AnalysisRule>(); //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; } }
public static 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; //**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 "<Call_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; }
/// <summary> /// Get Data of a single column /// </summary> /// <remarks> /// If the variable is a defined variable, use the expression /// </remarks> /// <param name="var"></param> /// <returns></returns> public DataTable GetData(Rule_Context pContext, IVariable var) { StringBuilder sql = new StringBuilder("select "); if (var.VarType == VariableType.DataSource) { sql.Append("[").Append(var.Name).Append("]"); } else { sql.Append(var.Expression); } sql.Append(this.GetSqlStatementPartFrom(pContext)); sql.Append(this.GetSqlStatementPartWhere()); sql.Append(this.GetSqlStatementPartSortBy()); Query query = Db.CreateQuery(sql.ToString()); return Db.Select(query); }