<<< Quote evaluation rules | Table Of Contents | quote(true,RM,RR) asymmetric quote >>> |
Common Text Transformation Library http://cttl.sourceforge.net/
Category:
Format:
Algorithm:
Quoted expression performs a search for the balanced pair of two arbitrary grammatical clauses RL and RR.
The quote(RL,RM,RR) constructs least specialized implementation, alternating balanced search grammar evaluation on expressions RL and RR until an even match is found.
Precondition: Both expressions RL and RR must be bang_find −searchable grammar constructs.
Space sensitivity:
Searchability:
Example:
Matching pair of opening and closing tags in XML document can be described by a generic quote as follows:
#define CTTL_TRACE_EVERYTHING #include "cttl/cttl.h" using namespace cttl; int main() { std::string inp = "<element>text</element>"; const_edge<> substring( inp ); const_edge<> interior = substring; quote( symbol( "<element>" ), interior( entity() ), symbol( "</element>" ) ).match( substring ); assert( interior == "text" ); return 0; }
Trace output format:
The trace symbol of a quote is a double quotation mark ("), enclosed in a pair of symmetrical braces:
{" ... }
The above sample generates the following trace:
-@<element>text</element>?{" 0-23 ---------------<element>@| T 9-23 <element> -<element>text</element>@| T 23-23 </element> ~~~~~~~~~~~~~~~<element>@~ T 9-23 FAIL <element> --------------------@text? {e 9-13 :3:1 --------------------@text? {; 9-13 ---------------<element>@| 1 9-13 --------------------@text? {! 9-13 -----------<element>text@| Z 13-13 EOF } } --------------------@text| e 9-13 } }
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.
<<< Quote evaluation rules | Table Of Contents | quote(true,RM,RR) asymmetric quote >>> |