示例#1
0
        // initiates parsing of DLL into statements
        public bool Parse(String ddl)
        {
            this.ddl = new Parsable(ddl);

            while (this.ddl.Length > 0)
            {
                this.ShowParsingInfo();

                try {
                    if (this.ParseComment())
                    {
                        continue;
                    }
                    if (this.ddl.Length == 0 || this.ParseStatement())
                    {
                        continue;
                    }

                    // failed to parse a comment or a statement, skip up to end of statement
                    // to skip garbage. comments are no problem
                    throw new ParseException(
                              "-->" + this.ddl.ConsumeUpTo(";", include: true)
                              );
                } catch (ParseException e) {
                    // track exception and continue parsing
                    this.errors.Add(e);
                }
            }

            return(true);
        }
示例#2
0
        public void testConsumeUpTo()
        {
            Parsable text = new Parsable("  123 456;789");

            Assert.AreEqual(text.ConsumeUpTo(";"), "123 456");
            Assert.AreEqual(text.Length, 4);
        }
示例#3
0
        public void testSkipLeadingWhitespace()
        {
            Parsable text = new Parsable(" \t\r\n123456789");

            text.SkipLeadingWhitespace();
            Assert.AreEqual(text.Length, 9);
        }
示例#4
0
        public void testFullyQualifiedName()
        {
            QualifiedName qn = new Parsable("  hello.world").ConsumeQualifiedName();

            Assert.AreEqual("hello", qn.Scope);
            Assert.AreEqual("world", qn.Name);
            Assert.AreEqual("hello.world", qn.ToString());
        }
示例#5
0
        public void testSimpleQualifiedName()
        {
            QualifiedName qn = new Parsable("  hello").ConsumeQualifiedName();

            Assert.IsNull(qn.Scope);
            Assert.AreEqual("hello", qn.Name);
            Assert.AreEqual("hello", qn.ToString());
        }
示例#6
0
        public void testImplicitConstructorBehaviour()
        {
            Parsable text = new Parsable(" \t\r\n123456789");

            // NOTE: \r is discards
            //       repeated whitespace (space and tab) are replaced by single space
            Assert.AreEqual(text.Length, 11);
        }