org.anarres.cpp
Class Macro

java.lang.Object
  extended by org.anarres.cpp.Macro

public class Macro
extends Object

A macro object. This encapsulates a name, an argument count, and a token stream for replacement. The replacement token stream may contain the extra tokens Token.M_ARG and Token.M_STRING.


Constructor Summary
Macro(Source source, String name)
           
Macro(String name)
           
 
Method Summary
 void addPaste(Token tok)
          Adds a "paste" operator to the expansion of this macro.
 void addToken(Token tok)
          Adds a token to the expansion of this macro.
 int getArgs()
          Returns the number of arguments to this macro.
 String getName()
          Returns the name of this macro.
 Source getSource()
          Returns the Source from which this macro was parsed.
 String getText()
           
 boolean isFunctionLike()
          Returns true if this is a function-like macro.
 boolean isVariadic()
          Returns true if this is a variadic function-like macro.
 void setArgs(List<String> args)
          Sets the arguments to this macro.
 void setSource(Source s)
          Sets the Source from which this macro was parsed.
 void setVariadic(boolean b)
          Sets the variadic flag on this Macro.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Macro

public Macro(Source source,
             String name)

Macro

public Macro(String name)
Method Detail

setSource

public void setSource(Source s)
Sets the Source from which this macro was parsed.


getSource

public Source getSource()
Returns the Source from which this macro was parsed. This method may return null if the macro was not parsed from a regular file.


getName

public String getName()
Returns the name of this macro.


setArgs

public void setArgs(List<String> args)
Sets the arguments to this macro.


isFunctionLike

public boolean isFunctionLike()
Returns true if this is a function-like macro.


getArgs

public int getArgs()
Returns the number of arguments to this macro.


setVariadic

public void setVariadic(boolean b)
Sets the variadic flag on this Macro.


isVariadic

public boolean isVariadic()
Returns true if this is a variadic function-like macro.


addToken

public void addToken(Token tok)
Adds a token to the expansion of this macro.


addPaste

public void addPaste(Token tok)
Adds a "paste" operator to the expansion of this macro. A paste operator causes the next token added to be pasted to the previous token when the macro is expanded. It is an error for a macro to end with a paste token.


getText

public String getText()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007 Shevek, Anarres. All Rights Reserved.