public static FABuilder run ( Rule [ ] rules , IntBitSet terminals , StringArrayList symbolTable , PrintWriter verbose ) throws ActionException { FA alt ; int i ; Expander expander ; FABuilder builder ; Label label ; RegExpr expanded ; Minimizer minimizer ; expander = new Expander ( rules , symbolTable ) ; builder = new FABuilder ( symbolTable ) ; builder . fa = ( FA ) new Choice ( ) . visit ( builder ) ; if ( verbose != null ) { verbose . println ( "building NFA" ) ; } for ( i = 0 ; i < rules . length ; i ++ ) { if ( terminals . contains ( rules [ i ] . getLeft ( ) ) ) { expanded = ( RegExpr ) rules [ i ] . getRight ( ) . visit ( expander ) ; alt = ( FA ) expanded . visit ( builder ) ; label = new Label ( rules [ i ] . getLeft ( ) ) ; alt . setEndLabels ( label ) ; builder . fa . alternate ( alt ) ; } } if ( verbose != null ) { verbose . println ( "building DFA" ) ; } builder . fa = DFA . create ( builder . fa ) ; if ( verbose != null ) { verbose . println ( "complete DFA" ) ; } builder . errorSi = builder . fa . add ( null ) ; builder . fa = CompleteFA . create ( builder . fa , builder . errorSi ) ; if ( verbose != null ) { verbose . println ( "minimized DFA" ) ; } minimizer = new Minimizer ( builder . fa ) ; builder . fa = minimizer . run ( ) ; builder . errorSi = minimizer . getNewSi ( builder . errorSi ) ; builder . inlines = expander . getUsed ( ) ; if ( builder . fa . isEnd ( builder . fa . getStart ( ) ) ) { label = ( Label ) builder . fa . get ( builder . fa . getStart ( ) ) . getLabel ( ) ; throw new ActionException ( "Scanner accepts the empty word for symbol " + symbolTable . get ( label . getSymbol ( ) ) + ".\nThis is illegal because it might cause infinite loops when scanning." ) ; } return builder ; }
Translates only those rules where the left - hand . side is contained in the specified terminals set . The remaining rules are used for inlining .