diff options
Diffstat (limited to 'src/syntax.h')
| -rw-r--r-- | src/syntax.h | 105 |
1 files changed, 65 insertions, 40 deletions
diff --git a/src/syntax.h b/src/syntax.h index 1b96284af42..06ce0ec55df 100644 --- a/src/syntax.h +++ b/src/syntax.h @@ -1,6 +1,6 @@ /* Declarations having to do with GNU Emacs syntax tables. -Copyright (C) 1985, 1993-1994, 1997-1998, 2001-2013 Free Software +Copyright (C) 1985, 1993-1994, 1997-1998, 2001-2015 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,12 +18,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef EMACS_SYNTAX_H +#define EMACS_SYNTAX_H + +#include "buffer.h" +#include "lisp.h" + INLINE_HEADER_BEGIN -#ifndef SYNTAX_INLINE -# define SYNTAX_INLINE INLINE -#endif extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object); +extern void update_syntax_table_forward (ptrdiff_t, bool, Lisp_Object); /* The standard syntax table is stored where it will automatically be used in all new buffers. */ @@ -55,30 +59,32 @@ enum syntaxcode other side by any char with the same syntaxcode. */ Sstring_fence, /* Starts/ends string which is delimited on the other side by any char with the same syntaxcode. */ - Smax /* Upper bound on codes that are meaningful */ + Smax /* Upper bound on codes that are meaningful. */ }; struct gl_state_s { - Lisp_Object object; /* The object we are scanning. */ - ptrdiff_t start; /* Where to stop. */ - ptrdiff_t stop; /* Where to stop. */ + Lisp_Object object; /* The object we are scanning. */ + ptrdiff_t start; /* Where to stop. */ + ptrdiff_t stop; /* Where to stop. */ bool use_global; /* Whether to use global_code - or c_s_t. */ - Lisp_Object global_code; /* Syntax code of current char. */ - Lisp_Object current_syntax_table; /* Syntax table for current pos. */ - Lisp_Object old_prop; /* Syntax-table prop at prev pos. */ - ptrdiff_t b_property; /* First index where c_s_t is valid. */ + or c_s_t. */ + Lisp_Object global_code; /* Syntax code of current char. */ + Lisp_Object current_syntax_table; /* Syntax table for current pos. */ + Lisp_Object old_prop; /* Syntax-table prop at prev pos. */ + ptrdiff_t b_property; /* First index where c_s_t is valid. */ ptrdiff_t e_property; /* First index where c_s_t is - not valid. */ - INTERVAL forward_i; /* Where to start lookup on forward */ + not valid. */ + bool e_property_truncated; /* true if e_property if was truncated + by parse_sexp_propertize_done. */ + INTERVAL forward_i; /* Where to start lookup on forward. */ INTERVAL backward_i; /* or backward movement. The data in c_s_t is valid between these intervals, and possibly at the intervals too, depending - on: */ + on: */ /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */ ptrdiff_t offset; }; @@ -86,35 +92,49 @@ struct gl_state_s extern struct gl_state_s gl_state; /* Fetch the information from the entry for character C - in syntax table TABLE, or from globally kept data (gl_state). + in the current buffer's syntax table, + or (if VIA_PROPERTY) from globally kept data (gl_state). Does inheritance. */ -SYNTAX_INLINE Lisp_Object -SYNTAX_ENTRY (int c) +INLINE Lisp_Object +syntax_property_entry (int c, bool via_property) { -#ifdef SYNTAX_ENTRY_VIA_PROPERTY - return (gl_state.use_global - ? gl_state.global_code - : CHAR_TABLE_REF (gl_state.current_syntax_table, c)); -#else + if (via_property) + return (gl_state.use_global + ? gl_state.global_code + : CHAR_TABLE_REF (gl_state.current_syntax_table, c)); return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c); -#endif +} +INLINE Lisp_Object +SYNTAX_ENTRY (int c) +{ + return syntax_property_entry (c, false); } /* Extract the information from the entry for character C in the current syntax table. */ -SYNTAX_INLINE int -SYNTAX_WITH_FLAGS (int c) +INLINE int +syntax_property_with_flags (int c, bool via_property) { - Lisp_Object ent = SYNTAX_ENTRY (c); + Lisp_Object ent = syntax_property_entry (c, via_property); return CONSP (ent) ? XINT (XCAR (ent)) : Swhitespace; } +INLINE int +SYNTAX_WITH_FLAGS (int c) +{ + return syntax_property_with_flags (c, false); +} -SYNTAX_INLINE enum syntaxcode +INLINE enum syntaxcode +syntax_property (int c, bool via_property) +{ + return syntax_property_with_flags (c, via_property) & 0xff; +} +INLINE enum syntaxcode SYNTAX (int c) { - return SYNTAX_WITH_FLAGS (c) & 0xff; + return syntax_property (c, false); } @@ -135,9 +155,10 @@ extern char const syntax_code_spec[16]; for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. The value is meant for use in code that does nothing when - parse_sexp_lookup_properties is 0, so return 0 in that case, for speed. */ + parse_sexp_lookup_properties is false, so return 0 in that case, + for speed. */ -SYNTAX_INLINE ptrdiff_t +INLINE ptrdiff_t SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos) { return (! parse_sexp_lookup_properties @@ -157,26 +178,27 @@ SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos) /* Make syntax table state (gl_state) good for CHARPOS, assuming it is currently good for a position before CHARPOS. */ -SYNTAX_INLINE void +INLINE void UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos) -{ +{ /* Performs just-in-time syntax-propertization. */ if (parse_sexp_lookup_properties && charpos >= gl_state.e_property) - update_syntax_table (charpos + gl_state.offset, 1, 0, gl_state.object); + update_syntax_table_forward (charpos + gl_state.offset, + false, gl_state.object); } /* Make syntax table state (gl_state) good for CHARPOS, assuming it is currently good for a position after CHARPOS. */ -SYNTAX_INLINE void +INLINE void UPDATE_SYNTAX_TABLE_BACKWARD (ptrdiff_t charpos) { if (parse_sexp_lookup_properties && charpos < gl_state.b_property) - update_syntax_table (charpos + gl_state.offset, -1, 0, gl_state.object); + update_syntax_table (charpos + gl_state.offset, -1, false, gl_state.object); } /* Make syntax table good for CHARPOS. */ -SYNTAX_INLINE void +INLINE void UPDATE_SYNTAX_TABLE (ptrdiff_t charpos) { UPDATE_SYNTAX_TABLE_BACKWARD (charpos); @@ -185,10 +207,11 @@ UPDATE_SYNTAX_TABLE (ptrdiff_t charpos) /* Set up the buffer-global syntax table. */ -SYNTAX_INLINE void +INLINE void SETUP_BUFFER_SYNTAX_TABLE (void) { - gl_state.use_global = 0; + gl_state.use_global = false; + gl_state.e_property_truncated = false; gl_state.current_syntax_table = BVAR (current_buffer, syntax_table); } @@ -196,3 +219,5 @@ extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT); extern void SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object, ptrdiff_t, ptrdiff_t); INLINE_HEADER_END + +#endif /* EMACS_SYNTAX_H */ |
