GNU M4: Define a rule that matches text, and operates on that matched text?

南楼画角 提交于 2019-12-11 06:33:08

问题


Suppose I have:

File:

[x]

And I would like to define m4 macro:

define(`\[.*\]`, ...)

Question: Is this possible and how does one do it?


回答1:


It isn't possible as you can see in manual of m4:

3.1 Macro names

A name is any sequence of letters, digits, and the character ‘_’ (underscore), where the first character is not a digit. m4 will use the longest such sequence found in the input. If a name has a macro definition, it will be subject to macro expansion (see Macros). Names are case-sensitive.

Examples of legal names are: ‘foo’, ‘_tmp’, and ‘name01’.

The [ and ] characters aren't legal in macro definition.



来源:https://stackoverflow.com/questions/57206281/gnu-m4-define-a-rule-that-matches-text-and-operates-on-that-matched-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!