13#include "synctex_parser.h" 
   14#include "synctex_parser_utils.h" 
   16#ifndef __SYNCTEX_PARSER_PRIVATE__ 
   17#define __SYNCTEX_PARSER_PRIVATE__ 
   23typedef synctex_node_p synctex_non_null_node_p;
 
   43enum { synctex_shift_root, synctex_shift_no_root, synctex_shift_void, synctex_shift_no_void, synctex_shift_box, synctex_shift_no_box, synctex_shift_proxy, synctex_shift_no_proxy, synctex_shift_h, synctex_shift_v };
 
   45    synctex_mask_root = 1,
 
   46    synctex_mask_no_root = synctex_mask_root << 1,
 
   47    synctex_mask_void = synctex_mask_no_root << 1,
 
   48    synctex_mask_no_void = synctex_mask_void << 1,
 
   49    synctex_mask_box = synctex_mask_no_void << 1,
 
   50    synctex_mask_no_box = synctex_mask_box << 1,
 
   51    synctex_mask_proxy = synctex_mask_no_box << 1,
 
   52    synctex_mask_no_proxy = synctex_mask_proxy << 1,
 
   53    synctex_mask_h = synctex_mask_no_proxy << 1,
 
   54    synctex_mask_v = synctex_mask_h << 1,
 
   56enum { synctex_mask_non_void_hbox = synctex_mask_no_void | synctex_mask_box | synctex_mask_h, synctex_mask_non_void_vbox = synctex_mask_no_void | synctex_mask_box | synctex_mask_v };
 
   58    synctex_node_mask_sf = synctex_mask_root | synctex_mask_no_void | synctex_mask_no_box | synctex_mask_no_proxy,
 
   59    synctex_node_mask_vbox = synctex_mask_no_root | synctex_mask_no_void | synctex_mask_box | synctex_mask_no_proxy | synctex_mask_v,
 
   60    synctex_node_mask_hbox = synctex_mask_no_root | synctex_mask_no_void | synctex_mask_box | synctex_mask_no_proxy | synctex_mask_h,
 
   61    synctex_node_mask_void_vbox = synctex_mask_no_root | synctex_mask_void | synctex_mask_box | synctex_mask_no_proxy | synctex_mask_v,
 
   62    synctex_node_mask_void_hbox = synctex_mask_no_root | synctex_mask_void | synctex_mask_box | synctex_mask_no_proxy | synctex_mask_h,
 
   63    synctex_node_mask_vbox_proxy = synctex_mask_no_root | synctex_mask_no_void | synctex_mask_box | synctex_mask_proxy | synctex_mask_v,
 
   64    synctex_node_mask_hbox_proxy = synctex_mask_no_root | synctex_mask_no_void | synctex_mask_box | synctex_mask_proxy | synctex_mask_h,
 
   65    synctex_node_mask_nvnn = synctex_mask_no_root | synctex_mask_void | synctex_mask_no_box | synctex_mask_no_proxy,
 
   66    synctex_node_mask_input = synctex_mask_root | synctex_mask_void | synctex_mask_no_box | synctex_mask_no_proxy,
 
   67    synctex_node_mask_proxy = synctex_mask_no_root | synctex_mask_void | synctex_mask_no_box | synctex_mask_proxy
 
   72    synctex_tree_sibling_idx = 0,
 
   73    synctex_tree_s_input_max = 1,
 
   75    synctex_tree_s_parent_idx = 1,
 
   76    synctex_tree_sp_child_idx = 2,
 
   77    synctex_tree_spc_friend_idx = 3,
 
   78    synctex_tree_spcf_last_idx = 4,
 
   79    synctex_tree_spcfl_vbox_max = 5,
 
   81    synctex_tree_spcfl_next_hbox_idx = 5,
 
   82    synctex_tree_spcfln_hbox_max = 6,
 
   84    synctex_tree_spcfln_target_idx = 6,
 
   85    synctex_tree_spcflnt_proxy_hbox_max = 7,
 
   87    synctex_tree_spcfl_target_idx = 5,
 
   88    synctex_tree_spcflt_proxy_vbox_max = 6,
 
   90    synctex_tree_sp_friend_idx = 2,
 
   91    synctex_tree_spf_max = 3,
 
   93    synctex_tree_spf_arg_sibling_idx = 3,
 
   94    synctex_tree_spfa_max = 4,
 
   96    synctex_tree_spf_target_idx = 3,
 
   97    synctex_tree_spft_proxy_max = 4,
 
   99    synctex_tree_spfa_target_idx = 4,
 
  100    synctex_tree_spfat_proxy_last_max = 5,
 
  102    synctex_tree_s_child_idx = 1,
 
  103    synctex_tree_sc_next_hbox_idx = 2,
 
  104    synctex_tree_scn_sheet_max = 3,
 
  106    synctex_tree_sc_target_idx = 2,
 
  107    synctex_tree_sct_form_max = 3,
 
  109    synctex_tree_spc_target_idx = 3,
 
  110    synctex_tree_spct_handle_max = 4,
 
  115    synctex_data_input_tag_idx = 0,
 
  116    synctex_data_input_line_idx = 1,
 
  117    synctex_data_input_name_idx = 2,
 
  118    synctex_data_input_tln_max = 3,
 
  120    synctex_data_sheet_page_idx = 0,
 
  121    synctex_data_p_sheet_max = 1,
 
  123    synctex_data_form_tag_idx = 0,
 
  124    synctex_data_t_form_max = 1,
 
  126    synctex_data_tag_idx = 0,
 
  127    synctex_data_line_idx = 1,
 
  128    synctex_data_column_idx = 2,
 
  129    synctex_data_h_idx = 3,
 
  130    synctex_data_v_idx = 4,
 
  131    synctex_data_tlchv_max = 5,
 
  133    synctex_data_width_idx = 5,
 
  134    synctex_data_tlchvw_max = 6,
 
  136    synctex_data_height_idx = 6,
 
  137    synctex_data_depth_idx = 7,
 
  138    synctex_data_box_max = 8,
 
  140    synctex_data_mean_line_idx = 8,
 
  141    synctex_data_weight_idx = 9,
 
  142    synctex_data_h_V_idx = 10,
 
  143    synctex_data_v_V_idx = 11,
 
  144    synctex_data_width_V_idx = 12,
 
  145    synctex_data_height_V_idx = 13,
 
  146    synctex_data_depth_V_idx = 14,
 
  147    synctex_data_hbox_max = 15,
 
  149    synctex_data_ref_tag_idx = 0,
 
  150    synctex_data_ref_h_idx = 1,
 
  151    synctex_data_ref_v_idx = 2,
 
  152    synctex_data_ref_thv_max = 3,
 
  154    synctex_data_proxy_h_idx = 0,
 
  155    synctex_data_proxy_v_idx = 1,
 
  156    synctex_data_proxy_hv_max = 2,
 
  160typedef struct synctex_class_t synctex_class_s;
 
  161typedef synctex_class_s *synctex_class_p;
 
  174    synctex_node_p as_node;
 
  179typedef synctex_data_u *synctex_data_p;
 
  181#if defined(SYNCTEX_USE_CHARINDEX) 
  182typedef unsigned int synctex_charindex_t;
 
  183synctex_charindex_t synctex_node_charindex(synctex_node_p node);
 
  184typedef synctex_charindex_t synctex_lineindex_t;
 
  185synctex_lineindex_t synctex_node_lineindex(synctex_node_p node);
 
  186synctex_node_p synctex_scanner_handle(synctex_scanner_p scanner);
 
  187#define SYNCTEX_DECLARE_CHARINDEX                                                                                                                                                                                                              \ 
  188    synctex_charindex_t char_index;                                                                                                                                                                                                            \ 
  189    synctex_lineindex_t line_index; 
  190#define SYNCTEX_DECLARE_CHAR_OFFSET synctex_charindex_t charindex_offset; 
  192#define SYNCTEX_DECLARE_CHARINDEX 
  193#define SYNCTEX_DECLARE_CHAR_OFFSET 
  195struct synctex_node_t {
 
  196    SYNCTEX_DECLARE_CHARINDEX
 
  197    synctex_class_p 
class;
 
  199    synctex_data_u data[22];
 
  201    synctex_data_u data[1];
 
  205typedef synctex_node_p *synctex_node_r;
 
  212typedef synctex_point_s *synctex_point_p;
 
  219typedef synctex_box_s *synctex_box_p;
 
  239    synctex_node_type_none = 0,
 
  240    synctex_node_type_input,
 
  241    synctex_node_type_sheet,
 
  242    synctex_node_type_form,
 
  243    synctex_node_type_ref,
 
  244    synctex_node_type_vbox,
 
  245    synctex_node_type_void_vbox,
 
  246    synctex_node_type_hbox,
 
  247    synctex_node_type_void_hbox,
 
  248    synctex_node_type_kern,
 
  249    synctex_node_type_glue,
 
  250    synctex_node_type_rule,
 
  251    synctex_node_type_math,
 
  252    synctex_node_type_boundary,
 
  253    synctex_node_type_box_bdry,
 
  254    synctex_node_type_proxy,
 
  255    synctex_node_type_proxy_last,
 
  256    synctex_node_type_proxy_vbox,
 
  257    synctex_node_type_proxy_hbox,
 
  258    synctex_node_type_handle,
 
  259    synctex_node_number_of_types
 
  260} synctex_node_type_t;
 
  263synctex_node_type_t synctex_node_type(synctex_node_p node);
 
  264const char *synctex_node_isa(synctex_node_p node);
 
  266synctex_node_type_t synctex_node_target_type(synctex_node_p node);
 
  268synctex_node_type_t synctex_node_type(synctex_node_p node);
 
  269const char *synctex_node_isa(synctex_node_p node);
 
  271void synctex_node_log(synctex_node_p node);
 
  272void synctex_node_display(synctex_node_p node);
 
  277int synctex_node_form_tag(synctex_node_p node);
 
  279int synctex_node_mean_line(synctex_node_p node);
 
  280int synctex_node_weight(synctex_node_p node);
 
  281int synctex_node_child_count(synctex_node_p node);
 
  283int synctex_node_h(synctex_node_p node);
 
  284int synctex_node_v(synctex_node_p node);
 
  285int synctex_node_width(synctex_node_p node);
 
  287int synctex_node_box_h(synctex_node_p node);
 
  288int synctex_node_box_v(synctex_node_p node);
 
  289int synctex_node_box_width(synctex_node_p node);
 
  290int synctex_node_box_height(synctex_node_p node);
 
  291int synctex_node_box_depth(synctex_node_p node);
 
  293int synctex_node_hbox_h(synctex_node_p node);
 
  294int synctex_node_hbox_v(synctex_node_p node);
 
  295int synctex_node_hbox_width(synctex_node_p node);
 
  296int synctex_node_hbox_height(synctex_node_p node);
 
  297int synctex_node_hbox_depth(synctex_node_p node);
 
  299synctex_scanner_p synctex_scanner_new();
 
  300synctex_node_p synctex_node_new(synctex_scanner_p scanner, synctex_node_type_t type);
 
  310int synctex_scanner_display_switcher(synctex_scanner_p scanR);
 
  311void synctex_scanner_set_display_switcher(synctex_scanner_p scanR, 
int switcher);
 
  321typedef struct synctex_iterator_t synctex_iterator_s;
 
  322typedef synctex_iterator_s *synctex_iterator_p;
 
  336synctex_iterator_p synctex_iterator_new_display(synctex_scanner_p scanner, 
const char *name, 
int line, 
int column, 
int page_hint);
 
  348synctex_iterator_p synctex_iterator_new_edit(synctex_scanner_p scanner, 
int page, 
float h, 
float v);
 
  355void synctex_iterator_free(synctex_iterator_p iterator);
 
  360synctex_bool_t synctex_iterator_has_next(synctex_iterator_p iterator);
 
  367synctex_node_p synctex_iterator_next_result(synctex_iterator_p iterator);
 
  372int synctex_iterator_reset(synctex_iterator_p iterator);
 
  377int synctex_iterator_count(synctex_iterator_p iterator);
 
  382synctex_node_p synctex_node_target(synctex_node_p node);
 
  384#ifndef SYNCTEX_NO_UPDATER 
  391typedef struct synctex_updater_t synctex_updater_s;
 
  392typedef synctex_updater_s *synctex_updater_p;
 
  397synctex_updater_p synctex_updater_new_with_output_file(
const char *output, 
const char *directory);
 
  401void synctex_updater_append_magnification(synctex_updater_p updater, 
char *magnification);
 
  402void synctex_updater_append_x_offset(synctex_updater_p updater, 
char *x_offset);
 
  403void synctex_updater_append_y_offset(synctex_updater_p updater, 
char *y_offset);
 
  406void synctex_updater_free(synctex_updater_p updater);
 
  409#if defined(SYNCTEX_DEBUG) 
  411#define SYNCTEX_ASSERT assert 
  413#define SYNCTEX_ASSERT(UNUSED) 
  416#if defined(SYNCTEX_TESTING) 
  417#warning TESTING IS PROHIBITED 
  419#define __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wformat-extra-args\"") 
  421#define __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS _Pragma("clang diagnostic pop") 
  423#define __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS 
  424#define __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS 
  427#define SYNCTEX_TEST_BODY(counter, condition, desc, ...)                                                                                                                                                                                       \ 
  429        __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS                                                                                                                                                                                                    \ 
  430        if (!(condition)) {                                                                                                                                                                                                                    \ 
  432            printf("**** Test failed: %s\nfile %s\nfunction %s\nline %i\n", #condition, __FILE__, __FUNCTION__, __LINE__);                                                                                                                     \ 
  433            printf((desc), ##__VA_ARGS__);                                                                                                                                                                                                     \ 
  435        __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS                                                                                                                                                                                                     \ 
  438#define SYNCTEX_TEST_PARAMETER(counter, condition) SYNCTEX_TEST_BODY(counter, (condition), "Invalid parameter not satisfying: %s", #condition) 
  440int synctex_test_input(synctex_scanner_p scanner);
 
  441int synctex_test_proxy(synctex_scanner_p scanner);
 
  442int synctex_test_tree(synctex_scanner_p scanner);
 
  443int synctex_test_page(synctex_scanner_p scanner);
 
  444int synctex_test_handle(synctex_scanner_p scanner);
 
  445int synctex_test_display_query(synctex_scanner_p scanner);
 
  446int synctex_test_charindex();
 
  447int synctex_test_sheet_1();
 
  448int synctex_test_sheet_2();
 
  449int synctex_test_sheet_3();
 
  450int synctex_test_form();