diff options
| author | Alan Mackenzie | 2016-03-20 13:19:48 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2016-03-20 13:19:48 +0000 |
| commit | 9dcf5998935c8aaa846d7585b81f0dcfe1935b3d (patch) | |
| tree | 371e627342a753acc111fa1c774cef559407e18f /doc/lispref | |
| parent | 565df7265dd73b4812fcb02cd1663fce4dc40be7 (diff) | |
| download | emacs-9dcf5998935c8aaa846d7585b81f0dcfe1935b3d.tar.gz emacs-9dcf5998935c8aaa846d7585b81f0dcfe1935b3d.zip | |
Amend parse-partial-sexp correctly to handle two character comment delimiters
Do this by adding a new field to the parser state: the syntax of the last
character scanned, should that be the first char of a (potential) two char
construct, nil otherwise.
This should make the parser state complete.
Also document element 9 of the parser state. Also refactor the code a bit.
* src/syntax.c (struct lisp_parse_state): Add a new field.
(SYNTAX_FLAGS_COMSTARTEND_FIRST): New function.
(internalize_parse_state): New function, extracted from scan_sexps_forward.
(back_comment): Call internalize_parse_state.
(forw_comment): Return the syntax of the last character scanned to the caller
when that character might be the first of a two character construct.
(Fforward_comment, scan_lists): New dummy variables, passed to forw_comment.
(scan_sexps_forward): Remove a redundant state parameter. Access all `state'
information via the address parameter `state'. Remove the code which converts
from external to internal form of `state'. Access buffer contents only from
`from' onwards. Reformulate code at the top of the main loop correctly to
recognize comment openers when starting in the middle of one. Call
forw_comment with extra argument (for return of syntax value of possible first
char of a two char construct).
(Fparse_partial_sexp): Document elements 9, 10 of the parser state in the
doc string. Clarify the doc string in general. Call
internalize_parse_state. Take account of the new elements when consing up the
output parser state.
* doc/lispref/syntax.texi: (Parser State): Document element 9 and the new
element 10. Minor wording corrections (remove reference to "trivial
cases").
(Low Level Parsing): Minor corrections.
* etc/NEWS: Note new element 10, and documentation of element 9 of parser
state.
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/syntax.texi | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi index d5a7eba13fe..f81c1643c21 100644 --- a/doc/lispref/syntax.texi +++ b/doc/lispref/syntax.texi | |||
| @@ -791,10 +791,10 @@ Hooks}). | |||
| 791 | @subsection Parser State | 791 | @subsection Parser State |
| 792 | @cindex parser state | 792 | @cindex parser state |
| 793 | 793 | ||
| 794 | A @dfn{parser state} is a list of ten elements describing the state | 794 | A @dfn{parser state} is a list of (currently) eleven elements |
| 795 | of the syntactic parser, after it parses the text between a specified | 795 | describing the state of the syntactic parser, after it parses the text |
| 796 | starting point and a specified end point in the buffer. Parsing | 796 | between a specified starting point and a specified end point in the |
| 797 | functions such as @code{syntax-ppss} | 797 | buffer. Parsing functions such as @code{syntax-ppss} |
| 798 | @ifnottex | 798 | @ifnottex |
| 799 | (@pxref{Position Parse}) | 799 | (@pxref{Position Parse}) |
| 800 | @end ifnottex | 800 | @end ifnottex |
| @@ -851,15 +851,20 @@ position where the string began. When outside of strings and comments, | |||
| 851 | this element is @code{nil}. | 851 | this element is @code{nil}. |
| 852 | 852 | ||
| 853 | @item | 853 | @item |
| 854 | Internal data for continuing the parsing. The meaning of this | 854 | The list of the positions of the currently open parentheses, starting |
| 855 | data is subject to change; it is used if you pass this list | 855 | with the outermost. |
| 856 | as the @var{state} argument to another call. | 856 | |
| 857 | @item | ||
| 858 | When the last buffer position scanned was the (potential) first | ||
| 859 | character of a two character construct (comment delimiter or | ||
| 860 | escaped/char-quoted character pair), the @var{syntax-code} | ||
| 861 | (@pxref{Syntax Table Internals}) of that position. Otherwise | ||
| 862 | @code{nil}. | ||
| 857 | @end enumerate | 863 | @end enumerate |
| 858 | 864 | ||
| 859 | Elements 1, 2, and 6 are ignored in a state which you pass as an | 865 | Elements 1, 2, and 6 are ignored in a state which you pass as an |
| 860 | argument to continue parsing, and elements 8 and 9 are used only in | 866 | argument to continue parsing. Elements 9 and 10 are mainly used |
| 861 | trivial cases. Those elements are mainly used internally by the | 867 | internally by the parser code. |
| 862 | parser code. | ||
| 863 | 868 | ||
| 864 | One additional piece of useful information is available from a | 869 | One additional piece of useful information is available from a |
| 865 | parser state using this function: | 870 | parser state using this function: |
| @@ -898,11 +903,11 @@ The depth starts at 0, or at whatever is given in @var{state}. | |||
| 898 | 903 | ||
| 899 | If the fourth argument @var{stop-before} is non-@code{nil}, parsing | 904 | If the fourth argument @var{stop-before} is non-@code{nil}, parsing |
| 900 | stops when it comes to any character that starts a sexp. If | 905 | stops when it comes to any character that starts a sexp. If |
| 901 | @var{stop-comment} is non-@code{nil}, parsing stops when it comes to the | 906 | @var{stop-comment} is non-@code{nil}, parsing stops after the start of |
| 902 | start of an unnested comment. If @var{stop-comment} is the symbol | 907 | an unnested comment. If @var{stop-comment} is the symbol |
| 903 | @code{syntax-table}, parsing stops after the start of an unnested | 908 | @code{syntax-table}, parsing stops after the start of an unnested |
| 904 | comment or a string, or the end of an unnested comment or a string, | 909 | comment or a string, or after the end of an unnested comment or a |
| 905 | whichever comes first. | 910 | string, whichever comes first. |
| 906 | 911 | ||
| 907 | If @var{state} is @code{nil}, @var{start} is assumed to be at the top | 912 | If @var{state} is @code{nil}, @var{start} is assumed to be at the top |
| 908 | level of parenthesis structure, such as the beginning of a function | 913 | level of parenthesis structure, such as the beginning of a function |