As m4
reads its input, it separates it into tokens. A
token is either a name, a quoted string, or any single character, that
is not a part of either a name or a string. Input to m4
can also
contain comments.
A name is any sequence of letters, digits, and the character _ (underscore), where the first character is not a digit. If a name has a macro definition, it will be subject to macro expansion (see section How to invoke macros).
Examples of legal names are: `foo', `_tmp', and `name01'.
A quoted string is a sequence of characters surrounded by the quotes ` and ', where the number of start and end quotes within the string balances. The value of a string token is the text, with one level of quotes stripped off. Thus
`'
is the empty string, and
``quoted''
is the string
`quoted'
The quote characters can be changed at any time, using the builtin macro
changequote
. See section Changing the quote characters for more information.
Any character, that is neither a part of a name, nor of a quoted string, is a token by itself.
Comments in m4
are normally delimited by the characters `#'
and newline. All characters between the comment delimiters are ignored,
but the entire comment (including the delimiters) is passed through to
the output--comments are not discarded by m4
.
Comments cannot be nested, so the first newline after a `#' ends the comment. The commenting effect of the begin comment character can be inhibited by quoting it.
The comment delimiters can be changed to any string at any time, using
the builtin macro changecom
. See section Changing comment delimiters for more
information.