protected virtual void StripWildCardAlts( ICollection<int> disabledAlts )
{
List<int> sortedDisableAlts = new List<int>( disabledAlts );
sortedDisableAlts.Sort();
//Collections.sort( sortedDisableAlts );
int lastAlt =
(int)sortedDisableAlts[sortedDisableAlts.Count - 1];
GrammarAST blockAST =
_dfa.Nfa.Grammar.GetDecisionBlockAST( _dfa.DecisionNumber );
//[email protected]("block with error = "+blockAST.toStringTree());
GrammarAST lastAltAST = null;
if ( blockAST.GetChild( 0 ).Type == ANTLRParser.OPTIONS )
{
// if options, skip first child: ( options { ( = greedy false ) )
lastAltAST = (GrammarAST)blockAST.GetChild( lastAlt );
}
else
{
lastAltAST = (GrammarAST)blockAST.GetChild( lastAlt - 1 );
}
//[email protected]("last alt is "+lastAltAST.toStringTree());
// if last alt looks like ( ALT . <end-of-alt> ) then wildcard
// Avoid looking at optional blocks etc... that have last alt
// as the EOB:
// ( BLOCK ( ALT 'else' statement <end-of-alt> ) <end-of-block> )
if ( lastAltAST.Type != ANTLRParser.EOB &&
lastAltAST.GetChild( 0 ).Type == ANTLRParser.WILDCARD &&
lastAltAST.GetChild( 1 ).Type == ANTLRParser.EOA )
{
//[email protected]("wildcard");
disabledAlts.Remove( lastAlt );
}
}