Esempio n. 1
0
        internal static bool HasLazyQuantifiers(RegExp regExp)
        {
            var repetitionRegExp = regExp as RepetitionRegExp;
            if (repetitionRegExp != null && repetitionRegExp.Greediness == Greediness.LazyQuantification)
            {
                return true;
            }
            else
            {
                bool hasLazyChilds = false;

                if (regExp.ChildExpressions != null)
                {
                    foreach (var childExpression in regExp.ChildExpressions)
                    {
                        hasLazyChilds |= HasLazyQuantifiers(childExpression);
                        if (hasLazyChilds)
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Esempio n. 2
0
 internal static RegExp FactorizeRegExp(RegExp regExp)
 {
     if (!HasLazyQuantifiers(regExp))
     {
         return regExp; // Do nothing, because no lazy quantifiers are used.
     }
     return null;
 }
Esempio n. 3
0
        //TODO: Func<Token, bool> => Predicate<Token>
        public void IgnoreTerminal(RegExp ignoree, Func<Token, bool> lexicalAction = null)
        {
            FiniteAutomata tokenNfa = GetTokenNfa(ignoree);
            if (lexicalAction != null)
            {
                mLexicalActions[tokenNfa.Terminator.TokenClass] = lexicalAction;
            }
            mIgnoredTokens.Add(tokenNfa.Terminator.TokenClass);

            AddTokenToNfa(tokenNfa);
        }
Esempio n. 4
0
 public extern string ReplaceRegex(RegExp regex, StringReplaceCallback callback);
Esempio n. 5
0
 public extern string ReplaceRegex(RegExp regex, string replaceText);
 internal DumbRegexpQuery(Term term, int flags)
     : base(term.Field)
 {
     RegExp re = new RegExp(term.Text(), flags);
     Automaton = re.ToAutomaton();
 }
Esempio n. 7
0
 public Terminal UseTerminal(RegExp regExp, Func<Token, bool> lexicalAction = null)
 {
     tokensNumber++;
     return mTokenizer.UseTerminal(regExp, lexicalAction);
 }
Esempio n. 8
0
        //TODO: Func<Token, bool> => Predicate<Token>
        public Terminal UseTerminal(RegExp regExp, Func<Token, bool> lexicalAction = null)
        {
            FiniteAutomata tokenNfa = GetTokenNfa(regExp);
            if (lexicalAction != null)
            {
                mLexicalActions[tokenNfa.Terminator.TokenClass] = lexicalAction;
            }

            AddTokenToNfa(tokenNfa);

            var terminal = new Terminal(regExp.ToString(), mClassIdProvider.GetCurrent());
            return terminal;
        }
Esempio n. 9
0
 public string[] Split(RegExp regex)
 {
     return(null);
 }
Esempio n. 10
0
 public int Search(RegExp regex)
 {
     return(0);
 }
Esempio n. 11
0
 public string ReplaceRegex(RegExp regex, StringReplaceCallback callback)
 {
     return(null);
 }
Esempio n. 12
0
 public string ReplaceRegex(RegExp regex, string replaceText)
 {
     return(null);
 }
Esempio n. 13
0
 public string[] Match(RegExp regex)
 {
     return(null);
 }
Esempio n. 14
0
 public NegationRegExp(RegExp regExp, bool createLoopTransitionsOnAcceptingStates = true)
 {
     mPositiveRegExp = regExp;
     this.createLoopTransitionsOnAcceptingStates = createLoopTransitionsOnAcceptingStates;
 }
Esempio n. 15
0
 public static IEnumerable<object> GetMatching(Context ctx, Coords from, Coords target, int direction, RegExp.Pattern pattern)
 {
     IEnumerable<Coords> c;
     if (pattern.CaptureAll(ctx.GameState, target, from, RegExp.Pattern.Direction.Any, out c))
     {
         return c;
     }
     else
     {
         return new List<object>();
     }
 }
Esempio n. 16
0
 public string[] Split(RegExp regex, int limit)
 {
     return(null);
 }
Esempio n. 17
0
 public static bool Match(Context ctx, Coords from, Coords target, RegExp.Pattern.Direction direction, RegExp.Pattern pattern)
 {
     return pattern.Match(ctx.GameState, target, from, direction);
 }
Esempio n. 18
0
 public extern int Search(RegExp regex);
Esempio n. 19
0
        private FiniteAutomata GetTokenNfa(RegExp regExp)
        {
            FiniteAutomata tokenNfa = regExp.AsNFA();
            tokenNfa.Terminator.IsAccepting = true;
            tokenNfa.Terminator.TokenClass = mClassIdProvider.GetNext();

            return tokenNfa;
        }
Esempio n. 20
0
 public extern string[] Split(RegExp regex);
Esempio n. 21
0
 public void IgnoreTerminal(RegExp regExp)
 {
     tokensNumber++;
     mTokenizer.IgnoreTerminal(regExp);
 }
Esempio n. 22
0
 public extern string[] Split(RegExp regex, int limit);
Esempio n. 23
0
 internal DumbRegexpQuery(TestRegexpRandom2 outerInstance, Term term, int flags)
     : base(term.Field())
 {
     this.OuterInstance = outerInstance;
     RegExp re = new RegExp(term.Text(), flags);
     Automaton = re.ToAutomaton();
 }
Esempio n. 24
0
 public extern string[] Match(RegExp regex);
Esempio n. 25
0
 internal RepeatUntilRegExp(RegExp repeatedRegExp, RegExp suffixRegExp)
 {
     mRepeatedRegExp = repeatedRegExp;
     mSuffixRegExp = suffixRegExp;
 }
Esempio n. 26
0
 // The idea:
 // a((a|b)+?|c)d = a((a|b)+?d | cd)
 // if there is no regexp after lazy quantifier, change it to greedy quantifier.
 // a(d(a|b)+?|c) --> a(d(a|b)+|c)
 // otherwise, move the following regexp into the regexp and add it to sequence:
 // a(d(a|b)+?|c)d(f|g) --> a(d(a|b)+?d(f|g)|cd(f|g))
 // ((a(d(a|b)+?|c)d(f|g))|(whatever))something -->
 // Algorithm:
 //    1) Find closest parent of type SequenceRegExp
 //    2) if position of current regexp is last, change lazy to greedy and exit
 //    3) otherwise
 public static RegExp Factorize(RegExp regExp)
 {
     throw new NotImplementedException();
 }