Пример #1
0
 internal SetNode(ParsingNode?startParsingNode, string[] variableNames, string assignmentExpression, ParsingNode?endParsingNode)
     : base(startParsingNode, Enumerable.Empty <ASTNode>(), endParsingNode)
 {
     VariableNames        = variableNames;
     AssignmentBlock      = null;
     AssignmentExpression = assignmentExpression;
 }
Пример #2
0
 internal SetNode(ParsingNode?startParsingNode, string[] variableNames, ContainerNode assignmentBlock, ParsingNode?endParsingNode)
     : base(startParsingNode, assignmentBlock.YieldOne(), endParsingNode)
 {
     VariableNames        = variableNames;
     AssignmentBlock      = assignmentBlock;
     AssignmentExpression = null;
 }
Пример #3
0
 internal CallNode(ParsingNode?startParsingNode, ExpressionNode callerDefinition, ExpressionNode macroCall, ContainerNode contents, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null)
     : base(startParsingNode, contents.ParsingNodes, endParsingNode)
 {
     Contents          = contents;
     WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet();
     MacroCall         = macroCall;
     CallerDefinition  = callerDefinition;
 }
Пример #4
0
 internal ASTNode(ParsingNode?startingParsingNode, IEnumerable <ParsingNode> contentParsingNodes, ParsingNode?endingParsingNode)
 {
     ParsingNodes =
         (startingParsingNode?.YieldOne() ?? Enumerable.Empty <ParsingNode>())
         .Concat(contentParsingNodes)
         .Concat(endingParsingNode?.YieldOne() ?? Enumerable.Empty <ParsingNode>())
         .ToArray();
     StartParsingNode = startingParsingNode;
     EndParsingNode   = endingParsingNode;
     NodeID           = _NodeID++;
 }
Пример #5
0
 internal MacroNode(JinjaEnvironment environment, ParsingNode?startParsingNode, string macroText, ContainerNode contents, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null)
     : base(startParsingNode, contents.ParsingNodes, endParsingNode)
 {
     Contents          = contents;
     WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet();
     //MacroText = macroText;
     if (environment.Evaluation.TryParseFunctionDeclaration(macroText, out var functionDeclaration) == false || functionDeclaration == null)
     {
         throw new NotImplementedException();
     }
     FunctionDeclaration = functionDeclaration;
 }
Пример #6
0
        internal static bool TryParseLineStatement(ILookaroundEnumerator <Token> enumerator, [NotNullWhen(true)] out ParsingNode?parsedNode)
        {
            parsedNode = default;
            if (enumerator.Current.TokenType != TokenType.LineStatement)
            {
                return(false);
            }
            var continueLoop = true;
            var queue        = new Queue <Token>();
            var nestingStack = new Stack <TokenType>();

            while (continueLoop)
            {
                if (enumerator.Current.TokenType == TokenType.NewLine && nestingStack.Count > 0)
                {
                    enumerator.MoveNext();
                    continue;
                }
                else if (enumerator.Current.TokenType.IsOpeningBrace())
                {
                    nestingStack.Push(enumerator.Current.TokenType);
                }
                else if (enumerator.Current.TokenType.IsClosingBrace())
                {
                    if (nestingStack.Peek().IsMatchingBrace(enumerator.Current.TokenType))
                    {
                        nestingStack.Pop();
                    }
                    else
                    {
                        throw new NotImplementedException(); //Unbalanced stack
                    }
                }

                if (enumerator.TryGetNext(out var nextToken) == false)
                {
                    continueLoop = false;
                }
Пример #7
0
 internal RawNode(ParsingNode?startParsingNode, IEnumerable <ParsingNode> contents, ParsingNode?endParsingNode)
     : base(startParsingNode, contents, endParsingNode)
 {
     Children = contents.ToArrayWithoutInstantiation();
 }
Пример #8
0
 internal ContainerNode(ParsingNode?startParsingNode, IEnumerable <ASTNode> children, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null)
     : base(startParsingNode, children, endParsingNode)
 {
     WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet();
 }
Пример #9
0
 internal ConditionalNode(ParsingNode?startParsingNode, ExpressionNode expression, IEnumerable <ASTNode> children, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null) :
     base(startParsingNode, children, endParsingNode)
 {
     Expression        = expression;
     WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet();
 }
Пример #10
0
 internal BlockNode(ParsingNode?startParsingNode, string name, ContainerNode blockContents, ParsingNode?endParsingNode)
     : base(startParsingNode, blockContents.YieldOne(), endParsingNode)
 {
     Name          = name;
     BlockContents = blockContents;
 }
Пример #11
0
 internal IfNode(ParsingNode?startParsingNode, IEnumerable <ConditionalNode> conditions, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null)
     : base(startParsingNode, conditions, endParsingNode)
 {
     Conditions        = conditions.ToArrayWithoutInstantiation();
     WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet();
 }
Пример #12
0
 internal StatementNode(ParsingNode?startParsingNode, IEnumerable <ASTNode> children, ParsingNode?endParsingNode)
     : base(startParsingNode, children.SelectMany(x => x.ParsingNodes), endParsingNode)
 {
     Children = children.ToArrayWithoutInstantiation();
 }
Пример #13
0
 internal AbstractContainerNode(ParsingNode?startingParsingNode, IEnumerable <ASTNode> children, ParsingNode?endingParsingNode)
     : base(startingParsingNode, children.SelectMany(child => child.ParsingNodes), endingParsingNode)
 {
     Children = children.ToArrayWithoutInstantiation();
 }
Пример #14
0
 internal ForNode(ContainerNode primaryBlock, ContainerNode?elseBlock,
                  string[] variableNames, object?expression, ExpressionNode?filter, bool recursive, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null)
     : base(
         startParsingNode: null,
         children: primaryBlock.YieldOne().Concat(elseBlock?.YieldOne() ?? Enumerable.Empty <ContainerNode>()),
         endParsingNode: endParsingNode
         )
 {
     PrimaryBlock           = primaryBlock;
     ElseBlock              = elseBlock;
     VariableNames          = variableNames;
     Filter                 = filter;
     WhiteSpaceControl      = whiteSpace ?? new WhiteSpaceControlSet();
     Recursive              = recursive;
     AlreadyEvaluatedObject = expression;
 }
Пример #15
0
 internal FilterNode(ParsingNode?startParsingNode, string filter, ContainerNode filterContents, ParsingNode?endParsingNode)
     : base(startParsingNode, filterContents.YieldOne(), endParsingNode)
 {
     Filter         = filter;
     FilterContents = filterContents;
 }