Пример #1
0
        public void deployCode(codeSourceElement el, syntaxDeclaration syntax)
        {
            codeSourceElementCollection subElements = new codeSourceElementCollection(el, syntax);
            syntaxBlockDeclaration      sb;

            foreach (codeSourceElement subEl in subElements.codeElements)
            {
                if (subEl.lineClass != null)
                {
                    switch (subEl.lineClass.lineType)
                    {
                    case syntaxBlockLineType.normal:
                        codeLine cl = children.getElement <codeLine>(subEl.name);
                        if (cl == null)
                        {
                            syntaxBlockLineDeclaration cld = declaration.lines.Find(x => x.name == subEl.name);
                            cl = new codeLine(subEl.name, cld);
                            children.Add(cl);
                        }
                        cl.deployDeclaration(syntax);
                        cl.deployCode(subEl);
                        break;

                    case syntaxBlockLineType.block:

                        sb = syntax.blocks.find(subEl.name);

                        codeBlock cb = children.getElement <codeBlock>(subEl.name);

                        if (cb == null)
                        {
                            cb = new codeBlock(subEl.name, sb);
                            children.Add(cb);
                        }
                        // cb.deployDeclaration(syntax);
                        cb.deployCode(subEl, syntax);
                        ////// ovde poziva obradu koda

                        break;

                    case syntaxBlockLineType.emptyLine:
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Building DOM from source code string
        /// </summary>
        /// <param name="__source">Source code string</param>
        public void build(String __source)
        {
            codeBlock cb = null;
            syntaxBlockDeclaration sb;

            foreach (syntaxRenderUnit ru in declaration.structure)
            {
                sb = declaration.blocks.Find(x => x.name == ru.elementName);
                cb = new codeBlock(sb.name, sb);
                children.Add(cb);
                if (ru.mode == syntaxBlockRenderMode.inner)
                {
                    flatBlocks.Add(cb);
                }
                cb.deployDeclaration(declaration);
            }

            codeSourceElementCollection elements = new codeSourceElementCollection(__source, declaration);

            foreach (codeSourceElement el in elements.codeElements)
            {
                cb = null;
                sb = null;
                if (el.lineClass != null)
                {
                    switch (el.lineClass.lineType)
                    {
                    case syntaxBlockLineType.normal:
                        cb = flatBlocks.Find(x => x.children.hasElement(el.name));
                        codeLine cl = null;
                        if (cb != null)
                        {
                            cl = cb.children.getElement <codeLine>(el.name);
                            cl.deployCode(el);
                        }
                        else
                        {
                            unresolvedElements.Add(el);
                        }

                        break;

                    case syntaxBlockLineType.block:

                        sb = declaration.blocks.find(el.name);
                        if (sb != null)
                        {
                            if (sb.role == syntaxBlockRole.permanent)
                            {
                                cb = children.getElement <codeBlock>(el.name);
                            }
                        }

                        //declaration.blocks.

                        //el.lineClass.

                        //
                        if (cb == null)
                        {
                            // sb = declaration.blocks.find(el.name);
                            if (sb != null)
                            {
                                cb = new codeBlock(el.name, sb);
                                children.Add(cb);
                                cb.deployDeclaration(declaration);
                            }
                            else
                            {
                                unresolvedElements.Add(el);
                            }
                        }

                        if (cb != null)
                        {
                            cb.deployCode(el, declaration);
                        }

                        break;

                    case syntaxBlockLineType.emptyLine:
                        break;

                    default:
                        break;
                    }
                }
            }
        }