Esempio n. 1
0
            /// <summary>
            /// Convert to automaton
            /// </summary>
            public Automaton <S> ToAutomaton(RegexToAutomatonBuilder <ILikeNode, S> builder, ICharAlgebra <S> solver)
            {
                var moveCond = solver.MkRangeConstraint(this.start, this.end);

                moveCond = this.negate ? solver.MkNot(moveCond) : moveCond;
                return(builder.MkSeq(moveCond));
            }
Esempio n. 2
0
 /// <summary>
 /// Create instance of LikeToAutomatonConverter for a given character solver.
 /// </summary>
 public LikePatternToAutomatonConverter(ICharAlgebra <S> solver)
 {
     this.solver  = solver;
     this.builder = new RegexToAutomatonBuilder <ILikeNode, S>(solver, this.TokenToAutomaton);
     //add implicit start and end anchors
     this.builder.isBeg = false;
     this.builder.isEnd = false;
 }
Esempio n. 3
0
 /// <summary>
 /// Constructs a regex to symbolic finite automata converter
 /// </summary>
 /// <param name="solver">solver for character constraints</param>
 /// <param name="categorizer">maps unicode categories to corresponding character conditions</param>
 internal RegexToAutomatonConverter(ICharAlgebra <S> solver, IUnicodeCategoryTheory <S> categorizer)
 {
     this.solver      = solver;
     this.categorizer = categorizer;
     description.Add(solver.True, "");
     description.Add(solver.False, "[]");
     this.automBuilder = new RegexToAutomatonBuilder <RegexNode, S>(solver, ConvertNode);
     //this.converterHelper.Callback = (node, start, end) => ConvertNode(node, start, end);
 }
Esempio n. 4
0
 /// <summary>
 /// Constructs a regex to symbolic finite automata converter
 /// </summary>
 /// <param name="solver">solver for character constraints</param>
 public RegexToAutomatonConverter(ICharAlgebra <S> solver)
 {
     this.solver      = solver;
     this.categorizer = new UnicodeCategoryTheory <S>(solver);
     description.Add(solver.True, "");
     description.Add(solver.False, "[]");
     this.automBuilder = new RegexToAutomatonBuilder <RegexNode, S>(solver, ConvertNode);
     //this.converterHelper.Callback = ConvertNode;
 }
Esempio n. 5
0
        //public SymbolicRegexBuilder<S> SRBuilder
        //{
        //    get
        //    {
        //        return srBuilder;
        //    }
        //}

        /// <summary>
        /// Constructs a regex to symbolic finite automata converter
        /// </summary>
        /// <param name="solver">solver for character constraints</param>
        /// <param name="categorizer">maps unicode categories to corresponding character conditions</param>
        internal RegexToAutomatonConverter(ICharAlgebra <S> solver, IUnicodeCategoryTheory <S> categorizer = null)
        {
            this.solver      = solver;
            this.categorizer = (categorizer == null ? new UnicodeCategoryTheory <S>(solver) : categorizer);
            description.Add(solver.True, ".");
            //"[]" does not unfortunately parse as a valid regex
            //description.Add(solver.False, "[0-[0]]");
            description.Add(solver.False, "[]");
            this.automBuilder = new RegexToAutomatonBuilder <RegexNode, S>(solver, ConvertNode);
            this.srBuilder    = new SymbolicRegexBuilder <S>((ICharAlgebra <S>)solver);
            //this.converterHelper.Callback = (node, start, end) => ConvertNode(node, start, end);
        }
Esempio n. 6
0
            /// <summary>
            /// Convert to automaton
            /// </summary>
            public Automaton <S> ToAutomaton(RegexToAutomatonBuilder <ILikeNode, S> builder, ICharAlgebra <S> solver)
            {
                if (this.set.Length == 0)
                {
                    return(builder.MkSeq(solver.False));
                }

                var moveCond = solver.MkOr(this.set.Select(c => solver.MkCharConstraint(c)));

                moveCond = this.negate ? solver.MkNot(moveCond) : moveCond;
                return(builder.MkSeq(moveCond));
            }
Esempio n. 7
0
 /// <summary>
 /// Convert to automaton
 /// </summary>
 public Automaton <S> ToAutomaton(RegexToAutomatonBuilder <ILikeNode, S> builder, ICharAlgebra <S> solver)
 {
     return(builder.MkSeq(solver.False));
 }
Esempio n. 8
0
 /// <summary>
 /// Convert to automaton
 /// </summary>
 public Automaton <S> ToAutomaton(RegexToAutomatonBuilder <ILikeNode, S> builder, ICharAlgebra <S> solver)
 {
     return(builder.MkLoop(new LikeAny(), 0, int.MaxValue));
 }
Esempio n. 9
0
 /// <summary>
 /// Convert to automaton
 /// </summary>
 public Automaton <S> ToAutomaton(RegexToAutomatonBuilder <ILikeNode, S> builder, ICharAlgebra <S> solver)
 {
     return(builder.MkSeq(this.chars.Select(c => solver.MkRangeConstraint(c, c)).ToArray()));
 }
Esempio n. 10
0
 /// <summary>
 /// Convert to Automaton
 /// </summary>
 public Automaton <S> ToAutomaton(RegexToAutomatonBuilder <ILikeNode, S> builder, ICharAlgebra <S> solver)
 {
     return(builder.MkConcatenate(this.children, implicitAnchors: true));
 }
Esempio n. 11
0
 /// <summary>
 /// Create instance of LikeToAutomatonConverter for a given character solver.
 /// </summary>
 public LikePatternToAutomatonConverter(ICharAlgebra <S> solver)
 {
     this.solver  = solver;
     this.builder = new RegexToAutomatonBuilder <ILikeNode, S>(solver, this.TokenToAutomaton);
 }