<<< Lexeme entity() | Table Of Contents | Lexeme end() >>> |
Common Text Transformation Library http://cttl.sourceforge.net/
Category:
Format:
Algorithm:
Space sensitivity:
The space sensitivity of begin() lexeme is disabled. The space policy is ignored. Regardless of the space policy, the evaluation of begin() begins immediately at the position specified by the upper boundary of parseable substring.
Searchability:
Search grammar evaluation algorithms
are enabled for begin() lexeme. The search moves upper boundary of the substring to the beginning-of-file location (the input string position with absolute offset zero.) The following fragment demonstrates terminal symbol search algorithm for begin():
#define CTTL_TRACE_EVERYTHING
#include "cttl/cttl.h"
using namespace cttl;
int main()
{
std::string inp = "XYZ";
const_edge<> substring( inp, inp.length(), inp.length() );
node<> start = substring.second;
size_t result = start( begin() ).find( substring );
assert( result == 0 );
assert( start.offset() == 0 );
assert( substring.first.offset() == 0 );
return 0;
}
Usage example:
#define CTTL_TRACE_EVERYTHING #include "cttl/cttl.h" using namespace cttl; int main() { std::string inp = "XYZ"; const_edge<> substring( inp ); const_edge<> token = substring; size_t result = token( begin() ).match( substring ); assert( result == 0 ); assert( token.length() == 0 ); substring.first.offset( 1 ); result = begin().match( substring ); assert( result == std::string::npos ); return 0; }
Trace output format:
The trace symbol of begin() lexeme is uppercase 'A', The above example generates the following trace:
---------------------@XYZ?{e 0-3 :3:1 ------------------------@| A 0-3 ------------------------@| e 0-0 } ~~~~~~~~~~~~~~~~~~~~~~~X@~A 1-3 FAIL
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.
<<< Lexeme entity() | Table Of Contents | Lexeme end() >>> |