m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to not expand in strings


From: Eric Blake
Subject: Re: How to not expand in strings
Date: Fri, 01 Oct 2010 06:17:13 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.4

On 09/30/2010 10:00 PM, Mike Gran wrote:
Hi-

I have a newbie question.  I'm using m4 to preprocess files in
the Scheme language.  I've changed the quotes to
U+007B LEFT CURLY BRACKET and U+007D RIGHT CURLY BRACKET which
works great with Scheme.  But now I need to avoid processing
a curly bracket that appears inside a string, as in the
following

(set! str
       m4_ifdef({USE_REGEX},
                {" } "},
                {">  "}))

The ONLY way to represent an m4 close-quote sequence within an m4 string is to temporarily change quotes to some other string for the duration of quoting the problem character.

I guess I could just temporarily change the quote characters
again, but, is there some more compact way to not expand just that
one string that contains the curly bracket?

Sorry, there isn't. There have been some proposals for adding some additional syntax abilities in m4 2.0 to make it possible, but no code has materialized for it yet.

You may also want to consider how both autoconf and bison do things - they have a post-processing step and a specific character sequence that maps to a few specific characters that are otherwise difficult to represent directly in m4; in autoconf, they are quadrigraphs (quoting characters [ and ], so @:>@ maps to ] and @<:@ maps to ]); in bison, they are digraphs (quoting characters [ and ], so @{ maps to [ and @} maps to ]). Again, making a post-processing step a built-in part of m4 would be nice, but no one has contributed code.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]