bufferAsserts.i (3204B)
1 /* -*- C++ -*- vim: set syntax=cpp: */ 2 #ifndef __QUEX_INCLUDE_GUARD__BUFFER__ASSERTS_I 3 #define __QUEX_INCLUDE_GUARD__BUFFER__ASSERTS_I 4 5 #ifndef QUEX_OPTION_ASSERTS 6 7 #else 8 9 QUEX_NAMESPACE_MAIN_OPEN 10 11 QUEX_INLINE void 12 QUEX_NAME(BUFFER_ASSERT_pointers_in_range_core)(QUEX_NAME(Buffer)* B) 13 /* Check whether _read_p and _lexeme_start_p are in ther appropriate range. */ 14 { 15 __quex_assert( (B) != 0x0 ); 16 if( ! (*B)._memory._front && ! (*B)._memory._back ) { 17 return; 18 } 19 20 __quex_assert((*B)._memory._front < (*B)._memory._back); 21 __quex_assert((*B)._read_p >= (*B)._memory._front); 22 __quex_assert((*B)._lexeme_start_p >= (*B)._memory._front); 23 24 __quex_assert((*B).input.end_p >= (*B)._memory._front + 1); 25 __quex_assert((*B).input.end_p <= (*B)._memory._back); 26 27 __quex_assert((*B)._read_p <= (*B).input.end_p); 28 __quex_assert((*B)._lexeme_start_p <= (*B).input.end_p); 29 } 30 31 QUEX_INLINE void 32 QUEX_NAME(BUFFER_ASSERT_limit_codes_in_place_core)(QUEX_NAME(Buffer)* B) 33 { 34 if( ! (*B)._memory._front && ! (*B)._memory._back ) { 35 return; 36 } 37 __quex_assert(*((*B)._memory._front) == QUEX_SETTING_BUFFER_LIMIT_CODE); 38 __quex_assert(*((*B)._memory._back) == QUEX_SETTING_BUFFER_LIMIT_CODE); 39 __quex_assert(*(*B).input.end_p == QUEX_SETTING_BUFFER_LIMIT_CODE); 40 } 41 42 QUEX_INLINE void 43 QUEX_NAME(BUFFER_ASSERT_CONSISTENCY_core)(QUEX_NAME(Buffer)* B) 44 { 45 if( ! B ) return; 46 __quex_assert( B->input.lexatom_index_begin == -1 47 || B->input.lexatom_index_begin >= 0); 48 __quex_assert( B->input.lexatom_index_end_of_stream == -1 49 || B->input.lexatom_index_end_of_stream >= B->input.lexatom_index_begin); 50 QUEX_NAME(BUFFER_ASSERT_pointers_in_range_core)(B); 51 QUEX_NAME(BUFFER_ASSERT_limit_codes_in_place_core)(B); 52 } 53 54 QUEX_INLINE void 55 QUEX_NAME(BUFFER_ASSERT_NO_BUFFER_LIMIT_CODE_core)(const QUEX_TYPE_LEXATOM* Begin, 56 const QUEX_TYPE_LEXATOM* End) 57 { 58 const QUEX_TYPE_LEXATOM* iterator = 0x0; 59 __quex_assert(Begin <= End); 60 61 for(iterator = Begin; iterator != End; ++iterator) { 62 if( *iterator != QUEX_SETTING_BUFFER_LIMIT_CODE ) continue; 63 64 if( iterator == Begin ) { 65 QUEX_ERROR_EXIT("Buffer limit code character appeared as first character in buffer.\n" 66 "This is most probably a load failure.\n"); 67 } else { 68 QUEX_ERROR_EXIT("Buffer limit code character appeared as normal text content.\n"); 69 } 70 } 71 } 72 73 QUEX_NAMESPACE_MAIN_CLOSE 74 75 #endif 76 77 #endif /* __QUEX_INCLUDE_GUARD__BUFFER__ASSERTS_I */ 78