mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 10:43:02 +00:00
doc: formatting changes
* doc/bison.texi: Wrap lines. No semantical difference.
This commit is contained in:
@@ -7042,21 +7042,20 @@ Bison}.
|
|||||||
@node Calling Convention
|
@node Calling Convention
|
||||||
@subsection Calling Convention for @code{yylex}
|
@subsection Calling Convention for @code{yylex}
|
||||||
|
|
||||||
The value that @code{yylex} returns must be the positive numeric code
|
The value that @code{yylex} returns must be the positive numeric code for
|
||||||
for the type of token it has just found; a zero or negative value
|
the type of token it has just found; a zero or negative value signifies
|
||||||
signifies end-of-input.
|
end-of-input.
|
||||||
|
|
||||||
When a token is referred to in the grammar rules by a name, that name
|
When a token is referred to in the grammar rules by a name, that name in the
|
||||||
in the parser implementation file becomes a C macro whose definition
|
parser implementation file becomes a C macro whose definition is the proper
|
||||||
is the proper numeric code for that token type. So @code{yylex} can
|
numeric code for that token type. So @code{yylex} can use the name to
|
||||||
use the name to indicate that type. @xref{Symbols}.
|
indicate that type. @xref{Symbols}.
|
||||||
|
|
||||||
When a token is referred to in the grammar rules by a character literal,
|
When a token is referred to in the grammar rules by a character literal, the
|
||||||
the numeric code for that character is also the code for the token type.
|
numeric code for that character is also the code for the token type. So
|
||||||
So @code{yylex} can simply return that character code, possibly converted
|
@code{yylex} can simply return that character code, possibly converted to
|
||||||
to @code{unsigned char} to avoid sign-extension. The null character
|
@code{unsigned char} to avoid sign-extension. The null character must not
|
||||||
must not be used this way, because its code is zero and that
|
be used this way, because its code is zero and that signifies end-of-input.
|
||||||
signifies end-of-input.
|
|
||||||
|
|
||||||
Here is an example showing these things:
|
Here is an example showing these things:
|
||||||
|
|
||||||
@@ -7091,17 +7090,16 @@ all others. In this case, the use of the literal string tokens in
|
|||||||
the grammar file has no effect on @code{yylex}.
|
the grammar file has no effect on @code{yylex}.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
@code{yylex} can find the multicharacter token in the @code{yytname}
|
@code{yylex} can find the multicharacter token in the @code{yytname} table.
|
||||||
table. The index of the token in the table is the token type's code.
|
The index of the token in the table is the token type's code. The name of a
|
||||||
The name of a multicharacter token is recorded in @code{yytname} with a
|
multicharacter token is recorded in @code{yytname} with a double-quote, the
|
||||||
double-quote, the token's characters, and another double-quote. The
|
token's characters, and another double-quote. The token's characters are
|
||||||
token's characters are escaped as necessary to be suitable as input
|
escaped as necessary to be suitable as input to Bison.
|
||||||
to Bison.
|
|
||||||
|
|
||||||
Here's code for looking up a multicharacter token in @code{yytname},
|
Here's code for looking up a multicharacter token in @code{yytname},
|
||||||
assuming that the characters of the token are stored in
|
assuming that the characters of the token are stored in @code{token_buffer},
|
||||||
@code{token_buffer}, and assuming that the token does not contain any
|
and assuming that the token does not contain any characters like @samp{"}
|
||||||
characters like @samp{"} that require escaping.
|
that require escaping.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
for (int i = 0; i < YYNTOKENS; i++)
|
for (int i = 0; i < YYNTOKENS; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user