void CreateCompileTimeConstants() { DTE2 dte = (DTE2)m_Package.GetInterface(typeof(DTE)); m_CompileTimeConstants = new VariableValueResolver(); m_CompileTimeConstants.SetVariable("true", true); m_CompileTimeConstants.SetVariable("false", false); m_CompileTimeConstants.SetVariable("dte_version", dte.Version); m_CompileTimeConstants.SetVariable("vs_version", DTEVersionToVSYear(dte.Version)); m_CompileTimeConstants.SetVariable("vs_edition", dte.Edition); }
protected internal override Value RecursiveCollectUnresolvedVariables(IEvalContext ctx) { SubExpressions[0].RecursiveCollectUnresolvedVariables(ctx); SubExpressions[1].RecursiveCollectUnresolvedVariables(ctx); string output = "X"; if (m_VariableName != null) { m_LocalContext = new VariableValueResolver(); m_LocalContext.SetVariable(m_VariableName, output); } return new StringValue(output); }
public override Value Evaluate(IEvalContext ctx) { string command = SubExpressions[0].Evaluate(ctx).ToString(); string workdir = SubExpressions[1].Evaluate(ctx).ToString(); string exec_output = m_Evaluator.Evaluate(m_ExecPeriodSecs, command, workdir); if (m_VariableName != null) { m_LocalContext = new VariableValueResolver(); m_LocalContext.SetVariable(m_VariableName, exec_output); } return new StringValue(exec_output); }
Expression Parse(string s) { try { VariableValueResolver compile_time_constants = new VariableValueResolver(); compile_time_constants.SetVariable("true", true); compile_time_constants.SetVariable("false", false); Parser parser = new Parser(s, compile_time_constants); return parser.Parse(); } catch (ParserException ex) { Console.WriteLine("Parser Exception:"); Console.WriteLine(ex.InputText); string indent = new string(' ', ex.ErrorPos); Console.WriteLine("{0}^", indent); Console.WriteLine("{0}{1}", indent, ex.ErrorMessage); throw ex; } }