Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
programming and computer science, "maximal munch" or "longest match" is
the principle that when creating some construct, as much of the
available input as possible should be consumed. It is similar, though
not entirely identical, to the concept of a greedy algorithm. For
instance, the lexical syntax of many programming languages requires that
tokens be built from the maximum possible number of characters from the
input stream. This is done to resolve the problem of inherent ambiguity
in commonly used regular expressions such as. The term has also been
used in the field of compilers to describe a process of "tiling"
determining how a structured tree representing a program in an
intermediate language should be converted into linear machine code. An
entire subtree might be converted into just one machine instruction, and
the problem is how to split the tree into non-overlapping "tiles," each
representing one machine instruction. An effective strategy is simply to
make a tile of the largest subtree possible at any given point, which is
called "maximal munch."