public RegularCaptureType DetermineKind()
        {
            if (this.ForcedRecognizer)
            {
                return(RegularCaptureType.Recognizer);
            }
            RegularCaptureType result = DetermineKind(this, this.file);

            return(result);
        }
        internal static RegularCaptureType DetermineKind(IOilexerGrammarTokenEntry entry, ITokenExpressionSeries series, IOilexerGrammarFile file)
        {
            RegularCaptureType result = RegularCaptureType.Undecided;

            foreach (var expression in series)
            {
                var currentKind = DetermineKind(entry, expression, file);
                switch (currentKind)
                {
                case RegularCaptureType.Recognizer:
                    if (result == RegularCaptureType.Undecided)
                    {
                        result = currentKind;
                    }
                    break;

                case RegularCaptureType.Capturer:
                    result = currentKind;
                    break;

                case RegularCaptureType.Transducer:
                    if (result == RegularCaptureType.Undecided)
                    {
                        result = RegularCaptureType.Transducer;
                    }
                    else if (result == RegularCaptureType.Recognizer)
                    {
                        result = RegularCaptureType.Capturer;
                    }
                    break;
                }
            }
            if (result == RegularCaptureType.Undecided)
            {
                result = RegularCaptureType.Recognizer;
            }

            if (result == RegularCaptureType.Transducer)
            {
                if ((from gdEntry in file
                     where gdEntry is IOilexerGrammarProductionRuleEntry
                     let ruleEntry = (IOilexerGrammarProductionRuleEntry)gdEntry
                                     from productionRuleItem in GetProductionRuleSeriesItems(ruleEntry)
                                     where productionRuleItem is ILiteralReferenceProductionRuleItem
                                     let literalItem = (ILiteralReferenceProductionRuleItem)productionRuleItem
                                                       where literalItem.Source == entry
                                                       select literalItem).Count() > 0)
                {
                    return(RegularCaptureType.ContextfulTransducer);
                }
            }
            return(result);
        }
Example #3
0
 internal void Reduce(RegularCaptureType captureType, Func <RegularLanguageDFAState, RegularLanguageDFAState, bool> additionalReducer = null)
 {
     Reduce(this, captureType == RegularCaptureType.Recognizer, additionalReducer);
 }