#include <xtl_op_impl.h>
Public Member Functions | |
template<typename SubstrT > | |
size_t | bang_find (SubstrT &edge_) |
Implements repeatable search evaluation for the set complement operator, starting at the upper boundary of the parseable substring. | |
template<typename SubstrT > | |
size_t | find (SubstrT &edge_) |
Implements search evaluation for the set complement operator, starting at the upper boundary of the parseable substring. | |
template<typename SubstrT > | |
size_t | match (SubstrT &edge_) |
Implements match evaluation for the set complement operator, starting at the upper boundary of the parseable substring. | |
xtl_opbinminus (Left_exprT const &lhs_expr_, Right_exprT const &rhs_expr_) | |
Constructs and initializes the object. |
Left_exprT | specifies type of left-hand-side grammar expression object, determined by the C++ compiler at compile time. | |
Right_exprT | specifies type of right-hand-side grammar expression object, determined by the C++ compiler at compile time. |
Definition at line 2299 of file xtl_op_impl.h.
cttl_impl::xtl_opbinminus< Left_exprT, Right_exprT >::xtl_opbinminus | ( | Left_exprT const & | lhs_expr_, | |
Right_exprT const & | rhs_expr_ | |||
) |
Constructs and initializes the object.
Left_exprT | specifies type of left-hand-side grammar expression object, determined by the C++ compiler at compile time. | |
Right_exprT | specifies type of right-hand-side grammar expression object, determined by the C++ compiler at compile time. |
lhs_expr_ | immutable reference to left-hand-side grammar expression object. | |
rhs_expr_ | immutable reference to right-hand-side grammar expression object. |
Definition at line 2322 of file xtl_op_impl.h.
size_t cttl_impl::xtl_opbinminus< Left_exprT, Right_exprT >::bang_find | ( | SubstrT & | edge_ | ) |
Implements repeatable search evaluation for the set complement operator, starting at the upper boundary of the parseable substring.
SubstrT | specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge . |
edge_ | reference to the parseable substring. |
edge_
parameter, is consumed according to the size of the matched fragment.SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Definition at line 2467 of file xtl_op_impl.h.
02468 { 02469 // !!(L_-R) 02470 CTTL_TRACE_LEVEL_BANG( '-' ); 02471 typename SubstrT::offset_guard_T saved_first_offset( edge_.first ); 02472 typename SubstrT::offset_guard_T match_lhs_offset( edge_.first, SubstrT::string_T::npos ); 02473 xtl_edge_offset_guard< SubstrT > saved_lhs_edge( edge_ ); // preserve current substring 02474 // if this offset stops progressing, we must bail out of infinite loop: 02475 typename SubstrT::offset_guard_T iteration_offset( edge_.first, SubstrT::string_T::npos ); 02476 02477 while ( ( match_lhs_offset = this->m_expr_lhs.bang_find( edge_ ) ) != SubstrT::string_T::npos ) { 02478 saved_lhs_edge.save( edge_ ); // preserve LHS edge 02479 edge_.second.offset( edge_.first.offset() ); // restrict RHS substring 02480 edge_.first.offset( match_lhs_offset ); 02481 typename SubstrT::strict_edge_T strict_universe( edge_ ); 02482 if ( this->m_expr_rhs.match( strict_universe ) == SubstrT::string_T::npos ) { 02483 // RHS did not match, we succeed: 02484 saved_lhs_edge.restore( edge_ ); // restore LHS edge 02485 return match_lhs_offset; 02486 } 02487 02488 // RHS matched, continue searching: 02489 saved_lhs_edge.restore( edge_ ); // restore LHS edge 02490 02491 if ( iteration_offset == edge_.first.offset() ) { 02492 CTTL_TRACE_TEXT( '-', "!!(R1-R2): search made no progress: bailing out" ); 02493 break; // second, third, etc., iteration hasn't made any progress: bail out 02494 } 02495 02496 iteration_offset = edge_.first.offset(); 02497 } 02498 02499 edge_.first.offset( saved_first_offset ); // restore substring 02500 CTTL_TRACE_RESULT( false, '-' ); 02501 return SubstrT::string_T::npos; 02502 }
size_t cttl_impl::xtl_opbinminus< Left_exprT, Right_exprT >::find | ( | SubstrT & | edge_ | ) |
Implements search evaluation for the set complement operator, starting at the upper boundary of the parseable substring.
SubstrT | specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge . |
edge_ | reference to the parseable substring. |
edge_
parameter, is consumed according to the size of the matched fragment.SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Definition at line 2412 of file xtl_op_impl.h.
02413 { 02414 // !L-R_ 02415 CTTL_TRACE_LEVEL_FIND( '-' ); 02416 typename SubstrT::offset_guard_T saved_first_offset( edge_.first ); 02417 xtl_edge_offset_guard< SubstrT > saved_lhs_edge( edge_ ); // preserve current substring 02418 02419 // position of the left side of the substring after LHS succeeds: 02420 typename SubstrT::offset_guard_T match_lhs_offset( edge_.first, this->m_expr_lhs.find( edge_ ) ); 02421 if ( match_lhs_offset != SubstrT::string_T::npos ) { 02422 saved_lhs_edge.save( edge_ ); // preserve LHS edge 02423 edge_.second.offset( edge_.first.offset() ); // restrict RHS substring 02424 edge_.first.offset( match_lhs_offset ); 02425 typename SubstrT::strict_edge_T strict_universe( edge_ ); 02426 if ( this->m_expr_rhs.match( strict_universe ) == SubstrT::string_T::npos ) { 02427 // RHS did not match, we succeed: 02428 saved_lhs_edge.restore( edge_ ); // restore LHS edge 02429 return match_lhs_offset; 02430 } 02431 } 02432 02433 // RHS matched, we fail: 02434 edge_.first.offset( saved_first_offset ); // restore substring 02435 edge_.second.offset( saved_lhs_edge.second ); 02436 CTTL_TRACE_RESULT( false, '-' ); 02437 return SubstrT::string_T::npos; 02438 }
size_t cttl_impl::xtl_opbinminus< Left_exprT, Right_exprT >::match | ( | SubstrT & | edge_ | ) |
Implements match evaluation for the set complement operator, starting at the upper boundary of the parseable substring.
SubstrT | specifies type of the parseable substring. Can be either cttl::const_edge or cttl::edge . |
edge_ | reference to the parseable substring. |
edge_
parameter, is consumed according to the size of the matched fragment.SubstrT::string_T::npos
, indicating that the evaluation algorithm has failed. Definition at line 2356 of file xtl_op_impl.h.
02357 { 02358 // L-R_ strict set-difference 02359 // if L succeeds, and R fails, substring needs to be restored 02360 CTTL_TRACE_LEVEL_MATCH( '-' ); 02361 typename SubstrT::offset_guard_T saved_first_offset( edge_.first ); 02362 xtl_edge_offset_guard< SubstrT > saved_lhs_edge( edge_ ); // preserve current substring 02363 02364 // position of the left side of the substring after LHS succeeds: 02365 typename SubstrT::offset_guard_T match_lhs_offset( edge_.first, this->m_expr_lhs.match( edge_ ) ); 02366 if ( match_lhs_offset != SubstrT::string_T::npos ) { 02367 saved_lhs_edge.save( edge_ ); // preserve LHS edge 02368 edge_.second.offset( edge_.first.offset() ); // restrict RHS substring 02369 edge_.first.offset( match_lhs_offset ); 02370 typename SubstrT::strict_edge_T strict_universe( edge_ ); 02371 if ( this->m_expr_rhs.match( strict_universe ) == SubstrT::string_T::npos ) { 02372 // RHS did not match, we succeed: 02373 saved_lhs_edge.restore( edge_ ); // restore LHS edge 02374 return match_lhs_offset; 02375 } 02376 } 02377 02378 // RHS matched, we fail: 02379 edge_.first.offset( saved_first_offset ); // restore substring 02380 edge_.second.offset( saved_lhs_edge.second ); 02381 CTTL_TRACE_RESULT( false, '-' ); 02382 return SubstrT::string_T::npos; 02383 }