Class LoopStatement

    • Constructor Detail

      • LoopStatement

        LoopStatement()
        Constructor for serialization.
      • LoopStatement

        public LoopStatement​(VariableDeclaration iteratorVar,
                             Expression containerExpression,
                             ITemplateElement statement,
                             Expression separatorExpression,
                             Expression finalSeparatorExpression)
                      throws VilException
        Create a loop-statement.
        Parameters:
        iteratorVar - the iterator variable (name and type of iterator variable)
        containerExpression - the container to iterate over
        statement - the loop-statement which may subsumes a set of template elements that will be processed multiple times.
        separatorExpression - an optional separator expression to be emitted between elements (may be null)
        finalSeparatorExpression - an optional separator expression to be emitted after the last element (may be null)
        Throws:
        VilException - in case of semantic problems while creating this loop object
    • Method Detail

      • getSeparatorExpression

        public Expression getSeparatorExpression()
        Returns the optional separator expression.
        Returns:
        the separator expression or null
      • getFinalSeparatorExpression

        public Expression getFinalSeparatorExpression()
        Returns the optional final separator expression.
        Returns:
        the separator expression or null
      • getIteratorVariable

        public VariableDeclaration getIteratorVariable()
        Returns the iterator variable.
        Returns:
        The iterator variable.
      • getContainerExpression

        public Expression getContainerExpression()
        Get the expression of this loop which defines the set of elements to iterate over.
        Returns:
        The Expression of this loop.
      • getLoopStatement

        public ITemplateElement getLoopStatement()
        Get the loop-statement which may subsume a set of template elements that will be processed multiple times.
        Returns:
        The template element that represents the loop-statement/block.
      • accept

        public java.lang.Object accept​(IVisitor visitor)
                                throws VilException
        Description copied from interface: ITemplateLangElement
        Accepts the visitor for visiting.
        Parameters:
        visitor - the visitor to be used
        Returns:
        the result of visiting this instance (may be null)
        Throws:
        VilException - in case that visiting fails (e.g., execution)
      • isBlock

        public boolean isBlock()
        Description copied from interface: ITemplateElement
        Returns whether this element is a block (opposite is a single statement).
        Returns:
        true if it is a block, false else
      • setParent

        protected void setParent​(ILanguageElement parent)
        Description copied from class: AbstractTemplateElement
        Changes the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.
        Overrides:
        setParent in class AbstractTemplateElement
        Parameters:
        parent - the parent
      • endsWithContentStatement

        public boolean endsWithContentStatement()
        Description copied from interface: ITemplateElement
        Returns whether this element ends with a content statement.
        Returns:
        true for end with content statement, false else