Antlr3.Analysis.DFAState.GetGatedPredicatesInNFAConfigurations C# (CSharp) Method

GetGatedPredicatesInNFAConfigurations() public method

public GetGatedPredicatesInNFAConfigurations ( ) : Antlr3.Analysis.SemanticContext
return Antlr3.Analysis.SemanticContext
        public virtual SemanticContext GetGatedPredicatesInNFAConfigurations()
        {
            SemanticContext unionOfPredicatesFromAllAlts = null;
            int numConfigs = _nfaConfigurations.Count;
            for ( int i = 0; i < numConfigs; i++ )
            {
                NFAConfiguration configuration = (NFAConfiguration)_nfaConfigurations[i];
                SemanticContext gatedPredExpr =
                    configuration.SemanticContext.GatedPredicateContext;
                if ( gatedPredExpr == null )
                {
                    // if we ever find a configuration w/o a gated predicate
                    // (even if it's a nongated predicate), we cannot gate
                    // the indident edges.
                    return null;
                }
                else if ( IsAcceptState || !configuration.SemanticContext.IsSyntacticPredicate )
                {
                    // at this point we have a gated predicate and, due to elseif,
                    // we know it's an accept or not a syn pred.  In this case,
                    // it's safe to add the gated predicate to the union.  We
                    // only want to add syn preds if it's an accept state.  Other
                    // gated preds can be used with edges leading to accept states.
                    if ( unionOfPredicatesFromAllAlts == null )
                    {
                        unionOfPredicatesFromAllAlts = gatedPredExpr;
                    }
                    else
                    {
                        unionOfPredicatesFromAllAlts =
                            SemanticContext.Or( unionOfPredicatesFromAllAlts, gatedPredExpr );
                    }
                }
            }
            if ( unionOfPredicatesFromAllAlts is SemanticContext.TruePredicate )
            {
                return null;
            }
            return unionOfPredicatesFromAllAlts;
        }