cttl::policy_space< flag_follow_region > Struct Template Reference

Space policy specialization to skip user-defined void regions. More...

#include <policy.h>

Inheritance diagram for cttl::policy_space< flag_follow_region >:

cttl::policy_mapped_space cttl::policy_space< flag_follow_space|flag_follow_region > cttl::policy_space< flag_greedy|flag_follow_region > cttl::policy_space< flag_greedy|flag_follow_space|flag_follow_region >

List of all members.

Public Member Functions

template<typename SubstrT >
size_t match (SubstrT &substr_)
 Defines CTTL grammar production rule to evaluate grammar expression matching the white space defined by the map of void regions.


Detailed Description

template<>
struct cttl::policy_space< flag_follow_region >

Space policy specialization to skip user-defined void regions.

Makes user-defined void regions "invisible" to the CTTL lexer.
The region-based policy is typically used in two-pass algorithms. For example,
  • Programming language comments can be detected by the first pass through the input.
    During the first pass, the boundaries of comments are added to the internal map of void regions.
    The map of void regions is kept and maintained by the policy.

  • During the second pass, the internal map of void regions is looked up and automatically bypassed by the lexer.

Definition at line 543 of file policy.h.


Member Function Documentation

template<typename SubstrT >
size_t cttl::policy_space< flag_follow_region >::match ( SubstrT &  substr_  ) 

Defines CTTL grammar production rule to evaluate grammar expression matching the white space defined by the map of void regions.

Template Parameters:
SubstrT specifies type of the parseable substring, such as cttl::const_edge or cttl::edge.
Parameters:
substr_ references parseable substring.
Returns:
absolute position of the substring upper boundary after expression that matches white space is evaluated.
Postcondition:
The function must
  • always succeed
  • return a valid offset within the specified substring.
Remarks:
This implementation is ungreedy.

Reimplemented in cttl::policy_space< flag_follow_space|flag_follow_region >, cttl::policy_space< flag_greedy|flag_follow_region >, and cttl::policy_space< flag_greedy|flag_follow_space|flag_follow_region >.

Definition at line 571 of file policy.h.

00572     {
00573         size_t ungreedy_offset = substr_.first.offset();
00574         lower_bound( ungreedy_offset, substr_ );
00575         // policy_space is ungreedy:
00576         return ungreedy_offset;
00577     }


The documentation for this struct was generated from the following file:

Generated on Sun Aug 23 13:43:45 2009 for Common Text Transformation Library by  doxygen 1.5.9