Esempio n. 1
0
 public override Expr VisitRegExLitExpr([NotNull] JPathParser.RegExLitExprContext context)
 {
     try
     {
         var regex = new Regex(context.Value.Text.Trim('/', '!'));
         return(new RegexLit(regex));
     }
     catch (ArgumentException e)
     {
         throw AstError(context.Value, $"Value '{context.Value}' is not a valid regex: {e.Message}");
     }
 }
Esempio n. 2
0
 public override Expr VisitRegExLitExpr([NotNull] JPathParser.RegExLitExprContext context)
 {
     try
     {
         var regexStr =
             context.Value.Text.StartsWith("/") ? context.Value.Text.Trim('/') :
             context.Value.Text.StartsWith("!") ? context.Value.Text.Trim('!') :
             context.Value.Text;
         return(new RegexLit(new Regex(regexStr)));
     }
     catch (ArgumentException e)
     {
         throw AstError(context.Value, $"Value '{context.Value.Text}' is not a valid regex: {e.Message}");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>RegExLitExpr</c>
 /// labeled alternative in <see cref="JPathParser.literal"/>.
 /// <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 VisitRegExLitExpr([NotNull] JPathParser.RegExLitExprContext context)
 {
     return(VisitChildren(context));
 }
Esempio n. 4
0
 /// <summary>
 /// Exit a parse tree produced by the <c>RegExLitExpr</c>
 /// labeled alternative in <see cref="JPathParser.literal"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitRegExLitExpr([NotNull] JPathParser.RegExLitExprContext context)
 {
 }