public void addNullable ( IntBitSet result ) { IntBitSet remaining ; // indexes of productions boolean modified ; int i ; int prod ; int max ; remaining = new IntBitSet ( ) ; remaining . addRange ( 0 , getProductionCount ( ) - 1 ) ; do { modified = false ; for ( prod = remaining . first ( ) ; prod != - 1 ; prod = remaining . next ( prod ) ) { if ( result . contains ( getLeft ( prod ) ) ) { remaining . remove ( prod ) ; } else { max = getLength ( prod ) ; for ( i = 0 ; i < max ; i ++ ) { if ( ! result . contains ( getRight ( prod , i ) ) ) { break ; } } if ( i == max ) { result . add ( getLeft ( prod ) ) ; modified = true ; } } } } while ( modified ) ; }
Returns a symbols that can derive the empty word . Also called removable symbols