private final void reduce ( ParserAction action ) throws ParserException { try { Production production = getGrammar ( ) . getProduction ( action . getParameter ( ) ) ; for ( int i = 0 ; i < production . getConstructions ( ) . size ( ) ; i ++ ) { /* * The for loop is run as many times as the production contains constructions * which are added up for an AST node. */ stateStack . pop ( ) ; } actionStack . add ( action ) ; ParserAction gotoAction = parserTable . getAction ( stateStack . peek ( ) , new NonTerminal ( production . getName ( ) ) ) ; if ( gotoAction . getAction ( ) == ActionType . ERROR ) { error ( ) ; return ; } stateStack . push ( gotoAction . getParameter ( ) ) ; } catch ( GrammarException e ) { logger . error ( e . getMessage ( ) , e ) ; throw new ParserException ( e . getMessage ( ) ) ; } }
This method is called for reduce actions .