aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-06-21 10:01:58 +0000
committerRichard M. Stallman2002-06-21 10:01:58 +0000
commit6cbdd38befb162339ca946e07b2484f6433af3d3 (patch)
treedfefb96ad71e43672c1d19393745b9c10c8ec250
parent857356cb69a141666acba0741efea67dc84268ea (diff)
downloademacs-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.texi46
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
597expressions, also known as @dfn{sexps}, in which parentheses match in 597expressions, also known as @dfn{sexps}. Basically, a sexp is either a
598pairs. The syntax table controls the interpretation of characters, so 598balanced parenthetical grouping, or a symbol name (a sequence of
599these functions can be used for Lisp expressions when in Lisp mode and 599characters whose syntax is either word constituent or symbol
600for C expressions when in C mode. @xref{List Motion}, for convenient 600constituent). However, characters whose syntax is expression prefix
601are treated as part of the sexp if they appear next to it.
602
603 The syntax table controls the interpretation of characters, so these
604functions can be used for Lisp expressions when in Lisp mode and for C
605expressions when in C mode. @xref{List Motion}, for convenient
601higher-level functions for moving over balanced expressions. 606higher-level functions for moving over balanced expressions.
602 607
603A syntax table only describes how each character changes the state of 608 A syntax table only describes how each character changes the state
604the parser, rather than describing the state itself. For example, a string 609of the parser, rather than describing the state itself. For example,
605delimiter character toggles the parser state between ``in-string'' and 610a 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
607syntax to identify them as such. 612not have any particular syntax to identify them as such. For example
608 613(note that 15 is the syntax code for generic string delimiters),
609For 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
615does not tell Emacs that the first eight chars of the current buffer 620does not tell Emacs that the first eight chars of the current buffer
616are a string, but rather that they are all string delimiters and thus 621are a string, but rather that they are all string delimiters. As a
617Emacs should treat them as four adjacent empty strings. 622result, Emacs treats them as four consecutive empty string constants.
618 623
619The 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
620example). Instead, every time the parser is used, it is given not just 625well as a starting position. If you omit the starting state, the
621a starting position but a starting state. If the starting state is not 626default is ``top level in parenthesis structure,'' as it would be at
622specified explicitly, Emacs assumes we are at the top level of parenthesis 627the beginning of a function definition. (This is the case for
623structure, such as the beginning of a function definition (this is the case 628@code{forward-sexp}, which blindly assumes that the starting point is
624for @code{forward-sexp} which blindly assumes that the starting point is in 629in such a state.)
625such 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
628This function parses a sexp in the current buffer starting at 632This function parses a sexp in the current buffer starting at