summaryrefslogtreecommitdiff
path: root/doc/lispref/syntax.texi
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2016-03-20 13:19:48 +0000
committerAlan Mackenzie <acm@muc.de>2016-03-20 13:19:48 +0000
commit9dcf5998935c8aaa846d7585b81f0dcfe1935b3d (patch)
tree371e627342a753acc111fa1c774cef559407e18f /doc/lispref/syntax.texi
parent565df7265dd73b4812fcb02cd1663fce4dc40be7 (diff)
downloademacs-9dcf5998935c8aaa846d7585b81f0dcfe1935b3d.tar.gz
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/syntax.texi')
-rw-r--r--doc/lispref/syntax.texi33
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}).
@subsection Parser State
@cindex parser state
- A @dfn{parser state} is a list of ten elements describing the state
-of the syntactic parser, after it parses the text between a specified
-starting point and a specified end point in the buffer. Parsing
-functions such as @code{syntax-ppss}
+ A @dfn{parser state} is a list of (currently) eleven elements
+describing the state of the syntactic parser, after it parses the text
+between a specified starting point and a specified end point in the
+buffer. Parsing functions such as @code{syntax-ppss}
@ifnottex
(@pxref{Position Parse})
@end ifnottex
@@ -851,15 +851,20 @@ position where the string began. When outside of strings and comments,
this element is @code{nil}.
@item
-Internal data for continuing the parsing. The meaning of this
-data is subject to change; it is used if you pass this list
-as the @var{state} argument to another call.
+The list of the positions of the currently open parentheses, starting
+with the outermost.
+
+@item
+When the last buffer position scanned was the (potential) first
+character of a two character construct (comment delimiter or
+escaped/char-quoted character pair), the @var{syntax-code}
+(@pxref{Syntax Table Internals}) of that position. Otherwise
+@code{nil}.
@end enumerate
Elements 1, 2, and 6 are ignored in a state which you pass as an
-argument to continue parsing, and elements 8 and 9 are used only in
-trivial cases. Those elements are mainly used internally by the
-parser code.
+argument to continue parsing. Elements 9 and 10 are mainly used
+internally by the parser code.
One additional piece of useful information is available from a
parser state using this function:
@@ -898,11 +903,11 @@ The depth starts at 0, or at whatever is given in @var{state}.
If the fourth argument @var{stop-before} is non-@code{nil}, parsing
stops when it comes to any character that starts a sexp. If
-@var{stop-comment} is non-@code{nil}, parsing stops when it comes to the
-start of an unnested comment. If @var{stop-comment} is the symbol
+@var{stop-comment} is non-@code{nil}, parsing stops after the start of
+an unnested comment. If @var{stop-comment} is the symbol
@code{syntax-table}, parsing stops after the start of an unnested
-comment or a string, or the end of an unnested comment or a string,
-whichever comes first.
+comment or a string, or after the end of an unnested comment or a
+string, whichever comes first.
If @var{state} is @code{nil}, @var{start} is assumed to be at the top
level of parenthesis structure, such as the beginning of a function