changeset 22394:5e1f0caf1873

(struct lisp_parse_state): New field, levelstarts. (scan_sexps_forward): Use 10th elt of STATE to set levelstarts. (parse-partial-sexp): Add 10th elt to return value.
author Richard M. Stallman <rms@gnu.org>
date Mon, 08 Jun 1998 04:29:46 +0000
parents e60f71fe8aed
children 4f8f06912912
files src/syntax.c
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/syntax.c	Mon Jun 08 02:09:03 1998 +0000
+++ b/src/syntax.c	Mon Jun 08 04:29:46 1998 +0000
@@ -64,6 +64,8 @@
     int location;	/* Char number at which parsing stopped.  */
     int mindepth;	/* Minimum depth seen while scanning.  */
     int comstr_start;	/* Position just after last comment/string starter.  */
+    Lisp_Object levelstarts;	/* Char numbers of starts-of-expression
+				   of levels (starting from outermost).  */
   };
 
 /* These variables are a cache for finding the start of a defun.
@@ -2361,6 +2363,18 @@
       oldstate = Fcdr (oldstate);
       tem = Fcar (oldstate);
       state.comstr_start = NILP (tem) ? -1 : XINT (tem) ;
+      oldstate = Fcdr (oldstate);
+      tem = Fcar (oldstate);
+      while (!NILP (tem))		/* >= second enclosing sexps.  */
+	{
+	  /* curlevel++->last ran into compiler bug on Apollo */
+	  curlevel->last = XINT (Fcar (tem));
+	  if (++curlevel == endlevel)
+	    error ("Nesting too deep for parser");
+	  curlevel->prev = -1;
+	  curlevel->last = -1;
+	  tem = Fcdr (tem);
+	}
     }
   state.quoted = 0;
   mindepth = depth;
@@ -2596,6 +2610,10 @@
   state.prevlevelstart
     = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
   state.location = from;
+  state.levelstarts = Qnil;
+  while (--curlevel >= levelstart)
+      state.levelstarts = Fcons (make_number (curlevel->last),
+				 state.levelstarts);
   immediate_quit = 0;
 
   *stateptr = state;
@@ -2611,7 +2629,7 @@
  point is set to where parsing stops.\n\
 If fifth arg STATE is omitted or nil,\n\
  parsing assumes that FROM is the beginning of a function.\n\
-Value is a list of nine elements describing final state of parsing:\n\
+Value is a list of ten elements describing final state of parsing:\n\
  0. depth in parens.\n\
  1. character address of start of innermost containing list; nil if none.\n\
  2. character address of start of last complete sexp terminated.\n\
@@ -2624,6 +2642,7 @@
  7. t if in a comment of style b; `syntax-table' if the comment\n\
     should be terminated by a generic comment delimiter.\n\
  8. character address of start of comment or string; nil if not in one.\n\
+ 9. Intermediate data for continuation of parsing (subject to change).\n\
 If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\
 in parentheses becomes equal to TARGETDEPTH.\n\
 Fourth arg STOPBEFORE non-nil means stop when come to\n\
@@ -2678,7 +2697,7 @@
 			      Fcons ((state.incomment || state.instring
 				      ? make_number (state.comstr_start)
 				      : Qnil),
-				     Qnil)))))))));
+				     Fcons (state.levelstarts, Qnil))))))))));
 }
 
 void