コード例 #1
0
 private If(Expr lhExpr, Relop relop, Expr rhExpr, Statement statement)
 {
     this.lhExpr    = lhExpr;
     this.relop     = relop;
     this.rhExpr    = rhExpr;
     this.statement = statement;
 }
コード例 #2
0
 public static If Parse(Input input, TextWriter output)
 {
     return(input.RewindOnNull(() =>
     {
         var cmd = input.Pop(KeywordIf);
         if (cmd == null)
         {
             return null;
         }
         var lhExpr = Expr.Parse(input, output);
         if (lhExpr == null)
         {
             output.WriteLine(MessageFormatter.Expected("expression"));
             return null;
         }
         var relop = Relop.Parse(input);
         if (relop == null)
         {
             output.WriteLine(MessageFormatter.Expected(Relop.Strings));
             return null;
         }
         var rhExpr = Expr.Parse(input, output);
         if (rhExpr == null)
         {
             output.WriteLine(MessageFormatter.Expected("expression"));
             return null;
         }
         var then = input.Pop(KeywordThen);
         if (then == null)
         {
             output.WriteLine(MessageFormatter.Expected(KeywordThen));
             return null;
         }
         var statement = Statement.Parse(input, output);
         if (statement == null)
         {
             output.WriteLine(MessageFormatter.Expected("statement"));
             return null;
         }
         return new If(lhExpr, relop, rhExpr, statement);
     }));
 }