public StatementListBuilder <StatementT, TokenT> Statement(StatementT type, TokenListBuilder <TokenT> tokens)
        {
            Statement <StatementT, TokenT> statement = new Statement <StatementT, TokenT>(type, tokens, tokens);

            this.statements.Add(statement);
            return(this);
        }
        public StatementNodeBuilder StatementNode(int indent, StatementType type, TokenListBuilder<ParserTokenType> tokens, StatementNodeBuilder children = null)
        {
            var statement = new Statement<StatementType, ParserTokenType>(type, tokens, tokens);
            var statementNode = new StatementNode(indent, null, statement);

            this.statementNodes.Add(statementNode);

            if (children != null)
            {
                foreach (var child in children)
                {
                    statementNode.Add(child);
                }
            }

            return this;
        }
 private static TokenListBuilder<ParserTokenType> Token(ParserTokenType type, string value)
 {
     var builder = new TokenListBuilder<ParserTokenType>();
     return builder.Token(type, value);
 }
 private static StatementNodeBuilder StatementNode(int indent, StatementType type, TokenListBuilder<ParserTokenType> tokens, StatementNodeBuilder children = null)
 {
     var builder = new StatementNodeBuilder();
     return builder.StatementNode(indent, type, tokens, children);
 }
        ////[Fact]
        ////public void TwoTrivialObjects()
        ////{
        ////    this.TestParser(
        ////        "one\ntwo",
        ////        Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Object, "one")
        ////            .Token(ParserTokenType.Whitespace, "\n")
        ////            )
        ////        .Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Object, "two")
        ////            )
        ////        );
        ////}

        ////[Fact]
        ////public void TwoObjects()
        ////{
        ////    this.TestParser(
        ////        "one value\ntwo name=value",
        ////        Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Object, "one")
        ////            .Token(ParserTokenType.Whitespace, " ")
        ////            .Token(ParserTokenType.PropertyValue, "value")
        ////            .Token(ParserTokenType.Whitespace, "\n")
        ////            )
        ////        .Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Object, "two")
        ////            .Token(ParserTokenType.Whitespace, " ")
        ////            .Token(ParserTokenType.PropertyName, "name")
        ////            .Token(ParserTokenType.Equals, "=")
        ////            .Token(ParserTokenType.PropertyValue, "value")
        ////            )
        ////        );
        ////}

        ////[Fact]
        ////public void TwoObjectsWithIndent()
        ////{
        ////    this.TestParser(
        ////        "one value\n\ttwo name=value",
        ////        Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Object, "one")
        ////            .Token(ParserTokenType.Whitespace, " ")
        ////            .Token(ParserTokenType.PropertyValue, "value")
        ////            .Token(ParserTokenType.Whitespace, "\n")
        ////            )
        ////        .Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Whitespace, "\t")
        ////            .Token(ParserTokenType.Object, "two")
        ////            .Token(ParserTokenType.Whitespace, " ")
        ////            .Token(ParserTokenType.PropertyName, "name")
        ////            .Token(ParserTokenType.Equals, "=")
        ////            .Token(ParserTokenType.PropertyValue, "value")
        ////            )
        ////        );
        ////}

        ////[Fact]
        ////public void Continuation()
        ////{
        ////    this.TestParser(
        ////        "folder\n\tname=value",
        ////        Statement(
        ////            StatementType.Object,
        ////            Token(ParserTokenType.Object, "folder")
        ////            .Token(ParserTokenType.Whitespace, "\n")
        ////            .Token(ParserTokenType.Whitespace, "\t")
        ////            .Token(ParserTokenType.PropertyName, "name")
        ////            .Token(ParserTokenType.Equals, "=")
        ////            .Token(ParserTokenType.PropertyValue, "value")
        ////        ));
        ////}

        ////[Fact]
        ////public void UseStatement()
        ////{
        ////    this.TestParser(
        ////        "use appx",
        ////        Statement(
        ////            StatementType.Use,
        ////            Token(ParserTokenType.UseKeyword, "use")
        ////            .Token(ParserTokenType.Whitespace, " ")
        ////            .Token(ParserTokenType.NamespacePrefixDeclaration, "appx")
        ////            )
        ////        );
        ////}

