コード例 #1
0
 private static void HandleEachOverExpression(SuperSimpleTemplateParserState state)
 {
     var each = SyntaxTree.Iterate(
         state.ParseCurrentTokenExpression(),
         SyntaxTree.Block()
     );
     state.AddNodeToCurrentBlock(each);
     state.PushNewScope(each.Body, each.ItemType);
 }
コード例 #2
0
 private static void HandlePositiveConditional(SuperSimpleTemplateParserState state)
 {
     var condition = SyntaxTree.Conditional(
         state.ParseCurrentTokenExpression(),
         SyntaxTree.Block()
     );
     state.AddNodeToCurrentBlock(condition);
     state.PushNewScope(condition.TrueBlock);
 }
コード例 #3
0
        private static void HandleEachOverExpression(SuperSimpleTemplateParserState state)
        {
            var each = SyntaxTree.Iterate(
                state.ParseCurrentTokenExpression(),
                SyntaxTree.Block()
                );

            state.AddNodeToCurrentBlock(each);
            state.PushNewScope(each.Body, each.ItemType);
        }
コード例 #4
0
        private static void HandlePositiveConditional(SuperSimpleTemplateParserState state)
        {
            var condition = SyntaxTree.Conditional(
                state.ParseCurrentTokenExpression(),
                SyntaxTree.Block()
                );

            state.AddNodeToCurrentBlock(condition);
            state.PushNewScope(condition.TrueBlock);
        }
コード例 #5
0
        private static void HandlePartial(SuperSimpleTemplateParserState state)
        {
            var            details    = state.ParseCurrentTokenNameAndModelExpression();
            ExpressionNode expression = Expression.Self(state.CurrentTypeInScope());

            if (!String.IsNullOrEmpty(details.Model))
            {
                expression = state.ParseExpression(details.Model);
            }
            state.AddNodeToCurrentBlock(SyntaxTree.Include(details.Name, expression));
        }
コード例 #6
0
        private static void HandleWriteLiteral(SuperSimpleTemplateParserState state)
        {
            var expression = state.CurrentToken.Content;
            var htmlEncode = false;

            if (expression.StartsWith("!"))
            {
                htmlEncode = true;
                expression = expression.Substring(1);
            }
            state.AddNodeToCurrentBlock(SyntaxTree.WriteExpression(state.ParseExpression(expression), htmlEncode));
        }
コード例 #7
0
        public static SyntaxTreeNode Parse(IEnumerable<SuperSimpleToken> tokens, Type modelType)
        {
            var state = new SuperSimpleTemplateParserState();
            state.PushNewScope(modelType);

            foreach (var token in tokens)
            {
                state.CurrentToken = token;

                foreach (var handler in handlers)
                {
                    if (handler.Key(token))
                    {
                        handler.Value(state);
                        break;
                    }
                }
            }

            state.AssertScopeStackIsBackToASingleScope();
            return state.CurrentBlock;
        }
コード例 #8
0
        public static SyntaxTreeNode Parse(IEnumerable <SuperSimpleToken> tokens, Type modelType)
        {
            var state = new SuperSimpleTemplateParserState();

            state.PushNewScope(modelType);

            foreach (var token in tokens)
            {
                state.CurrentToken = token;

                foreach (var handler in handlers)
                {
                    if (handler.Key(token))
                    {
                        handler.Value(state);
                        break;
                    }
                }
            }

            state.AssertScopeStackIsBackToASingleScope();
            return(state.CurrentBlock);
        }
コード例 #9
0
 private static void HandleEndConditional(SuperSimpleTemplateParserState state)
 {
     state.AssertInsideConditionalBlock();
     state.PopCurrentScope();
 }
コード例 #10
0
 private static void HandleStringLiteral(SuperSimpleTemplateParserState state)
 {
     state.AddNodeToCurrentBlock(SyntaxTree.WriteString(state.CurrentToken.Content));
 }
コード例 #11
0
 private static void HandleFlush(SuperSimpleTemplateParserState state)
 {
     state.AddNodeToCurrentBlock(SyntaxTree.Flush());
 }
コード例 #12
0
        private static void HandleSection(SuperSimpleTemplateParserState state)
        {
            var details = state.ParseCurrentTokenNameAndModelExpression();

            state.AddNodeToCurrentBlock(SyntaxTree.Override(details.Name));
        }
コード例 #13
0
 private static void HandleSection(SuperSimpleTemplateParserState state)
 {
     var details = state.ParseCurrentTokenNameAndModelExpression();
     state.AddNodeToCurrentBlock(SyntaxTree.Override(details.Name));
 }
コード例 #14
0
 private static void HandleEndEach(SuperSimpleTemplateParserState state)
 {
     state.AssertInsideIterationBlock();
     state.PopCurrentScope();
 }
コード例 #15
0
 private static void HandleFlush(SuperSimpleTemplateParserState state)
 {
     state.AddNodeToCurrentBlock(SyntaxTree.Flush());
 }
コード例 #16
0
 private static void HandleEndEach(SuperSimpleTemplateParserState state)
 {
     state.AssertInsideIterationBlock();
     state.PopCurrentScope();
 }
コード例 #17
0
 private static void HandleWriteLiteral(SuperSimpleTemplateParserState state)
 {
     var expression = state.CurrentToken.Content;
     var htmlEncode = false;
     if (expression.StartsWith("!"))
     {
         htmlEncode = true;
         expression = expression.Substring(1);
     }
     state.AddNodeToCurrentBlock(SyntaxTree.WriteExpression(state.ParseExpression(expression), htmlEncode));
 }
コード例 #18
0
 private static void HandleStringLiteral(SuperSimpleTemplateParserState state)
 {
     state.AddNodeToCurrentBlock(SyntaxTree.WriteString(state.CurrentToken.Content));
 }
コード例 #19
0
 private static void HandleEndConditional(SuperSimpleTemplateParserState state)
 {
     state.AssertInsideConditionalBlock();
     state.PopCurrentScope();
 }
コード例 #20
0
        private static void HandlePartial(SuperSimpleTemplateParserState state)
        {
            var details = state.ParseCurrentTokenNameAndModelExpression();
            ExpressionNode expression = SyntaxTreeExpression.Self(state.CurrentTypeInScope());

            if (!String.IsNullOrEmpty(details.Model))
            {
                expression = state.ParseExpression(details.Model);
            }
            state.AddNodeToCurrentBlock(SyntaxTree.Include(details.Name, expression));
        }