Exemplo n.º 1
0
        internal static ExprBlockDef GetExprBlockDefinition(ExprRenderer exprRenderer)
        {
            if (exprRenderer.RenderType != ExprRenderType.Simple)
                for (int i = 0; i < _blockDefinitions.Count; i++)
                {
                    ExprBlockDef exprBlock_i = _blockDefinitions[i];
                    if (exprBlock_i.IsStartingExpr(exprRenderer.Name) || exprBlock_i.IsEndingExpr(exprRenderer.Name) || exprBlock_i.IsMiddleExpr(exprRenderer.Name))
                    {
                        return exprBlock_i;
                    }
                }

            return null;
        }
Exemplo n.º 2
0
        private int GetBlockStartExprIndex(ExprRenderer exprRenderer, int exprRendererIndex)
        {
            ExprBlockDef exprBlock = exprRenderer.BlockDef;
            if (exprBlock != null)
            {
                int startExprIndex = -1;
                for (int i = exprRendererIndex - 1; i >= 0; i--)
                {
                    ExprRenderer er_i = ExprRenderers[i];
                    if (er_i.Level == exprRenderer.Level)
                    {
                        if (exprBlock.IsStartingExpr(er_i.Name))
                        {
                            startExprIndex = i;
                            break;
                        }
                        else if (exprBlock.IsEndingExpr(er_i.Name))
                            // if same ending instruction encountered befor the startting instruction (same level)
                            break;
                    }
                }

                if (startExprIndex != -1)
                    return startExprIndex;
                else
                {
                    Errors.Add(new TemplateError(exprRenderer.ExprMatchResult.Line, string.Format("Missing '{0}' block start instruction, line {1}", exprBlock.Name, exprRenderer.ExprMatchResult.Line)));
                }
            }
            else
            {
                Errors.Add(new TemplateError(exprRenderer.ExprMatchResult.Line, string.Format("[FATAL] Missing block definition, line {0}", exprRenderer.ExprMatchResult.Line)));
            }

            return -1;
        }