lib/jison/jison.js
function LALR_buildNewGrammar () {
        var self = this,
            newg = this.newg;

        this.states.forEach(function (state, i) {
            state.forEach(function (item) {
                if (item.dotPosition === 0) {
                    // new symbols are a combination of state and transition symbol
                    var symbol = i+":"+item.production.symbol;
                    self.terms_[symbol] = item.production.symbol;
                    newg.nterms_[symbol] = i;
                    if (!newg.nonterminals[symbol])
                        newg.nonterminals[symbol] = new Nonterminal(symbol);
                    var pathInfo = self.goPath(i, item.production.handle);
                    var p = new Production(symbol, pathInfo.path, newg.productions.length);
                    newg.productions.push(p);
                    newg.nonterminals[symbol].productions.push(p);

                    // store the transition that get's 'backed up to' after reduction on path
                    var handle = item.production.handle.join(' ');
                    var goes = self.states.item(pathInfo.endState).goes;
                    if (!goes[handle])
                        goes[handle] = [];
                    goes[handle].push(symbol);

                    //self.trace('new production:',p);
                }
            });
            if (state.inadequate)
                self.inadequateStates.push(i);
        });
    }
function LALR_buildNewGrammar () {
        var self = this,
            newg = this.newg;

        this.states.forEach(function (state, i) {
            state.forEach(function (item) {
                if (item.dotPosition === 0) {
                    // new symbols are a combination of state and transition symbol
                    var symbol = i+":"+item.production.symbol;
                    self.terms_[symbol] = item.production.symbol;
                    newg.nterms_[symbol] = i;
                    if (!newg.nonterminals[symbol])
                        newg.nonterminals[symbol] = new Nonterminal(symbol);
                    var pathInfo = self.goPath(i, item.production.handle);
                    var p = new Production(symbol, pathInfo.path, newg.productions.length);
                    newg.productions.push(p);
                    newg.nonterminals[symbol].productions.push(p);

                    // store the transition that get's 'backed up to' after reduction on path
                    var handle = item.production.handle.join(' ');
                    var goes = self.states.item(pathInfo.endState).goes;
                    if (!goes[handle])
                        goes[handle] = [];
                    goes[handle].push(symbol);

                    //self.trace('new production:',p);
                }
            });
            if (state.inadequate)
                self.inadequateStates.push(i);
        });
    }
function LALR_buildNewGrammar ( ) { var self = this , newg = this . newg ; this . states . forEach ( function ( state , i ) { state . forEach ( function ( item ) { if ( item . dotPosition === 0 ) { // new symbols are a combination of state and transition symbol var symbol = i + ":" + item . production . symbol ; self . terms_ [ symbol ] = item . production . symbol ; newg . nterms_ [ symbol ] = i ; if ( ! newg . nonterminals [ symbol ] ) newg . nonterminals [ symbol ] = new Nonterminal ( symbol ) ; var pathInfo = self . goPath ( i , item . production . handle ) ; var p = new Production ( symbol , pathInfo . path , newg . productions . length ) ; newg . productions . push ( p ) ; newg . nonterminals [ symbol ] . productions . push ( p ) ; // store the transition that get's 'backed up to' after reduction on path var handle = item . production . handle . join ( ' ' ) ; var goes = self . states . item ( pathInfo . endState ) . goes ; if ( ! goes [ handle ] ) goes [ handle ] = [ ] ; goes [ handle ] . push ( symbol ) ; //self.trace('new production:',p); } } ) ; if ( state . inadequate ) self . inadequateStates . push ( i ) ; } ) ; }
every disjoint reduction of a nonterminal becomes a produciton in G'
every disjoint reduction of a nonterminal becomes a produciton in G