예제 #1
0
파일: RegExp.cs 프로젝트: cerilewis/Fare
        /// <summary>
        ///   Initializes a new instance of the <see cref = "RegExp" /> class from a string.
        /// </summary>
        /// <param name = "s">A string with the regular expression.</param>
        /// <param name = "syntaxFlags">Boolean 'or' of optional syntax constructs to be enabled.</param>
        public RegExp(string s, RegExpSyntaxOptions syntaxFlags)
        {
            this.b = s;
            this.flags = syntaxFlags;
            RegExp e;
            if (s.Length == 0)
            {
                e = RegExp.MakeString(string.Empty);
            }
            else
            {
                e = this.ParseUnionExp();
                if (this.pos < b.Length)
                {
                    throw new ArgumentException("end-of-string expected at position " + this.pos);
                }
            }

            this.kind = e.kind;
            this.exp1 = e.exp1;
            this.exp2 = e.exp2;
            this.s = e.s;
            this.c = e.c;
            this.min = e.min;
            this.max = e.max;
            this.digits = e.digits;
            this.from = e.from;
            this.to = e.to;
            this.b = null;
        }
예제 #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "RegExp" /> class from a string.
        /// </summary>
        /// <param name = "s">A string with the regular expression.</param>
        /// <param name = "syntaxFlags">Boolean 'or' of optional syntax constructs to be enabled.</param>
        internal RegExp(string s, RegExpSyntaxOptions syntaxFlags)
        {
            this.b     = RegExp.ReplaceShorthandCharacterClasses(s);
            this.flags = syntaxFlags;
            RegExp e;

            if (s.Length == 0)
            {
                e = RegExp.MakeString(string.Empty);
            }
            else
            {
                e = this.ParseUnionExp();
                if (this.pos < this.b.Length)
                {
                    throw new ArgumentException("end-of-string expected at position " + this.pos);
                }
            }

            this.kind   = e.kind;
            this.exp1   = e.exp1;
            this.exp2   = e.exp2;
            this.s      = e.s;
            this.c      = e.c;
            this.min    = e.min;
            this.max    = e.max;
            this.digits = e.digits;
            this.from   = e.from;
            this.to     = e.to;
            this.b      = null;
        }
예제 #3
0
파일: RegExp.cs 프로젝트: Licho1/Fare
        /// <summary>
        ///   Initializes a new instance of the <see cref = "RegExp" /> class from a string.
        /// </summary>
        /// <param name = "s">A string with the regular expression.</param>
        /// <param name = "anyCharAlphabet">A string with the regular expression.</param>
        /// <param name = "syntaxFlags">Boolean 'or' of optional syntax constructs to be enabled.</param>
        public RegExp(string s, string anyCharAlphabet, RegExpSyntaxOptions syntaxFlags)
        {
            this.b     = s;
            this.flags = syntaxFlags;
            RegExp e;

            if (anyCharAlphabet != null)
            {
                this.anyCharAlphabet = anyCharAlphabet;
            }
            if (s.Length == 0)
            {
                e = RegExp.MakeString(string.Empty);
            }
            else
            {
                e = this.ParseUnionExp();
                if (this.pos < b.Length)
                {
                    throw new ArgumentException("end-of-string expected at position " + this.pos);
                }
            }

            this.kind   = e.kind;
            this.exp1   = e.exp1;
            this.exp2   = e.exp2;
            this.s      = e.s;
            this.c      = e.c;
            this.min    = e.min;
            this.max    = e.max;
            this.digits = e.digits;
            this.from   = e.from;
            this.to     = e.to;
            this.b      = null;
        }
예제 #4
0
파일: RegExp.cs 프로젝트: AltaModaTech/Fare
        /// <summary>
        ///   Initializes a new instance of the <see cref = "RegExp" /> class from a string.
        /// </summary>
        /// <param name = "s">A string with the regular expression.</param>
        /// <param name = "syntaxFlags">Boolean 'or' of optional syntax constructs to be enabled.</param>
        public RegExp(string s, RegExpSyntaxOptions syntaxFlags)
        {
            this.b     = s;
            this.flags = syntaxFlags;
            RegExp e;

            if (s.Length == 0)
            {
                e = RegExp.MakeString(string.Empty);
            }
            else
            {
                e = this.ParseUnionExp();
                if (this.pos < b.Length)
                {
                    throw new ArgumentException("end-of-string expected at position " + this.pos);
                }
            }

            this.Kind          = e.Kind;
            this.Expr1         = e.Expr1;
            this.Expr2         = e.Expr2;
            this.SourceRegExpr = e.SourceRegExpr;
            this.Char          = e.Char;
            this.Min           = e.Min;
            this.Max           = e.Max;
            this.Digits        = e.Digits;
            this.FromChar      = e.FromChar;
            this.ToChar        = e.ToChar;
            this.b             = null;
        }
예제 #5
0
        public RegExp(string s, RegExpSyntaxOptions syntaxFlags)
        {
            _B     = s;
            _Flags = syntaxFlags;
            RegExp e;

            if (s.Length == 0)
            {
                e = MakeString(string.Empty);
            }
            else
            {
                e = ParseUnionExp();
                if (_Pos < _B.Length)
                {
                    throw new ArgumentException("end-of-string expected at position " + _Pos);
                }
            }

            _Kind   = e._Kind;
            _Exp1   = e._Exp1;
            _Exp2   = e._Exp2;
            _S      = e._S;
            _C      = e._C;
            _Min    = e._Min;
            _Max    = e._Max;
            _Digits = e._Digits;
            _From   = e._From;
            _To     = e._To;
            _B      = null;
        }
예제 #6
0
파일: RegExp.cs 프로젝트: cerilewis/Fare
 private bool Check(RegExpSyntaxOptions flag)
 {
     return (flags & flag) != 0;
 }
예제 #7
0
 private bool Check(RegExpSyntaxOptions flag)
 {
     return((this.flags & flag) != 0);
 }
예제 #8
0
 private bool Check(RegExpSyntaxOptions flag) => (_Flags & flag) != 0;