Esempio n. 1
0
        private Node parseBlock()
        {
            Token  token      = expect(typeof(Block));
            Block  blockToken = (Block)token;
            String mode       = blockToken.getMode();
            String name       = blockToken.getValue().Trim();

            Node blockNode;

            if (peek() is Indent)
            {
                blockNode = block();
            }
            else
            {
                blockNode = new BlockNode();
                blockNode.setLineNumber(blockToken.getLineNumber());
                blockNode.setFileName(filename);
            }

            ((BlockNode)blockNode).setMode(mode);

            if (blocks.ContainsKey(name))
            {
                BlockNode prev = (BlockNode)blocks[name];
                if ("append".Equals(prev.getMode()))
                {
                    blockNode.getNodes().AppendRange(prev.getNodes());
                }
                if ("prepend".Equals(prev.getMode()))
                {
                    blockNode.getNodes().PrependRange(prev.getNodes());
                }
                if ("replace".Equals(prev.getMode()))
                {
                    blockNode = prev;
                }
            }

            blocks.Add(name, blockNode);
            return(blockNode);
        }