private ScanPatterns AssembleNonWordPatterns()
        {
            ScanPatterns pats = new ScanPatterns();

            pats.Add(WhitespacePatterns);
            pats.AddDistinct(NewLinePatterns);

            pats.Add(CommentToEndPatterns);

            pats.AddDistinct(QuotePatterns);
            if (this.VerbatimLiteralPattern != null)
            {
                pats.AddDistinct(this.VerbatimLiteralPattern);
            }

            pats.AddDistinct(ExpressionPatterns);
            pats.AddDistinct(EndStmtPatterns);
            pats.AddDistinct(OpenContentBracedPatterns);
            pats.AddDistinct(OpenNamedBracedPatterns);
            pats.AddDistinct(CloseBracedPatterns);
            pats.AddDistinct(PathSepPatterns);

            // standard delimeters like "," and ":"
            pats.AddDistinct(DividerPatterns);

            return(pats);
        }
Exemple #2
0
        public TextTraits()
        {
            mWhitespacePatterns =
                new ScanPatterns(new string[] { " ", "\t" }, DelimClassification.Whitespace);
            mNewLinePatterns = new ScanPatterns();
            mDividerPatterns = new ScanPatterns(
                new string[] { ",", ":", "." }, DelimClassification.DividerSymbol);
            mCommentToEndPatterns = new ScanPatterns();

            // chars which separate names in a path.
            mPathSepPatterns.Add("/", DelimClassification.PathSep, DelimClassification.CommentToEnd);
            mPathSepPatterns.Add("\\", DelimClassification.PathSep);
        }
Exemple #3
0
        private ScanPatterns AssembleNonWordPatterns()
        {
            ScanPatterns pats = new ScanPatterns();

            pats.Add(WhitespacePatterns);
            pats.AddDistinct(NewLinePatterns);

            pats.Add(CommentToEndPatterns);

            pats.AddDistinct(QuotePatterns);
            if (this.VerbatimLiteralPattern != null)
            {
                pats.AddDistinct(this.VerbatimLiteralPattern);
            }

            pats.AddDistinct(ExpressionPatterns);
            pats.AddDistinct(EndStmtPatterns);
            pats.AddDistinct(OpenContentBracedPatterns);
            pats.AddDistinct(OpenNamedBracedPatterns);
            pats.AddDistinct(CloseBracedPatterns);
            pats.AddDistinct(PathSepPatterns);

            // standard delimeters like "," and ":"
            pats.AddDistinct(DividerPatterns);

            // special value starter pattern.  *LIBL is the special value. * is the starter
            // value.
            if (this.SpecialValueStarter != null)
            {
                ScanPattern pat =
                    new ScanPattern(this.SpecialValueStarter, DelimClassification.SpecialValueStarter);
                pats.AddDistinct(pat);
            }

            // note. dont add keyword patterns to this collection of non word patterns.
            //       Keyword patterns are a subset of the text ( identifier ) tokens found
            //       between non word tokens.

            // BgnTemp
//      if (_KeywordPatterns != null)
//      {
//        pats.AddDistinct(KeywordPatterns);
//      }
            // EndTemp

            // sort the list of patterns by patternValue and DelimClass.
            var sortedPats = from a in pats
                             orderby a.PatternValue, a.DelimClassification, a.UserCode
            select a;

            // build a list of patterns that are distinct on patternValue, delimClass, and
            // keyword code.
            ScanPatterns distinctPats = new ScanPatterns();
            ScanPattern  pvPat        = null;

            foreach (var pat in sortedPats)
            {
                if ((pvPat == null) || (pat.Equals(pvPat) == false))
                {
                    distinctPats.Add(pat.Duplicate( ));
                }
                pvPat = pat;
            }

            return(distinctPats);
        }