/* * Print the first pending token truncated then print ellipsis. * Free all tokens and empty the vector. * - p->pending_col = column where printing should start */ static void print_pending_truncated(printer_t *p) { pvector_t *v; void *tk; uint32_t i, n; p->col = p->pending_col; v = &p->pending_tokens; n = v->size; assert(n > 0); tk = v->data[0]; switch (ptr_tag(tk)) { case PP_TOKEN_OPEN_TAG: print_label_truncated(p, untag_open(tk)); break; case PP_TOKEN_ATOMIC_TAG: print_atomic_truncated(p, untag_atomic(tk)); break; case PP_TOKEN_CLOSE_TAG: pp_space(p); pp_ellipsis(p); free_close_token(p, untag_close(tk)); break; case PP_TOKEN_SEPARATOR_TAG: print_atomic_truncated(p, untag_separator(tk)); break; } for (i=1; i<n; i++) { free_token(p, v->data[i]); } pvector_reset(v); }
/* * Process a new token tk: * - add space + token at the end of the line, etc. * - then add token at the end of the token queue * - then forward tokens to the printer if possible */ static void process_token(formatter_t *f, void *tk) { switch (ptr_tag(tk)) { case PP_TOKEN_OPEN_TAG: process_open_token(f, untag_open(tk)); f->depth ++; break; case PP_TOKEN_ATOMIC_TAG: process_atomic_token(f, untag_atomic(tk)); break; case PP_TOKEN_CLOSE_TAG: assert(f->depth > 0); f->depth --; process_close_token(f, untag_close(tk)); break; case PP_TOKEN_SEPARATOR_TAG: process_separator_token(f, untag_separator(tk)); break; } // add tk to the queue ptr_queue_push(&f->token_queue, tk); // forward what we can to the printer flush_wide_blocks(f); }
/* * Process token tk * - if p is in HVMODE and tk is either an atomic or an open token * then tk->bsize is used to decide whether tk fits on the current line */ static void print_token(printer_t *p, void *tk) { pp_open_token_t *open; pp_atomic_token_t *atom; pp_open_token_t copy; switch (ptr_tag(tk)) { case PP_TOKEN_OPEN_TAG: open = untag_open(tk); check_newline(p, open->bsize); // print_open_token may free the token so we // make a local copy first. copy = *open; print_open_token(p, open); if (p->full_line) { p->overfull_count ++; } else { printer_push_state(p, ©); } break; case PP_TOKEN_ATOMIC_TAG: atom = untag_atomic(tk); check_newline(p, atom->bsize); print_atomic_token(p, atom); p->no_space = false; p->no_break = false; // this has no effect in HMODE break; case PP_TOKEN_CLOSE_TAG: print_close_token(p, untag_close(tk)); // space and break are allowed now p->no_space = false; p->no_break = false; if (p->overfull_count > 0) { p->overfull_count --; } else { printer_pop_state(p); } break; case PP_TOKEN_SEPARATOR_TAG: atom = untag_separator(tk); /* * a separator is treated like an atomic token * with no space or break allowed before or after * the token */ p->no_space = true; p->no_break = true; print_atomic_token(p, atom); p->no_space = true; p->no_break = true; // this has no effect in HMODE break; } // for debugging fflush(p->file); }
BOOL CTagManager::RegisterNoCopy(CTag *pTag) { //이름이 없거나 같은 이름으로 등록된 것이 있음 if( pTag->GetName() == "" || Find(pTag->GetName()) != NULL ) return FALSE; if( pTag->GetName() == "__ROOT" ) m_ptrRootTag = pTag; my_map::value_type registerTri( pTag->GetName(), ptr_tag(pTag) ); //등록 성공 or 실패 정보를 리턴 return m_mapRegistered.insert( registerTri ).second; }
/* * Free token: use tag to call one of the three functions above * - tk must be a tagged pointer */ static void free_token(printer_t *p, void *tk) { switch (ptr_tag(tk)) { case PP_TOKEN_OPEN_TAG: free_open_token(p, untag_open(tk)); break; case PP_TOKEN_ATOMIC_TAG: free_atomic_token(p, untag_atomic(tk)); break; case PP_TOKEN_CLOSE_TAG: free_close_token(p, untag_close(tk)); break; case PP_TOKEN_SEPARATOR_TAG: free_atomic_token(p, untag_separator(tk)); break; } }
/* * Print all the pending tokens. * Free all pending tokens and empty the pending_vector. * - p->pending_col = column where printing should start */ static void print_pending(printer_t *p) { pvector_t *v; void *tk; bool space; uint32_t i, n; // restore p->col p->col = p->pending_col; v = &p->pending_tokens; n = v->size; assert(n > 0); // no space before the first token space = false; for (i=0; i<n; i++) { tk = v->data[i]; switch (ptr_tag(tk)) { case PP_TOKEN_OPEN_TAG: if (space) pp_space(p); print_label(p, untag_open(tk)); space = tk_sep_allowed(untag_open(tk)); break; case PP_TOKEN_ATOMIC_TAG: if (space) pp_space(p); print_atomic(p, untag_atomic(tk)); space = true; break; case PP_TOKEN_CLOSE_TAG: print_close(p, untag_close(tk)); space = true; break; case PP_TOKEN_SEPARATOR_TAG: // no space before or after that token print_atomic(p, untag_separator(tk)); space = false; break; } } pvector_reset(v); }