diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/parser-state.html | |
new repository
Diffstat (limited to 'devdocs/elisp/parser-state.html')
| -rw-r--r-- | devdocs/elisp/parser-state.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/devdocs/elisp/parser-state.html b/devdocs/elisp/parser-state.html new file mode 100644 index 00000000..4739fe52 --- /dev/null +++ b/devdocs/elisp/parser-state.html @@ -0,0 +1,23 @@ + <h4 class="subsection">Parser State</h4> <p>A <em>parser state</em> 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 using <code>parse-partial-sexp</code> (see <a href="low_002dlevel-parsing">Low-Level Parsing</a>). Parsing functions such as <code>syntax-ppss</code> (see <a href="position-parse">Position Parse</a>) also return a parser state as the value. <code>parse-partial-sexp</code> can accept a parser state as an argument, for resuming parsing. </p> <p>Here are the meanings of the elements of the parser state: </p> <ol start="0"> <li> The depth in parentheses, counting from 0. <strong>Warning:</strong> this can be negative if there are more close parens than open parens between the parser’s starting point and end point. </li> +<li> The character position of the start of the innermost parenthetical grouping containing the stopping point; <code>nil</code> if none. </li> +<li> The character position of the start of the last complete subexpression terminated; <code>nil</code> if none. </li> +<li> Non-<code>nil</code> if inside a string. More precisely, this is the character that will terminate the string, or <code>t</code> if a generic string delimiter character should terminate it. </li> +<li> <code>t</code> if inside a non-nestable comment (of any comment style; see <a href="syntax-flags">Syntax Flags</a>); or the comment nesting level if inside a comment that can be nested. </li> +<li> <code>t</code> if the end point is just after a quote character. </li> +<li> The minimum parenthesis depth encountered during this scan. </li> +<li> What kind of comment is active: <code>nil</code> if not in a comment or in a comment of style ‘<samp>a</samp>’; 1 for a comment of style ‘<samp>b</samp>’; 2 for a comment of style ‘<samp>c</samp>’; and <code>syntax-table</code> for a comment that should be ended by a generic comment delimiter character. </li> +<li> The string or comment start position. While inside a comment, this is the position where the comment began; while inside a string, this is the position where the string began. When outside of strings and comments, this element is <code>nil</code>. </li> +<li> The list of the positions of the currently open parentheses, starting with the outermost. </li> +<li> 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</var> (see <a href="syntax-table-internals">Syntax Table Internals</a>) of that position. Otherwise <code>nil</code>. </li> +</ol> <p>Elements 1, 2, and 6 are ignored in a state which you pass as an argument to <code>parse-partial-sexp</code> to continue parsing. Elements 9 and 10 are mainly used internally by the parser code. </p> <p>Some additional useful information is available from a parser state using these functions: </p> <dl> <dt id="syntax-ppss-toplevel-pos">Function: <strong>syntax-ppss-toplevel-pos</strong> <em>state</em> +</dt> <dd> +<p>This function extracts, from parser state <var>state</var>, the last position scanned in the parse which was at top level in grammatical structure. “At top level” means outside of any parentheses, comments, or strings. </p> <p>The value is <code>nil</code> if <var>state</var> represents a parse which has arrived at a top level position. </p> +</dd> +</dl> <dl> <dt id="syntax-ppss-context">Function: <strong>syntax-ppss-context</strong> <em>state</em> +</dt> <dd><p>Return <code>string</code> if the end position of the scan returning <var>state</var> is in a string, and <code>comment</code> if it’s in a comment. Otherwise return <code>nil</code>. </p></dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Parser-State.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Parser-State.html</a> + </p> +</div> |
