Example #1
0
 private List<Node> whenBlock() {
   expect(Indent.class);
   List<Node> caseConditionalNodes = new LinkedList<Node>();
   while (!(peek() instanceof Outdent) && !(peek() instanceof Eos)) {
     if (peek() instanceof Newline) {
       nextToken();
     } else {
       caseConditionalNodes.add(this.parseCaseCondition());
     }
   }
   if (peek() instanceof Outdent) {
     expect(Outdent.class);
   }
   return caseConditionalNodes;
 }
Example #2
0
 private Node block() {
   BlockNode block = new BlockNode();
   block.setLineNumber(lexer.getLineno());
   block.setFileName(filename);
   expect(Indent.class);
   while (!(peek() instanceof Outdent) && !(peek() instanceof Eos)) {
     if (peek() instanceof Newline) {
       nextToken();
     } else {
       Node parseExpr = this.parseExpr();
       if (parseExpr != null) {
         block.push(parseExpr);
       }
     }
   }
   if (peek() instanceof Outdent) {
     expect(Outdent.class);
   }
   return block;
 }