<<< ansi_double_quote(RM) ANSI double quote | Table Of Contents | c_double_quote(RM) C double quote >>> |
Common Text Transformation Library http://cttl.sourceforge.net/
Category:
Description:
C single-quoted literals are enclosed in single quotation marks (').
CTTL quote format for C literals recognizes C-style escape characters inside the character literal.
Format:
c_single_quote( RM ) c_single_quote()
where optional RM clause describes grammar to match input symbols at the beginning of the C character literal, providing access to the interior of the quoted character constant.
The implementation of c_single_quote(RM) is optimized for matching C literals formed by the single quotation marks.
Function c_single_quote() is an abbreviated version of the c_single_quote(RM). It is a shorthand notation for c_single_quote(true).
Algorithm:
Space sensitivity:
Searchability:
Search grammar evaluation algorithms
are enabled for C single quotes, as in the following fragment:
//#define CTTL_TRACE_EVERYTHING #include "cttl/cttl.h" using namespace cttl; int main() { std::string inp = "Text \'\\\'\' one; \'A\' two ; "; const_edge< policy_space<> > substring( inp ); const_edge<> exterior = substring; const_edge<> interior = substring; size_t result = ( exterior( c_single_quote( interior( entity() ) ) ) + ( entity( isalpha ) & symbol( "two" ) ) + symbol( ';' ) ).bang_find( substring ); assert( result != std::string::npos ); assert( exterior == "\'A\'" ); assert( interior == "A" ); return 0; }
Example:
Programming languages, such as C/C++ and Java, recognize single-quoted character literals. CTTL parser can handle such literal by using c_single_quote():
//#define CTTL_TRACE_EVERYTHING #include "cttl/cttl.h" using namespace cttl; int main() { std::string inp = "\'\\x20\'"; const_edge<> substring( inp ); const_edge<> exterior = substring; const_edge<> interior = substring; size_t result = exterior( c_single_quote( interior( entity() ) ) ).match( substring ); assert( result != std::string::npos ); assert( exterior == "\'\\x20\'" ); assert( interior == "\\x20" ); return 0; }
Trace output format:
The trace symbol of C single quote is a double quotation mark ("), enclosed in a pair of symmetrical braces:
{" ... }
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.
<<< ansi_double_quote(RM) ANSI double quote | Table Of Contents | c_double_quote(RM) C double quote >>> |