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;
                    }
                }
            }
        }
Beispiel #2
0
        //public String renderInto(syntaxDeclaration syntax)
        //{
        //    //if (__declaration != null) __declaration = declaration;
        //    //__declaration.className
        //    String output = "";
        //    String inner = "";

        //    codeBlock cb = null;
        //    syntaxBlockDeclaration sb;

        //    foreach (codeBlock sl in children.items)
        //    {
        //        output = output + sl.renderInto(syntax).Trim(Environment.NewLine.ToCharArray()) + Environment.NewLine;
        //    }

        //    return output;
        //}

        public String render(syntaxDeclaration syntax)
        {
            //if (__declaration != null) __declaration = declaration;
            //__declaration.className
            String output = "";
            String inner  = "";

            codeBlock cb = null;
            syntaxBlockDeclaration sb;

            foreach (codeBlock sl in children.items)
            {
                output = output + sl.render(syntax).Trim(Environment.NewLine.ToCharArray()) + Environment.NewLine;
            }

            return(output);
        }
        public void deployDeclaration(syntaxDeclaration syntax)
        {
            foreach (syntaxBlockLineDeclaration ln in declaration.lines)
            {
                switch (ln.render)
                {
                case syntaxBlockLineType.block:
                    syntaxBlockDeclaration bls = syntax.blocks.find(ln.name);
                    codeBlock cb = new codeBlock(ln.name, bls);
                    children.Add(cb);
                    cb.deployDeclaration(syntax);
                    break;

                case syntaxBlockLineType.comment:
                case syntaxBlockLineType.custom:
                case syntaxBlockLineType.normal:
                    codeLine cl = new codeLine(ln.name, ln);
                    children.Add(cl);
                    cl.deployDeclaration(syntax);
                    break;
                }
            }
        }
        public void buildFrom(ICodeElement input)
        {
            codeBlock cb  = null;
            codeBlock cbi = input as codeBlock;
            syntaxBlockDeclaration sb;

            if (input is codeBlock)
            {
                sb = cbi.declaration;

                foreach (var sbl in sb.lines)
                {
                    ICodeElement cli = cbi.children.findElement(sbl.name);
                    ICodeElement cl  = this.children.findElement(sbl.name);

                    if (cl == null)
                    {
                    }
                    else
                    {
                        cl.buildFrom(cli);
                    }

                    /*
                     * if (cli != null)
                     * {
                     *  cli.buildFrom()
                     *  //cli.value = cbi.value;
                     * }
                     * else if (cli is codeBlock)
                     * {
                     *  {
                     *  }
                     * }*/
                }
            }
        }
Beispiel #5
0
        public void buildFrom(ICodeElement input)
        {
            codeBlock cb  = null;
            codeBlock cbi = 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);

            //    cbi = input.children.findElement(sb.name) as codeBlock;

            //    cb.buildFrom(cbi);

            //}

            foreach (var ie in input.children.items)
            {
                sb = declaration.blocks.find(ie.name);
                if (sb != null)
                {
                    cb = new codeBlock(ie.name, sb);
                    children.Add(cb);
                    if (sb.render == syntaxBlockRenderMode.inner)
                    {
                        flatBlocks.Add(cb);
                    }
                    cb.deployDeclaration(declaration);

                    //cbi = input[input.children.findElement(sb.name) as codeBlock;

                    cb.buildFrom(ie as codeBlock);
                }
                //cb = children.findElement(ie.name) as codeBlock;
                //if (cb == null)
                //{
                //    sb = declaration.blocks.find(ie.name);
                //    cb = new codeBlock(ie.name, sb);
                //    children.Add(cb);
                //    cb.deployDeclaration(input.declarationBase as syntaxDeclaration);
                //}
                //cb.buildFrom(ie);
            }

            //foreach (syntaxRenderUnit ru in declaration.structure)
            //{
            //    cb = input[ru.elementName]
            //    if (cb != null)
            //    {
            //        foreach (var cl in declaration.blocks.find(ru.elementName).lines)
            //        {
            //        }
            //    }
            //    sb = declaration.blocks.Find(x => x.name == ru.elementName);
            //    new codeBlock(sb.name, sb);
            //    children.Add(cb);
            //    if (ru.mode == syntaxBlockRenderMode.inner)
            //    {
            //        flatBlocks.Add(cb);
            //    }
            //    cb.deployDeclaration(declaration);
            //}

            //foreach (codeBlock sl in declaration.structure
            //{
            //    //output = output + sl.render(syntax).Trim(Environment.NewLine.ToCharArray()) + Environment.NewLine;
            //}
        }
Beispiel #6
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;
                    }
                }
            }
        }