diff options
| author | Richard M. Stallman | 1998-06-08 04:29:46 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-06-08 04:29:46 +0000 |
| commit | 1a102a5863318e45e6fe51fac2fd848eb78f64e0 (patch) | |
| tree | bfcb7555c4a7a32262845f9bdca1bf30763cb743 /src/syntax.c | |
| parent | f7fc93d80596a99bb6f3a7a135882226c4808d40 (diff) | |
| download | emacs-1a102a5863318e45e6fe51fac2fd848eb78f64e0.tar.gz emacs-1a102a5863318e45e6fe51fac2fd848eb78f64e0.zip | |
(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.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/syntax.c b/src/syntax.c index efa4bf3d271..b2d14576839 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -64,6 +64,8 @@ struct lisp_parse_state | |||
| 64 | int location; /* Char number at which parsing stopped. */ | 64 | int location; /* Char number at which parsing stopped. */ |
| 65 | int mindepth; /* Minimum depth seen while scanning. */ | 65 | int mindepth; /* Minimum depth seen while scanning. */ |
| 66 | int comstr_start; /* Position just after last comment/string starter. */ | 66 | int comstr_start; /* Position just after last comment/string starter. */ |
| 67 | Lisp_Object levelstarts; /* Char numbers of starts-of-expression | ||
| 68 | of levels (starting from outermost). */ | ||
| 67 | }; | 69 | }; |
| 68 | 70 | ||
| 69 | /* These variables are a cache for finding the start of a defun. | 71 | /* These variables are a cache for finding the start of a defun. |
| @@ -2361,6 +2363,18 @@ do { prev_from = from; \ | |||
| 2361 | oldstate = Fcdr (oldstate); | 2363 | oldstate = Fcdr (oldstate); |
| 2362 | tem = Fcar (oldstate); | 2364 | tem = Fcar (oldstate); |
| 2363 | state.comstr_start = NILP (tem) ? -1 : XINT (tem) ; | 2365 | state.comstr_start = NILP (tem) ? -1 : XINT (tem) ; |
| 2366 | oldstate = Fcdr (oldstate); | ||
| 2367 | tem = Fcar (oldstate); | ||
| 2368 | while (!NILP (tem)) /* >= second enclosing sexps. */ | ||
| 2369 | { | ||
| 2370 | /* curlevel++->last ran into compiler bug on Apollo */ | ||
| 2371 | curlevel->last = XINT (Fcar (tem)); | ||
| 2372 | if (++curlevel == endlevel) | ||
| 2373 | error ("Nesting too deep for parser"); | ||
| 2374 | curlevel->prev = -1; | ||
| 2375 | curlevel->last = -1; | ||
| 2376 | tem = Fcdr (tem); | ||
| 2377 | } | ||
| 2364 | } | 2378 | } |
| 2365 | state.quoted = 0; | 2379 | state.quoted = 0; |
| 2366 | mindepth = depth; | 2380 | mindepth = depth; |
| @@ -2596,6 +2610,10 @@ do { prev_from = from; \ | |||
| 2596 | state.prevlevelstart | 2610 | state.prevlevelstart |
| 2597 | = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; | 2611 | = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; |
| 2598 | state.location = from; | 2612 | state.location = from; |
| 2613 | state.levelstarts = Qnil; | ||
| 2614 | while (--curlevel >= levelstart) | ||
| 2615 | state.levelstarts = Fcons (make_number (curlevel->last), | ||
| 2616 | state.levelstarts); | ||
| 2599 | immediate_quit = 0; | 2617 | immediate_quit = 0; |
| 2600 | 2618 | ||
| 2601 | *stateptr = state; | 2619 | *stateptr = state; |
| @@ -2611,7 +2629,7 @@ Parsing stops at TO or when certain criteria are met;\n\ | |||
| 2611 | point is set to where parsing stops.\n\ | 2629 | point is set to where parsing stops.\n\ |
| 2612 | If fifth arg STATE is omitted or nil,\n\ | 2630 | If fifth arg STATE is omitted or nil,\n\ |
| 2613 | parsing assumes that FROM is the beginning of a function.\n\ | 2631 | parsing assumes that FROM is the beginning of a function.\n\ |
| 2614 | Value is a list of nine elements describing final state of parsing:\n\ | 2632 | Value is a list of ten elements describing final state of parsing:\n\ |
| 2615 | 0. depth in parens.\n\ | 2633 | 0. depth in parens.\n\ |
| 2616 | 1. character address of start of innermost containing list; nil if none.\n\ | 2634 | 1. character address of start of innermost containing list; nil if none.\n\ |
| 2617 | 2. character address of start of last complete sexp terminated.\n\ | 2635 | 2. character address of start of last complete sexp terminated.\n\ |
| @@ -2624,6 +2642,7 @@ Value is a list of nine elements describing final state of parsing:\n\ | |||
| 2624 | 7. t if in a comment of style b; `syntax-table' if the comment\n\ | 2642 | 7. t if in a comment of style b; `syntax-table' if the comment\n\ |
| 2625 | should be terminated by a generic comment delimiter.\n\ | 2643 | should be terminated by a generic comment delimiter.\n\ |
| 2626 | 8. character address of start of comment or string; nil if not in one.\n\ | 2644 | 8. character address of start of comment or string; nil if not in one.\n\ |
| 2645 | 9. Intermediate data for continuation of parsing (subject to change).\n\ | ||
| 2627 | If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\ | 2646 | If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\ |
| 2628 | in parentheses becomes equal to TARGETDEPTH.\n\ | 2647 | in parentheses becomes equal to TARGETDEPTH.\n\ |
| 2629 | Fourth arg STOPBEFORE non-nil means stop when come to\n\ | 2648 | Fourth arg STOPBEFORE non-nil means stop when come to\n\ |
| @@ -2678,7 +2697,7 @@ DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0, | |||
| 2678 | Fcons ((state.incomment || state.instring | 2697 | Fcons ((state.incomment || state.instring |
| 2679 | ? make_number (state.comstr_start) | 2698 | ? make_number (state.comstr_start) |
| 2680 | : Qnil), | 2699 | : Qnil), |
| 2681 | Qnil))))))))); | 2700 | Fcons (state.levelstarts, Qnil)))))))))); |
| 2682 | } | 2701 | } |
| 2683 | 2702 | ||
| 2684 | void | 2703 | void |