comparison src/syntax.c @ 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 1f0dc0251be3
children ac339ec4a12a
comparison
equal deleted inserted replaced
22393:e60f71fe8aed 22394:5e1f0caf1873
62 int thislevelstart; /* Char number of most recent start-of-expression at current level */ 62 int thislevelstart; /* Char number of most recent start-of-expression at current level */
63 int prevlevelstart; /* Char number of start of containing expression */ 63 int prevlevelstart; /* Char number of start of containing expression */
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.
70 find_start_pos is the place for which the defun start was found. 72 find_start_pos is the place for which the defun start was found.
71 find_start_value is the defun start position found for it. 73 find_start_value is the defun start position found for it.
2359 ? ST_COMMENT_STYLE : 1 ); 2361 ? ST_COMMENT_STYLE : 1 );
2360 2362
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;
2367 2381
2368 curlevel->prev = -1; 2382 curlevel->prev = -1;
2594 state.mindepth = mindepth; 2608 state.mindepth = mindepth;
2595 state.thislevelstart = curlevel->prev; 2609 state.thislevelstart = curlevel->prev;
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;
2602 } 2620 }
2603 2621
2609 "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\ 2627 "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\
2610 Parsing stops at TO or when certain criteria are met;\n\ 2628 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\
2618 3. non-nil if inside a string.\n\ 2636 3. non-nil if inside a string.\n\
2619 (it is the character that will terminate the string,\n\ 2637 (it is the character that will terminate the string,\n\
2622 5. t if following a quote character.\n\ 2640 5. t if following a quote character.\n\
2623 6. the minimum paren-depth encountered during this scan.\n\ 2641 6. the minimum paren-depth encountered during this scan.\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\
2630 any character that starts a sexp.\n\ 2649 any character that starts a sexp.\n\
2631 Fifth arg STATE is a nine-element list like what this function returns.\n\ 2650 Fifth arg STATE is a nine-element list like what this function returns.\n\
2676 ? Qsyntax_table : Qt) : 2695 ? Qsyntax_table : Qt) :
2677 Qnil), 2696 Qnil),
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
2685 init_syntax_once () 2704 init_syntax_once ()
2686 { 2705 {