diff options
| author | Richard M. Stallman | 2002-06-21 10:01:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-06-21 10:01:58 +0000 |
| commit | 6cbdd38befb162339ca946e07b2484f6433af3d3 (patch) | |
| tree | dfefb96ad71e43672c1d19393745b9c10c8ec250 | |
| parent | 857356cb69a141666acba0741efea67dc84268ea (diff) | |
| download | emacs-6cbdd38befb162339ca946e07b2484f6433af3d3.tar.gz emacs-6cbdd38befb162339ca946e07b2484f6433af3d3.zip | |
(Parsing Expressions): Give definition of sexp in terms of syntax classes.
Clarify other text in same node.
| -rw-r--r-- | lispref/syntax.texi | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/lispref/syntax.texi b/lispref/syntax.texi index bc3ac9c36bb..0d7c1cd0364 100644 --- a/lispref/syntax.texi +++ b/lispref/syntax.texi | |||
| @@ -594,35 +594,39 @@ expression prefix syntax class, and characters with the @samp{p} flag. | |||
| 594 | @section Parsing Balanced Expressions | 594 | @section Parsing Balanced Expressions |
| 595 | 595 | ||
| 596 | Here are several functions for parsing and scanning balanced | 596 | Here are several functions for parsing and scanning balanced |
| 597 | expressions, also known as @dfn{sexps}, in which parentheses match in | 597 | expressions, also known as @dfn{sexps}. Basically, a sexp is either a |
| 598 | pairs. The syntax table controls the interpretation of characters, so | 598 | balanced parenthetical grouping, or a symbol name (a sequence of |
| 599 | these functions can be used for Lisp expressions when in Lisp mode and | 599 | characters whose syntax is either word constituent or symbol |
| 600 | for C expressions when in C mode. @xref{List Motion}, for convenient | 600 | constituent). However, characters whose syntax is expression prefix |
| 601 | are treated as part of the sexp if they appear next to it. | ||
| 602 | |||
| 603 | The syntax table controls the interpretation of characters, so these | ||
| 604 | functions can be used for Lisp expressions when in Lisp mode and for C | ||
| 605 | expressions when in C mode. @xref{List Motion}, for convenient | ||
| 601 | higher-level functions for moving over balanced expressions. | 606 | higher-level functions for moving over balanced expressions. |
| 602 | 607 | ||
| 603 | A syntax table only describes how each character changes the state of | 608 | A syntax table only describes how each character changes the state |
| 604 | the parser, rather than describing the state itself. For example, a string | 609 | of the parser, rather than describing the state itself. For example, |
| 605 | delimiter character toggles the parser state between ``in-string'' and | 610 | a string delimiter character toggles the parser state between |
| 606 | ``in-code'' but the characters inside the string do not have any particular | 611 | ``in-string'' and ``in-code'' but the characters inside the string do |
| 607 | syntax to identify them as such. | 612 | not have any particular syntax to identify them as such. For example |
| 608 | 613 | (note that 15 is the syntax code for generic string delimiters), | |
| 609 | For example (note: 15 is the syntax-code of generic string delimiters): | ||
| 610 | 614 | ||
| 611 | @example | 615 | @example |
| 612 | (put-text-property 1 9 'syntax-table '(15 . nil)) | 616 | (put-text-property 1 9 'syntax-table '(15 . nil)) |
| 613 | @end example | 617 | @end example |
| 614 | 618 | ||
| 619 | @noindent | ||
| 615 | does not tell Emacs that the first eight chars of the current buffer | 620 | does not tell Emacs that the first eight chars of the current buffer |
| 616 | are a string, but rather that they are all string delimiters and thus | 621 | are a string, but rather that they are all string delimiters. As a |
| 617 | Emacs should treat them as four adjacent empty strings. | 622 | result, Emacs treats them as four consecutive empty string constants. |
| 618 | 623 | ||
| 619 | The state of the parser is transient (i.e. not stored in the buffer for | 624 | Every time you use the parser, you specify it a starting state as |
| 620 | example). Instead, every time the parser is used, it is given not just | 625 | well as a starting position. If you omit the starting state, the |
| 621 | a starting position but a starting state. If the starting state is not | 626 | default is ``top level in parenthesis structure,'' as it would be at |
| 622 | specified explicitly, Emacs assumes we are at the top level of parenthesis | 627 | the beginning of a function definition. (This is the case for |
| 623 | structure, such as the beginning of a function definition (this is the case | 628 | @code{forward-sexp}, which blindly assumes that the starting point is |
| 624 | for @code{forward-sexp} which blindly assumes that the starting point is in | 629 | in such a state.) |
| 625 | such a state.) | ||
| 626 | 630 | ||
| 627 | @defun parse-partial-sexp start limit &optional target-depth stop-before state stop-comment | 631 | @defun parse-partial-sexp start limit &optional target-depth stop-before state stop-comment |
| 628 | This function parses a sexp in the current buffer starting at | 632 | This function parses a sexp in the current buffer starting at |