Interface FunctionMacro

All Superinterfaces:
Macro

public interface FunctionMacro extends Macro

A FunctionMacro represents a C preprocessor function-like macro, which has the from #define f(X1,X2,...) .... The name of the macro is f, the X1,X2, etc., are the formal parameters, and the ... is a sequence of replacement tokens. The replacement tokens may include the formal parameters.

The last formal parameter in the formal parameter list may actually be an ELLIPSIS ("..."). In this case the number of formal parameters includes the ELLIPSIS as one of the formal parameters.

  • Method Details

    • getNumFormals

      int getNumFormals()
      Returns the number of formal parameters, including the ELLIPSIS parameter if present.
      Returns:
      the number of formal parameters
    • isVariadic

      boolean isVariadic()
      Is this a variadic macro?
      Returns:
      true if there is at least one formal, and the last formal is an ellipsis ("...")
    • getFormal

      org.antlr.runtime.Token getFormal(int index)
      Gets the index-th formal parameter. This may be ELLIPSIS ("...").
      Parameters:
      index - an integer in the range [0,numFormals-1]
      Returns:
      the index-th formal parameter token
    • getReplacementUnit

      FunctionMacro.FunctionReplacementUnit getReplacementUnit(int index)
      Description copied from interface: Macro
      Returns the index-th Macro.ReplacementUnit object of the Macro body.
      Specified by:
      getReplacementUnit in interface Macro
      Parameters:
      index - integer in range [0,numReplacements-1]
      Returns:
      the index-th replacement in the macro definition body