예제 #1
0
 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;
     }
 }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }