private AstNode arrayComprehension(AstNode result,int pos) throws IOException {
  List<ArrayComprehensionLoop> loops=new ArrayList<ArrayComprehensionLoop>();
  while (peekToken() == Token.FOR) {
    loops.add(arrayComprehensionLoop());
  }
  int ifPos=-1;
  ConditionData data=null;
  if (peekToken() == Token.IF) {
    consumeToken();
    ifPos=ts.tokenBeg - pos;
    data=condition();
  }
  mustMatchToken(Token.RB,"msg.no.bracket.arg");
  ArrayComprehension pn=new ArrayComprehension(pos,ts.tokenEnd - pos);
  pn.setResult(result);
  pn.setLoops(loops);
  if (data != null) {
    pn.setIfPosition(ifPos);
    pn.setFilter(data.condition);
    pn.setFilterLp(data.lp - pos);
    pn.setFilterRp(data.rp - pos);
  }
  return pn;
}

private AstNode arrayComprehension ( AstNode result , int pos ) throws IOException { List < ArrayComprehensionLoop > loops = new ArrayList < ArrayComprehensionLoop > ( ) ; while ( peekToken ( ) == Token . FOR ) { loops . add ( arrayComprehensionLoop ( ) ) ; } int ifPos = - 1 ; ConditionData data = null ; if ( peekToken ( ) == Token . IF ) { consumeToken ( ) ; ifPos = ts . tokenBeg - pos ; data = condition ( ) ; } mustMatchToken ( Token . RB , "msg.no.bracket.arg" ) ; ArrayComprehension pn = new ArrayComprehension ( pos , ts . tokenEnd - pos ) ; pn . setResult ( result ) ; pn . setLoops ( loops ) ; if ( data != null ) { pn . setIfPosition ( ifPos ) ; pn . setFilter ( data . condition ) ; pn . setFilterLp ( data . lp - pos ) ; pn . setFilterRp ( data . rp - pos ) ; } return pn ; }
parse a javascript 1 . 7 array comprehension .
