<<< quote(RL,RM,RR) generic quote | Table Of Contents | quote(char,RM,char) single character quote >>> |
Common Text Transformation Library http://cttl.sourceforge.net/
Category:
Asymmetric quoted expression (deprecated.)
NOTE: Asymmetric quote is no longer in use and will be phased out in the future releases of CTTL. It has been replaced by the positive lookbehind assertion algorithm, lookbehind(R1,R2).
Format:
Algorithm:
Asymmetric quote has no opening clause. The interior of the quote begins immediately at the upper boundary of the parseable substring.
Asymmetric quote performs non-terminal symbol search for the input symbol matching its RR grammar clause. The search algorithm is executed only once.
If RR succeeds, the RM expression is evaluated by
match()
grammar evaluation algorithm.
If RR fails, RM is never evaluated.
Parseable substring presented to the interior expression by RM is restricted by a half-open range
[ p1, p2 )
where
Precondition: expression RR must be a bang_find −searchable grammar construct.
Space sensitivity:
The space sensitivity of asymmetric quote is enabled. The interior clause RM invokes space policy grammar of the policy class specified by the parseable substring.
Searchability:
Search grammar evaluation algorithms
are syntactically enabled for asymmetric quotes, but have no effect: in either case match() grammar evaluation algorithm of RM is executed by the lexer.
Example:
Matching pair of opening and closing tags in XML document can be described by asymmetric 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; ( symbol( "<element>" ) + quote( true, interior( entity( isalpha ) ), symbol( "</element>" ) ) ).match( substring ); assert( interior == "text" ); return 0; }
Trace output format:
The trace symbol of an asymmetric 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> ----------@text</element>? {" 9-23 ---------------<element>@| 1 9-23 -<element>text</element>@| T 23-23 </element> --------------------@text? {e 9-13 :3:1 -----------<element>text@| $ 13-13 isalpha --------------------@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(RL,RM,RR) generic quote | Table Of Contents | quote(char,RM,char) single character quote >>> |