C-adaptions.h (7622B)
1 #ifndef __QUEX_INCLUDE_GUARD__ANALYZER__C_ADAPTIONS_H 2 #define __QUEX_INCLUDE_GUARD__ANALYZER__C_ADAPTIONS_H 3 4 #ifdef self_accumulator_add 5 /* Token / Token Policy _____________________________________________________*/ 6 # undef self_token_take_text 7 8 /* Modes ____________________________________________________________________*/ 9 # undef self_current_mode_p 10 # undef self_current_mode_id 11 # undef self_current_mode_name 12 /* Map: mode id to mode and vice versa */ 13 # undef self_map_mode_id_to_mode_p 14 # undef self_map_mode_p_to_mode_id 15 /* Changing Modes */ 16 # undef self_set_mode_brutally 17 # undef self_enter_mode 18 /* Changing Modes with stack */ 19 # undef self_pop_mode 20 # undef self_pop_drop_mode 21 # undef self_push_mode 22 /* Undo lexeme match */ 23 # undef self_undo 24 # undef self_undo_n 25 26 /* Accumulator ______________________________________________________________*/ 27 # undef self_accumulator_add 28 # undef self_accumulator_add_character 29 # undef self_accumulator_clear 30 # undef self_accumulator_flush 31 # undef self_accumulator_is_empty 32 /* Indentation/Counter _____________________________________________________*/ 33 # ifdef QUEX_OPTION_LINE_NUMBER_COUNTING 34 # undef self_line_number 35 # undef self_line_number_at_begin 36 # undef self_line_number_at_begin_set 37 # undef self_line_number_at_end 38 # endif 39 # ifdef QUEX_OPTION_COLUMN_NUMBER_COUNTING 40 # undef self_column_number 41 # undef self_column_number_at_begin 42 # undef self_column_number_at_begin_set 43 # undef self_column_number_at_end 44 # endif 45 # ifdef QUEX_OPTION_INDENTATION_TRIGGER 46 # undef self_indentation 47 # undef self_disable_next_indentation_event 48 # endif 49 #endif 50 51 /* Token / Token Policy 52 * (NOTE: Macros for token sending are defined separately in file 'member/token-sending'. 53 * Those macros have to perform a little 'type loose'). */ 54 #define self_token_take_text(Begin, End) \ 55 QUEX_NAME_TOKEN(take_text)(__QUEX_CURRENT_TOKEN_P, &self, (Begin), (End)) 56 57 /* Modes */ 58 #define self_current_mode_p() /* QUEX_NAME(Mode)* */ QUEX_NAME(mode)(&self) 59 #define self_current_mode_id() /* int */ QUEX_NAME(mode_id)(&self) 60 #define self_current_mode_name() /* const char* */ QUEX_NAME(mode_name)(&self) 61 62 /* Map: mode id to mode and vice versa */ 63 #define self_map_mode_id_to_mode_p(ID) QUEX_NAME(map_mode_id_to_mode)(&self, (ID)) 64 #define self_map_mode_p_to_mode_id(ModeP) QUEX_NAME(map_mode_to_mode_id)(&self, (ModeP)) 65 66 /* Changing Modes */ 67 #define self_set_mode_brutally(ModeP) QUEX_NAME(set_mode_brutally)(&self, (ModeP)) 68 69 #ifdef QUEX_OPTION_TOKEN_POLICY_QUEUE 70 #define self_enter_mode(ModeP) \ 71 QUEX_NAME(enter_mode)(&self, (ModeP)) 72 #else 73 #define self_enter_mode(ModeP) \ 74 do { \ 75 QUEX_NAME(enter_mode)(&self, (ModeP)); \ 76 __self_result_token_id = self_write_token_p()->_id; \ 77 } while(0) 78 #endif 79 80 /* Changing Modes with stack */ 81 #define self_pop_mode() QUEX_NAME(pop_mode)(&self) 82 #define self_pop_drop_mode() QUEX_NAME(pop_drop_mode)(&self) 83 #define self_push_mode(ModeP) QUEX_NAME(push_mode)(&self, (ModeP)) 84 85 #ifdef QUEX_OPTION_LINE_NUMBER_COUNTING 86 # define self_line_number_at_begin() (self.counter._line_number_at_begin) 87 # define self_line_number_at_begin_set(X) do { self.counter._line_number_at_begin = (X); } while(0) 88 # define self_line_number_at_end() (self.counter._line_number_at_end) 89 # define self_line_number() (self_line_number_at_begin()) 90 #endif 91 #ifdef QUEX_OPTION_COLUMN_NUMBER_COUNTING 92 # define self_column_number_at_begin() (self.counter._column_number_at_begin) 93 # define self_column_number_at_begin_set(X) do { self.counter._column_number_at_begin = (X); } while(0) 94 # define self_column_number_at_end() (self.counter._column_number_at_end) 95 # define self_column_number() (self_column_number_at_begin()) 96 #endif 97 #ifdef QUEX_OPTION_INDENTATION_TRIGGER 98 # define self_indentation() (counter._indentation_stack.back - counter._indentation_stack.front + 1) 99 #endif 100 101 /* Accumulator ______________________________________________________________*/ 102 # define self_accumulator_add(Begin, End) QUEX_NAME(Accumulator_add)(&self.accumulator, Begin, End) 103 # define self_accumulator_add_character(Char) QUEX_NAME(Accumulator_add_character)(&self.accumulator, Char) 104 # define self_accumulator_clear() QUEX_NAME(Accumulator_clear)(&self.accumulator) 105 # define self_accumulator_is_empty() (self.accumulator.text.begin == self.accumulator.text.end) 106 # define self_accumulator_flush(TokenID) \ 107 do { \ 108 /* All functions must ensure: there is one cell to store terminating zero. */ \ 109 __quex_assert(self.accumulator.text.end < self.accumulator.text.memory_end); \ 110 \ 111 /* If no text is to be flushed, behave the same as self_send */ \ 112 /* That is: self_token_set_id(ID); */ \ 113 /* QUEX_TOKEN_POLICY_PREPARE_NEXT(); */ \ 114 /* BUT: We clear the text of the otherwise void token. */ \ 115 self_token_set_id(TokenID) ; \ 116 if( self.accumulator.text.begin == self.accumulator.text.end ) { \ 117 QUEX_NAME_TOKEN(take_text)(__QUEX_CURRENT_TOKEN_P, &self, \ 118 &QUEX_LEXEME_NULL, \ 119 (&QUEX_LEXEME_NULL) + 1); \ 120 } \ 121 else { \ 122 *(self.accumulator.text.end) = (QUEX_TYPE_LEXATOM)0; /* see above */ \ 123 \ 124 if( QUEX_NAME_TOKEN(take_text)(__QUEX_CURRENT_TOKEN_P, &self, \ 125 self.accumulator.text.begin, \ 126 self.accumulator.text.end) == false ) { \ 127 /* The called function does not need the memory chunk, we reuse it. */ \ 128 QUEX_NAME(Accumulator_clear)(&self.accumulator); \ 129 } else { \ 130 /* The called function wants to use the memory, so we get some new. */ \ 131 QUEX_NAME(Accumulator_init_memory)(&self.accumulator); \ 132 } \ 133 } \ 134 QUEX_TOKEN_POLICY_PREPARE_NEXT(); \ 135 } while(0) 136 137 /* Undo lexeme match */ 138 # define self_undo() QUEX_NAME(undo)(&self) 139 # define self_undo_n(N) QUEX_NAME(undo_n)(&self, N) 140 141 #endif /* __QUEX_INCLUDE_GUARD__ANALYZER__C_ADAPTIONS_H */