internal SetNode(ParsingNode?startParsingNode, string[] variableNames, string assignmentExpression, ParsingNode?endParsingNode) : base(startParsingNode, Enumerable.Empty <ASTNode>(), endParsingNode) { VariableNames = variableNames; AssignmentBlock = null; AssignmentExpression = assignmentExpression; }
internal SetNode(ParsingNode?startParsingNode, string[] variableNames, ContainerNode assignmentBlock, ParsingNode?endParsingNode) : base(startParsingNode, assignmentBlock.YieldOne(), endParsingNode) { VariableNames = variableNames; AssignmentBlock = assignmentBlock; AssignmentExpression = null; }
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; }
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++; }
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; }
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; }
internal RawNode(ParsingNode?startParsingNode, IEnumerable <ParsingNode> contents, ParsingNode?endParsingNode) : base(startParsingNode, contents, endParsingNode) { Children = contents.ToArrayWithoutInstantiation(); }
internal ContainerNode(ParsingNode?startParsingNode, IEnumerable <ASTNode> children, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null) : base(startParsingNode, children, endParsingNode) { WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet(); }
internal ConditionalNode(ParsingNode?startParsingNode, ExpressionNode expression, IEnumerable <ASTNode> children, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null) : base(startParsingNode, children, endParsingNode) { Expression = expression; WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet(); }
internal BlockNode(ParsingNode?startParsingNode, string name, ContainerNode blockContents, ParsingNode?endParsingNode) : base(startParsingNode, blockContents.YieldOne(), endParsingNode) { Name = name; BlockContents = blockContents; }
internal IfNode(ParsingNode?startParsingNode, IEnumerable <ConditionalNode> conditions, ParsingNode?endParsingNode, WhiteSpaceControlSet?whiteSpace = null) : base(startParsingNode, conditions, endParsingNode) { Conditions = conditions.ToArrayWithoutInstantiation(); WhiteSpaceControl = whiteSpace ?? new WhiteSpaceControlSet(); }
internal StatementNode(ParsingNode?startParsingNode, IEnumerable <ASTNode> children, ParsingNode?endParsingNode) : base(startParsingNode, children.SelectMany(x => x.ParsingNodes), endParsingNode) { Children = children.ToArrayWithoutInstantiation(); }
internal AbstractContainerNode(ParsingNode?startingParsingNode, IEnumerable <ASTNode> children, ParsingNode?endingParsingNode) : base(startingParsingNode, children.SelectMany(child => child.ParsingNodes), endingParsingNode) { Children = children.ToArrayWithoutInstantiation(); }
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; }
internal FilterNode(ParsingNode?startParsingNode, string filter, ContainerNode filterContents, ParsingNode?endParsingNode) : base(startParsingNode, filterContents.YieldOne(), endParsingNode) { Filter = filter; FilterContents = filterContents; }