Exemplo n.º 1
0
 private If(Expr lhExpr, Relop relop, Expr rhExpr, Statement statement)
 {
     this.lhExpr    = lhExpr;
     this.relop     = relop;
     this.rhExpr    = rhExpr;
     this.statement = statement;
 }
Exemplo n.º 2
0
        private static If NewMethod(Input input)
        {
            var cmd = input.Pop(new List <string> {
                KeywordIf
            });

            if (cmd == null)
            {
                return(null);
            }
            var lhExpr = Expr.Parse(input);

            if (lhExpr == null)
            {
                Console.WriteLine(MessageFormatter.Expected("expression"));
                return(null);
            }
            var relop = Relop.Parse(input);

            if (relop == null)
            {
                Console.WriteLine(string.Join("", MessageFormatter.Expected(Relop.Strings)));
                return(null);
            }
            var rhExpr = Expr.Parse(input);

            if (rhExpr == null)
            {
                Console.WriteLine(MessageFormatter.Expected("expression"));
                return(null);
            }
            var then = input.Pop(new List <string> {
                KeywordThen
            });

            if (then == null)
            {
                Console.WriteLine(MessageFormatter.Expected(KeywordThen));
                return(null);
            }
            var statement = Statement.Parse(input);

            if (statement == null)
            {
                Console.WriteLine(MessageFormatter.Expected("statement"));
                return(null);
            }
            return(new If(lhExpr, relop, rhExpr, statement));
        }