Esempio n. 1
0
        private string TranslateToNETRegex(VBALikeParser.LikePatternStringContext likePattern)
        {
            StringBuilder regexStr = new StringBuilder();

            foreach (var element in likePattern.likePatternElement())
            {
                if (element.likePatternChar() != null)
                {
                    regexStr.Append(element.likePatternChar().GetText());
                }
                else if (element.QUESTIONMARK() != null)
                {
                    regexStr.Append(".");
                }
                else if (element.HASH() != null)
                {
                    regexStr.Append(@"\d");
                }
                else if (element.STAR() != null)
                {
                    regexStr.Append(@".*?");
                }
                else
                {
                    var charlist = element.likePatternCharlist().GetText();
                    if (charlist.StartsWith("[!"))
                    {
                        charlist = "[^" + charlist.Substring(2);
                    }
                    regexStr.Append(charlist);
                }
            }
            // Full string match, e.g. "abcd" should NOT match "a.c"
            var regex = "^" + regexStr.ToString() + "$";

            return(regex);
        }
Esempio n. 2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="VBALikeParser.likePatternString"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitLikePatternString([NotNull] VBALikeParser.LikePatternStringContext context)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="VBALikeParser.likePatternString"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitLikePatternString([NotNull] VBALikeParser.LikePatternStringContext context)
 {
     return(VisitChildren(context));
 }