<<< wchar_c_single_quote(RM) wide char C single quote | Table Of Contents | Quote search parser example >>> |
Common Text Transformation Library http://cttl.sourceforge.net/
Category:
Description:
C double-quoted wide character string literals are enclosed in double quotation marks wchar_t(").
CTTL quote format for C string literal recognizes C-style escape characters, found inside the string.
Format:
wchar_c_double_quote( RM ) wchar_c_double_quote()
where optional RM clause describes grammar to match input symbols at the beginning of the string, providing access to the interior of the quoted string constant.
The implementation of wchar_c_double_quote(RM) is optimized for matching C strings formed by the double quotation marks.
Function wchar_c_double_quote() is an abbreviated version of the wchar_c_double_quote(RM). It is a shorthand notation for wchar_c_double_quote(true).
Algorithm:
Space sensitivity:
Searchability:
Search grammar evaluation algorithms
are enabled for C double quotes, as in the following fragment:
#include "cttl/cttl.h" using namespace cttl; int main() { std::wstring inp = L"Text \"\\\"\" one; \"A\" two ; "; typedef const_edge< policy_space<>, std::wstring > substr_T; substr_T substring( inp ); substr_T exterior = substring; substr_T interior = substring; size_t result = ( exterior( wchar_c_double_quote( interior( entity() ) ) ) + ( entity( iswalpha ) & symbol( L"two" ) ) + symbol( L';' ) ).bang_find( substring ); assert( result != std::wstring::npos ); assert( exterior == L"\"A\"" ); assert( interior == L"A" ); return 0; }
Example:
Programming languages, such as C and C++, recognize double-quoted wide character string literals. CTTL parser can handle such literal by using wchar_c_double_quote():
#include "cttl/cttl.h" using namespace cttl; int main() { std::wstring inp = L"\"\\x20\\\"ABC\""; typedef const_edge< policy_default, std::wstring > substr_T; substr_T substring( inp ); substr_T exterior = substring; substr_T interior = substring; size_t result = exterior( wchar_c_double_quote( interior( entity() ) ) ).match( substring ); assert( result != std::wstring::npos ); assert( exterior == L"\"\\x20\\\"ABC\"" ); assert( interior == L"\\x20\\\"ABC" ); return 0; }
Trace output format:
Copyright © 1997-2009 Igor Kholodov mailto:cttl@users.sourceforge.net.
Permission to copy and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
<<< wchar_c_single_quote(RM) wide char C single quote | Table Of Contents | Quote search parser example >>> |