public void CompactTokenTypeTest()
        {
            const string txt = "[{%;?@]`x~";

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual(TokenType.Segment, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Block, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Lookup, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Secondary, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Condition, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Function, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Close, scan.ScanTokenType());
                scan.SkipChar();
                Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType());
                // Automatically skipped
                Assert.AreEqual(TokenType.Name, scan.ScanTokenType());
                scan.SkipChar();
                Assert.IsFalse(scan.Eof);
                Assert.AreEqual(TokenType.Unknown, scan.ScanTokenType());
                scan.SkipChar();
                Assert.IsTrue(scan.Eof);
                Assert.AreEqual(TokenType.Unknown, scan.ScanTokenType());
            }
        }
 public void EofTest()
 {
     using (var scan = new CompactProfileScanner(""))
     {
         Assert.IsTrue(scan.Eof);
         scan.SkipChar();
         Assert.AreEqual(ScanReader.EofChar, scan.Current, "Scan past EOF");
     }
 }
        public void TextTest()
        {
            const string txt = "text ``string`post-text string";

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual("text `string", scan.ScanText());
                Assert.AreEqual("p", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be beyond the delimeter");
            }
        }
        public void QuotedStringTest()
        {
            const string txt = "/quoted //string/unquoted string"; // / is the quote character;

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual("quoted /string", scan.ScanQuotedString());
                Assert.IsTrue(scan.CheckChar('u'), "Next character to scan");
            }
        }
        public void PartNameTest()
        {
            const string txt = "`Name`";

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter");
                Assert.AreEqual(TokenType.Name, scan.ScanTokenType());
                Assert.AreEqual("Name", scan.ScanName(), "Should be the unqualified name");
                Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType());
            }
        }
        public void LookupTest()
        {
            const string txt = "`%Class.Name=SubClass.Name:Lookup text`]";

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter");
                Assert.AreEqual(TokenType.Lookup, scan.ScanTokenType());
                Assert.AreEqual("Class.Name=SubClass.Name", scan.ScanLookup(), "Should be the lookup condition");
                Assert.AreEqual("L", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be in the body of the lookup");
            }
        }
        public void ConditionTest()
        {
            const string txt = "`?Class.Name='Class':Condition text`]";

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter");
                Assert.AreEqual(TokenType.Condition, scan.ScanTokenType());
                Assert.AreEqual("Class.Name='Class'", scan.ScanCondition(), "Should be the condition");
                Assert.AreEqual("C", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be in the body of the condition");
            }
        }
        public void SegmentClassTest()
        {
            const string txt = "`[Class>:Segment text`]";

            using (var scan = new CompactProfileScanner(txt))
            {
                Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter");
                Assert.AreEqual(TokenType.Segment, scan.ScanTokenType());
                Assert.AreEqual("Class>", scan.ScanSegmentClass(), "Should be the segement class");
                Assert.AreEqual("S", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be on the body of the segment");
            }
        }
 private GenCompactProfileParser(GenDataDef genDataDef, CompactProfileScanner scan)
     : base(new GenProfileParams(genDataDef))
 {
     Scan = scan;
     try
     {
         _compactPrimaryBodyParser   = new CompactPrimaryBodyParser(this);
         _compactSecondaryBodyParser = new CompactSecondaryBodyParser(this);
         ScanBody(ClassId, Body, this, Profile);
     }
     finally
     {
         Scan.Dispose();
     }
     _parameterSeparator = new CharSet(" " + Scan.Delimiter);
 }