Module dev.civl.abc

Interface PragmaNode

All Superinterfaces:
ASTNode, BlockItemNode, StatementNode

public interface PragmaNode extends StatementNode
A pragma may be included in the AST wherever a statement or an external definition may occur. The pragma is represented as an identifier (the first token to follow the # pragma tokens), followed by some sequence of tokens of length (say) n, followed by a newline character. We will refer to that sequence as the "pragma body". Note that the pragma body does not include the pragma identifier and does not include the final newline character.
  • Method Details

    • getPragmaIdentifier

      IdentifierNode getPragmaIdentifier()
      Returns the pragma identifier, i.e., the identifier immediately following # pragma. For example, in # pragma omp ..., the identifier omp would be returned.
      Returns:
      the pragma identifier
    • getNumTokens

      int getNumTokens()
      Returns n, the number of tokens in the pragma body, i.e., the number of tokens following # pragma IDENTIFIER
      Returns:
      number of tokens in the pragma body
    • getToken

      CivlcToken getToken(int index)
      Returns the index-th token in the pragma body. The tokens of body are indexed beginning with 0.
      Parameters:
      index - an integer in the range [0,n-1], where n is the value returned by getNumTokens()
      Returns:
      the index-th token in the pragma body
    • getTokens

      Iterable<CivlcToken> getTokens()
      Returns an iterable over the tokens in the pragma body.
      Returns:
      iterator over the tokens of pragma body
    • newTokenSource

      CivlcTokenSource newTokenSource()

      Returns the tokens of the pragma body as a CivlcTokenSource, which can then be fed into an ANTLR parser for syntactic analysis. Note that each call returns a new token source, since each can only be used once.

      The token source will effectively append an infinite sequence of EOF tokens after the pragma body. This is what is expected from most parsers.

      Returns:
      a token source for the tokens comprising the body of this pragma
    • getNewlineToken

      CivlcToken getNewlineToken()
      Returns the newline token which terminates this pragma.
      Returns:
      the newline token
    • copy

      PragmaNode copy()
      Description copied from interface: ASTNode
      Returns a deep copy of this AST node. The node and all of its descendants will be cloned. The cloning does not copy analysis or attribute information.
      Specified by:
      copy in interface ASTNode
      Specified by:
      copy in interface BlockItemNode
      Specified by:
      copy in interface StatementNode
      Returns:
      deep copy of this node