////        [Fact]
////        public void WixlibFileSearchTest()
////        {
////            this.TestParser(
////                @"use msi
////
////msi.fileSearch id=fsC component=c00d5a59-1bd1-4f6b-9b2b-27e0ae64020b
////
////msi.fileSearch id=fsRK registry=HKLM\Search\Registry\Key\",
////                Statement(
////                ////    StatementType.Use,
////                ////    Token(ParserTokenType.UseKeyword, "use")
////                ////    .Token(ParserTokenType.Whitespace, " ")
////                ////    .Token(ParserTokenType.NamespacePrefixDeclaration, "msi")
////                ////    .Token(ParserTokenType.Whitespace, "\r\n")
////                ////    )
////                ////.Statement(
////                    StatementType.Ignorable,
////                    Token(ParserTokenType.Whitespace, "\r\n")
////                    )
////                .Statement(
////                    StatementType.Object,
////                    Token(ParserTokenType.NamespacePrefix, "msi")
////                    .Token(ParserTokenType.Period, ".")
////                    .Token(ParserTokenType.Object, "fileSearch")
////                    .Token(ParserTokenType.Whitespace, " ")
////                    .Token(ParserTokenType.PropertyName, "id")
////                    .Token(ParserTokenType.Equals, "=")
////                    .Token(ParserTokenType.PropertyValue, "fsC")
////                    .Token(ParserTokenType.Whitespace, " ")
////                    .Token(ParserTokenType.PropertyName, "component")
////                    .Token(ParserTokenType.Equals, "=")
////                    .Token(ParserTokenType.PropertyValue, "c00d5a59-1bd1-4f6b-9b2b-27e0ae64020b")
////                    .Token(ParserTokenType.Whitespace, "\r\n")
////                    )
////                .Statement(
////                    StatementType.Ignorable,
////                    Token(ParserTokenType.Whitespace, "\r\n")
////                    )
////                .Statement(
////                    StatementType.Object,
////                    Token(ParserTokenType.NamespacePrefix, "msi")
////                    .Token(ParserTokenType.Period, ".")
////                    .Token(ParserTokenType.Object, "fileSearch")
////                    .Token(ParserTokenType.Whitespace, " ")
////                    .Token(ParserTokenType.PropertyName, "id")
////                    .Token(ParserTokenType.Equals, "=")
////                    .Token(ParserTokenType.PropertyValue, "fsRK")
////                    .Token(ParserTokenType.Whitespace, " ")
////                    .Token(ParserTokenType.PropertyName, "registry")
////                    .Token(ParserTokenType.Equals, "=")
////                    .Token(ParserTokenType.PropertyValue, "HKLM\\Search\\Registry\\Key\\")
////                    )
////                );
////        }


        private static StatementListBuilder <StatementType, ParserTokenType> Statement(StatementType type, TokenListBuilder <ParserTokenType> tokens)
        {
            var builder = new StatementListBuilder <StatementType, ParserTokenType>();

            return(builder.Statement(type, tokens));
        }
Пример #6
0
        private void TestLexer(string source, TokenListBuilder <LexerTokenType> expected)
        {
            var actual = XmlLexer.LexTokens(source, new Position(0, 0, 0));

            Assert.True(expected.SequenceEqual(actual, this.comparer));
        }
Пример #7
0
        ////[Fact]
        ////public void UseStatement()
        ////{
        ////    this.TestLexer(
        ////        "use appx",
        ////        Token(LexerTokenType.UseKeyword, "use")
        ////            .Token(LexerTokenType.Whitespace, " ")
        ////            .Token(LexerTokenType.Identifier, "appx")
        ////        );
        ////}

        private static TokenListBuilder <LexerTokenType> Token(LexerTokenType type, string value)
        {
            var builder = new TokenListBuilder <LexerTokenType>();

            return(builder.Token(type, value));
        }