コード例 #1
0
ファイル: DefineNodeTests.cs プロジェクト: peppy/osq2osb
        public void TestParameterParsing()
        {
            string input = @"#define test(a, b, c) abc";

            TreeNode.NodeBase node;

            using(var reader = new LocatedTextReaderWrapper(input)) {
                var parser = new Parser(reader);
                node = parser.ReadNode();
            }

            Assert.IsInstanceOf(typeof(TreeNode.DefineNode), node);

            TreeNode.DefineNode define = node as TreeNode.DefineNode;

            Assert.IsTrue(define.FunctionParameters.SequenceEqual(new string[] { "a", "b", "c" }));
        }
コード例 #2
0
ファイル: DirectiveNode.cs プロジェクト: peppy/osq2osb
        /// <summary>
        /// Reads the sub-nodes required by this node.
        /// </summary>
        /// <param name="parser">The parser to read sub-nodes from.</param>
        /// <exception cref="MissingDataException">Closing directive node was not available.</exception>
        private void ReadSubNodes(Parser parser)
        {
            NodeBase curNode = this;

            while(!this.EndsWith(curNode)) {
                curNode = parser.ReadNode();

                if(curNode == null) {
                    throw new MissingDataException("Closing #" + this.DirectiveName + " directive", this.Location);
                }

                this.ChildrenNodes.Add(curNode);
            }
        }