Go to the first, previous, next, last section, table of contents.

Lexical and syntactic conventions

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'.

Quoted strings

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


is the string


The quote characters can be changed at any time, using the builtin macro changequote. See section Changing the quote characters for more information.

Other tokens

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.

Go to the first, previous, next, last section, table of contents.