Package edu.odu.cs.cowem.macroproc
Class Macro
- java.lang.Object
-
- edu.odu.cs.cowem.macroproc.Macro
-
public class Macro extends java.lang.ObjectA text substitution macro Macros can be called as name or name(arg1, arg2, ...) The ( ) in a macro call can be replaced by [ ] or { } or < > Macro calls are replaced by the macro body, with substitution for the macro parameters. A macro substitution also swallows a single blank preceding the macro name if the macro name starts with an alphanumeric character and if the call is not at the beginning of the string) and a single blank following the macro call if the macro call has no ( ), [ ], { }, or < >.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringapply(java.lang.String target0)Apply the macro to a string .java.lang.StringgetBody()java.util.List<java.lang.String>getFormalParams()java.lang.StringgetName()voidsetBody(java.lang.String body0)voidsetFormalParams(java.util.List<java.lang.String> formalParams0)voidsetName(java.lang.String name0)java.lang.StringtoString()Render the macro as a string.
-
-
-
Constructor Detail
-
Macro
public Macro(java.lang.String name0, java.util.List<java.lang.String> params, java.lang.String body0)Create a new macro.- Parameters:
name0- name of the macro - can be any string of visible charactersparams- list of formal parameter names. Names should be limited to alphanumerics and - _body0- body in which to replace params as a replacement for the macro call
-
Macro
public Macro(java.lang.String name0, java.lang.String body0)Create a new macro with zero parameters.- Parameters:
name0- name of the macro - can be any string of visible charactersbody0- body to use as a replacement for the macro call
-
-
Method Detail
-
apply
public final java.lang.String apply(java.lang.String target0)
Apply the macro to a string .- Parameters:
target0- string to be processed via this macro.- Returns:
- target0 with macro substitutions, unchanged if macro call could not be matched
-
toString
public final java.lang.String toString()
Render the macro as a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- a readable version of the macro
-
getName
public final java.lang.String getName()
- Returns:
- the name
-
setName
public final void setName(java.lang.String name0)
- Parameters:
name0- the name to set
-
getFormalParams
public final java.util.List<java.lang.String> getFormalParams()
- Returns:
- the formalParams
-
setFormalParams
public final void setFormalParams(java.util.List<java.lang.String> formalParams0)
- Parameters:
formalParams0- the formalParams to set
-
getBody
public final java.lang.String getBody()
- Returns:
- the body
-
setBody
public final void setBody(java.lang.String body0)
- Parameters:
body0- the body to set
-
-