public PftRefFunction(PftParser.RefFunctionContext node)
     : base(node)
 {
     Argument1 = new PftArithExpression(node.arg1);
     Children.Add(Argument1);
     Argument2 = PftNonGrouped.DispatchContext(node.arg2);
     Children.Add(Argument2);
 }
 public PftContext WriteLine
 (
     PftAst node
 )
 {
     Output.WriteLine();
     return(this);
 }
 public PftFormatItemPlus(PftParser.FormatItemPlusContext node)
     : base(node)
 {
     foreach (PftParser.FormatItemContext context in node.formatItem())
     {
         PftAst item = PftNonGrouped.DispatchContext(context);
         Children.Add(item);
     }
 }
Beispiel #4
0
        public string Evaluate
        (
            PftAst ast
        )
        {
            PftContext copy = Push();

            ast.Execute(copy);
            return(copy.ToString());
        }
        public PftConditionString(PftParser.ConditionStringContext node)
            : base(node)
        {
            var context = node.stringTest();

            Left = PftNonGrouped.DispatchContext(context.left);
            Children.Add(Left);
            Op    = context.op.Text;
            Right = PftNonGrouped.DispatchContext(context.right);
            Children.Add(Right);
        }
 public PftContext WriteLine
 (
     PftAst node,
     string value
 )
 {
     if (!string.IsNullOrEmpty(value))
     {
         Output.WriteLine(value);
     }
     return(this);
 }
        /// <summary>
        /// Вычисление выражения во временной копии контекста.
        /// </summary>
        /// <param name="ast"></param>
        /// <returns></returns>
        public string Evaluate
        (
            PftAst ast
        )
        {
            PftContext copy = Push();

            ast.Execute(copy);
            string result = copy.ToString();

            Pop();
            return(result);
        }
 public PftContext WriteLine
 (
     PftAst node,
     string format,
     params object[] arg
 )
 {
     if (!string.IsNullOrEmpty(format))
     {
         Output.WriteLine(format, arg);
     }
     return(this);
 }
Beispiel #9
0
 public PftNonGrouped(PftParser.NonGroupedContext node)
     : base(node)
 {
     PftParser.FormatItemPlusContext plusContext = node as PftParser.FormatItemPlusContext;
     if (plusContext != null)
     {
         foreach (PftParser.FormatItemContext context in plusContext.formatItem())
         {
             PftAst item = DispatchContext(context);
             Children.Add(item);
         }
     }
     else
     {
         throw new ApplicationException();
     }
 }
Beispiel #10
0
        public AstText
        (
            PftAst node,
            string text
        )
        {
            if (ReferenceEquals(node, null))
            {
                throw new ArgumentNullException("node");
            }
            if (ReferenceEquals(text, null))
            {
                throw new ArgumentNullException("text");
            }

            Node = node;
            Text = text;
        }
Beispiel #11
0
 public void DiscoverChildren
 (
     ParserRuleContext context
 )
 {
     foreach (IParseTree node in context.children)
     {
         ParserRuleContext ctx = node as ParserRuleContext;
         if (ctx != null)
         {
             PftAst child = PftDispatcher.DispatchFormat(ctx);
             if (!ReferenceEquals(child, null))
             {
                 Children.Add(child);
             }
         }
     }
 }
        public AstTextCollection Write
        (
            PftAst node,
            string format,
            params object[] args
        )
        {
            if (ReferenceEquals(format, null))
            {
                throw new ArgumentNullException("format");
            }

            AstText item = new AstText
                           (
                node,
                string.Format(format, args)
                           );

            Add(item);

            return(this);
        }
 public PftRminFunction(PftParser.RminFunctionContext node)
     : base(node)
 {
     Argument = PftNonGrouped.DispatchContext(node.nonGrouped());
     Children.Add(Argument);
 }
 public PftFatalFunction(PftParser.FatalFunctionContext node)
     : base(node)
 {
     Argument = DispatchContext(node.nonGrouped());
     Children.Add(Argument);
 }
 public PftLFunction(PftParser.LFunctionContext node)
     : base(node)
 {
     Argument = PftNonGrouped.DispatchContext(node.nonGrouped());
 }