Counter.i (3642B)
1 #ifndef __QUEX_INCLUDE_GUARD__ANALYZER__COUNTER_I 2 #define __QUEX_INCLUDE_GUARD__ANALYZER__COUNTER_I 3 4 #include "definitions" 5 #include "analyzerAsserts" 6 #include "analyzerCounter" 7 8 QUEX_NAMESPACE_MAIN_OPEN 9 10 QUEX_INLINE void 11 QUEX_NAME(Counter_construct)(QUEX_NAME(Counter)* me) 12 { 13 /* Set all to '0xFF' in order to catch easily a lack of initialization. */ 14 __QUEX_IF_ASSERTS(memset((void*)me, 0xFF, sizeof(QUEX_NAME(Counter)))); 15 16 __QUEX_IF_COUNT_LINES(me->_line_number_at_begin = (size_t)1); 17 __QUEX_IF_COUNT_LINES(me->_line_number_at_end = (size_t)1); 18 __QUEX_IF_COUNT_COLUMNS(me->_column_number_at_begin = (size_t)1); 19 __QUEX_IF_COUNT_COLUMNS(me->_column_number_at_end = (size_t)1); 20 __QUEX_IF_COUNT_INDENTATION(QUEX_NAME(IndentationStack_init)(&me->_indentation_stack)); 21 } 22 23 #if 0 24 QUEX_INLINE void 25 QUEX_NAME(Counter_count)(QUEX_NAME(Counter)* me, 26 const QUEX_TYPE_LEXATOM* LexemeBegin, 27 const QUEX_TYPE_LEXATOM* LexemeEnd) 28 { 29 const QUEX_TYPE_LEXATOM* it = LexemeBegin; 30 31 __QUEX_COUNTER_SHIFT_VALUES(*me); 32 33 while( it != LexemeEnd ) 34 { 35 __QUEX_COUNTER_RULES(*me, it); 36 } 37 38 __QUEX_ASSERT_COUNTER_CONSISTENCY(me); \ 39 } 40 41 # if ! defined(__QUEX_COUNTER_RULES_NEWLINE) 42 # define __QUEX_COUNTER_RULES_NEWLINE(counter, iterator) \ 43 if( *iterator == (QUEX_TYPE_LEXATOM)'\n' ) { \ 44 (counter)._line_number_at_end += 1; \ 45 (counter)._column_number_at_end = 0; \ 46 } 47 # endif 48 49 QUEX_INLINE void 50 QUEX_NAME(Counter_count_newlines)(QUEX_NAME(Counter)* me, 51 const QUEX_TYPE_LEXATOM* LexemeBegin, 52 const QUEX_TYPE_LEXATOM* LexemeEnd) 53 { 54 const QUEX_TYPE_LEXATOM* it = LexemeBegin; 55 56 __QUEX_COUNTER_SHIFT_VALUES(*me); 57 58 while( it != LexemeEnd ) 59 { 60 __QUEX_COUNTER_RULES_NEWLINE(*me, it); 61 } 62 __QUEX_ASSERT_COUNTER_CONSISTENCY(me); \ 63 } 64 #endif 65 66 QUEX_INLINE void 67 QUEX_NAME(Counter_print_this)(QUEX_NAME(Counter)* me) 68 { 69 __QUEX_IF_COUNT_INDENTATION(size_t* it = 0x0); 70 71 __QUEX_STD_fprintf(stdout, " Counter:\n"); 72 # ifdef QUEX_OPTION_LINE_NUMBER_COUNTING 73 __QUEX_STD_fprintf(stdout, " _line_number_at_begin = %i;\n", (int)me->_line_number_at_begin); 74 __QUEX_STD_fprintf(stdout, " _line_number_at_end = %i;\n", (int)me->_line_number_at_end); 75 # endif 76 # ifdef QUEX_OPTION_COLUMN_NUMBER_COUNTING 77 __QUEX_STD_fprintf(stdout, " _column_number_at_begin = %i;\n", (int)me->_column_number_at_begin); 78 __QUEX_STD_fprintf(stdout, " _column_number_at_end = %i;\n", (int)me->_column_number_at_end); 79 # endif 80 # ifdef QUEX_OPTION_INDENTATION_TRIGGER 81 __QUEX_STD_fprintf(stdout, " _indentation_stack = {"); 82 for(it = me->_indentation_stack.front; it != me->_indentation_stack.back + 1; ++it) { 83 __QUEX_STD_fprintf(stdout, "%i, ", (int)*it); 84 } 85 __QUEX_STD_fprintf(stdout, "}\n"); 86 # endif 87 } 88 89 #if defined(QUEX_OPTION_INDENTATION_TRIGGER) 90 QUEX_INLINE void 91 QUEX_NAME(IndentationStack_init)(QUEX_NAME(IndentationStack)* me) 92 { 93 *(me->front) = 1; /* first indentation at column = 1 */ 94 me->back = me->front; 95 me->memory_end = me->front + QUEX_SETTING_INDENTATION_STACK_SIZE; 96 } 97 #endif 98 99 QUEX_NAMESPACE_MAIN_CLOSE 100 101 #endif /* __QUEX_INCLUDE_GUARD__ANALYZER__COUNTER_I */ 102