+/* The syntax table cache */
+
+/*
+ The *-single-property-change versions turn out to be unbearably slow.
+ Do not enable them in a production or distribution version.
+*/
+#define NEXT_SINGLE_PROPERTY_CHANGE 0
+#define PREVIOUS_SINGLE_PROPERTY_CHANGE 0
+
+/* Test instruments, used in macros below.
+ Define SYNTAX_CACHE_STATISTICS to enable them. */
+/* #undef SYNTAX_CACHE_STATISTICS */
+
+#ifdef SYNTAX_CACHE_STATISTICS
+#define SYNTAX_CACHE_STATISTICS_REPORT_INTERVAL 100000
+
+enum syntax_cache_statistics_functions {
+ scs_no_function = -1,
+ scs_find_context = 0,
+ scs_find_defun_start,
+ scs_scan_words,
+ scs_Fforward_comment,
+ scs_scan_lists,
+ scs_Fbackward_prefix_characters,
+ scs_scan_sexps_forward,
+ scs_number_of_functions
+};
+
+/* keep this in synch with syntax.c */
+extern char* syntax_cache_statistics_function_names[scs_number_of_functions];
+
+struct syntax_cache_statistics {
+ /* inits + misses_hi + misses_lo + #HITS = total_updates */
+ int total_updates;
+ int inits;
+ int misses_lo;
+ int misses_hi;
+ int min_length;
+ int max_length;
+ double mean_length;
+ double mean_length_on_miss;
+ enum syntax_cache_statistics_functions this_function;
+ int functions[scs_number_of_functions];
+};
+
+extern struct syntax_cache_statistics scs_statistics;
+
+#define SCS_STATISTICS_SET_FUNCTION(fndx) scs_statistics.this_function = fndx
+/* used in macros below */
+#define SYNTAX_CACHE_STATISTICS_COUNT_INIT scs_statistics.inits++
+
+#else
+
+#define SCS_STATISTICS_SET_FUNCTION(fndx)
+#define SYNTAX_CACHE_STATISTICS_COUNT_INIT
+
+#endif /* SYNTAX_CACHE_STATISTICS */
+
+/* Theory of the syntax table cache
+
+ This cache cooperates with but is conceptually different from the
+ mirror table. The mirror table precomputes (and caches, if you like)
+ the syntax codes for characters in a given syntax table, taking into
+ account possible inheritance from a table given by a parent text object.
+ The syntax table cache checks for overriding tables defined by
+ _subobjects_.
+
+ This implementation defines the "subobjects" by _extent properties_.
+ We may restrict them to _text_ properties. There are two lookup
+ styles for the cache, "single code" and "full table". In the "single
+ code" style, a given syntax code, kept in the `syntax_code' member, is
+ applied to the entire range (#### check this). In the "full table"
+ style, a syntax table kept in the `current_syntax_table' member is
+ checked for each character in the range. If the flag `use_code' is
+ non-zero, the "single code" is used, otherwise the "full table".
+
+ The cache is valid for the range `[prev_change, next_change)' in the
+ text object (buffer or string) `object'.
+
+ If the current position is outside the range valid for the cache, the
+ cache is updated by checking for the text property `syntax-table'. If
+ present, its value is either a syntax code or a syntax table, and the
+ appropriate member and `use_code' are updated accordingly. If absent
+ or nil, the default syntax table from the `buffer' member is used. The
+ extent of the property is used to reinitialize the cache's validity
+ range. (We would like to improve this by checking the property value
+ against `old_prop', and if the same, extend the validity range of the
+ cache by the extent of the property.)
+
+ Note: the values Qt and Qnil for `object' are not supported in this
+ implementation. GNU Emacs uses them for reasons not yet (####) clear.
+*/