Java Reference
In-Depth Information
public void execute(Context c)
{
while (term.eval(c) != null)
{
body.execute(c);
}
}
}
SOLUTION 25.3
The intent of I NTERPETER is to let you define composite classes that interpret, or bring
meaning to, an operation, based on the type of composition they represent. This lets you
create a "language," or infinite pattern of executable operations. The intent of C OMMAND is
merely to encapsulate a request in an object. Can an interpreter work as a command? Sure.
The question of which pattern applies depends on your intent. Are you defining an infinite
pattern of executable operations, or are you encapsulating requests in objects?
SOLUTION 25.4
One solution is: If the possible compositions of an interpreter hierarchy are a "language,"
the job of a parser is to translate elements of a textual language into corresponding elements
of the interpreter language.
Search WWH ::




Custom Search