]> git.saurik.com Git - bison.git/blob - doc/bison.info-5
alloca.c, alloca.h and allocate.c are really to be removed.
[bison.git] / doc / bison.info-5
1 Ceci est le fichier Info bison.info, produit par Makeinfo version 4.0b
2 à partir bison.texinfo.
3
4 START-INFO-DIR-ENTRY
5 * bison: (bison). GNU Project parser generator (yacc replacement).
6 END-INFO-DIR-ENTRY
7
8 This file documents the Bison parser generator.
9
10 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, 1999,
11 2000 Free Software Foundation, Inc.
12
13 Permission is granted to make and distribute verbatim copies of this
14 manual provided the copyright notice and this permission notice are
15 preserved on all copies.
16
17 Permission is granted to copy and distribute modified versions of
18 this manual under the conditions for verbatim copying, provided also
19 that the sections entitled "GNU General Public License" and "Conditions
20 for Using Bison" are included exactly as in the original, and provided
21 that the entire resulting derived work is distributed under the terms
22 of a permission notice identical to this one.
23
24 Permission is granted to copy and distribute translations of this
25 manual into another language, under the above conditions for modified
26 versions, except that the sections entitled "GNU General Public
27 License", "Conditions for Using Bison" and this permission notice may be
28 included in translations approved by the Free Software Foundation
29 instead of in the original English.
30
31 \1f
32 File: bison.info, Node: Table of Symbols, Next: Glossary, Prev: Invocation, Up: Top
33
34 Bison Symbols
35 *************
36
37 `error'
38 A token name reserved for error recovery. This token may be used
39 in grammar rules so as to allow the Bison parser to recognize an
40 error in the grammar without halting the process. In effect, a
41 sentence containing an error may be recognized as valid. On a
42 parse error, the token `error' becomes the current look-ahead
43 token. Actions corresponding to `error' are then executed, and
44 the look-ahead token is reset to the token that originally caused
45 the violation. *Note Error Recovery::.
46
47 `YYABORT'
48 Macro to pretend that an unrecoverable syntax error has occurred,
49 by making `yyparse' return 1 immediately. The error reporting
50 function `yyerror' is not called. *Note The Parser Function
51 `yyparse': Parser Function.
52
53 `YYACCEPT'
54 Macro to pretend that a complete utterance of the language has been
55 read, by making `yyparse' return 0 immediately. *Note The Parser
56 Function `yyparse': Parser Function.
57
58 `YYBACKUP'
59 Macro to discard a value from the parser stack and fake a
60 look-ahead token. *Note Special Features for Use in Actions:
61 Action Features.
62
63 `YYERROR'
64 Macro to pretend that a syntax error has just been detected: call
65 `yyerror' and then perform normal error recovery if possible
66 (*note Error Recovery::), or (if recovery is impossible) make
67 `yyparse' return 1. *Note Error Recovery::.
68
69 `YYERROR_VERBOSE'
70 Macro that you define with `#define' in the Bison declarations
71 section to request verbose, specific error message strings when
72 `yyerror' is called.
73
74 `YYINITDEPTH'
75 Macro for specifying the initial size of the parser stack. *Note
76 Stack Overflow::.
77
78 `YYLEX_PARAM'
79 Macro for specifying an extra argument (or list of extra
80 arguments) for `yyparse' to pass to `yylex'. *Note Calling
81 Conventions for Pure Parsers: Pure Calling.
82
83 `YYLTYPE'
84 Macro for the data type of `yylloc'; a structure with four
85 members. *Note Data Types of Locations: Location Type.
86
87 `yyltype'
88 Default value for YYLTYPE.
89
90 `YYMAXDEPTH'
91 Macro for specifying the maximum size of the parser stack. *Note
92 Stack Overflow::.
93
94 `YYPARSE_PARAM'
95 Macro for specifying the name of a parameter that `yyparse' should
96 accept. *Note Calling Conventions for Pure Parsers: Pure Calling.
97
98 `YYRECOVERING'
99 Macro whose value indicates whether the parser is recovering from a
100 syntax error. *Note Special Features for Use in Actions: Action
101 Features.
102
103 `YYSTYPE'
104 Macro for the data type of semantic values; `int' by default.
105 *Note Data Types of Semantic Values: Value Type.
106
107 `yychar'
108 External integer variable that contains the integer value of the
109 current look-ahead token. (In a pure parser, it is a local
110 variable within `yyparse'.) Error-recovery rule actions may
111 examine this variable. *Note Special Features for Use in Actions:
112 Action Features.
113
114 `yyclearin'
115 Macro used in error-recovery rule actions. It clears the previous
116 look-ahead token. *Note Error Recovery::.
117
118 `yydebug'
119 External integer variable set to zero by default. If `yydebug' is
120 given a nonzero value, the parser will output information on input
121 symbols and parser action. *Note Debugging Your Parser: Debugging.
122
123 `yyerrok'
124 Macro to cause parser to recover immediately to its normal mode
125 after a parse error. *Note Error Recovery::.
126
127 `yyerror'
128 User-supplied function to be called by `yyparse' on error. The
129 function receives one argument, a pointer to a character string
130 containing an error message. *Note The Error Reporting Function
131 `yyerror': Error Reporting.
132
133 `yylex'
134 User-supplied lexical analyzer function, called with no arguments
135 to get the next token. *Note The Lexical Analyzer Function
136 `yylex': Lexical.
137
138 `yylval'
139 External variable in which `yylex' should place the semantic value
140 associated with a token. (In a pure parser, it is a local
141 variable within `yyparse', and its address is passed to `yylex'.)
142 *Note Semantic Values of Tokens: Token Values.
143
144 `yylloc'
145 External variable in which `yylex' should place the line and column
146 numbers associated with a token. (In a pure parser, it is a local
147 variable within `yyparse', and its address is passed to `yylex'.)
148 You can ignore this variable if you don't use the `@' feature in
149 the grammar actions. *Note Textual Positions of Tokens: Token
150 Positions.
151
152 `yynerrs'
153 Global variable which Bison increments each time there is a parse
154 error. (In a pure parser, it is a local variable within
155 `yyparse'.) *Note The Error Reporting Function `yyerror': Error
156 Reporting.
157
158 `yyparse'
159 The parser function produced by Bison; call this function to start
160 parsing. *Note The Parser Function `yyparse': Parser Function.
161
162 `%debug'
163 Equip the parser for debugging. *Note Decl Summary::.
164
165 `%defines'
166 Bison declaration to create a header file meant for the scanner.
167 *Note Decl Summary::.
168
169 `%left'
170 Bison declaration to assign left associativity to token(s). *Note
171 Operator Precedence: Precedence Decl.
172
173 `%no_lines'
174 Bison declaration to avoid generating `#line' directives in the
175 parser file. *Note Decl Summary::.
176
177 `%nonassoc'
178 Bison declaration to assign non-associativity to token(s). *Note
179 Operator Precedence: Precedence Decl.
180
181 `%prec'
182 Bison declaration to assign a precedence to a specific rule.
183 *Note Context-Dependent Precedence: Contextual Precedence.
184
185 `%pure_parser'
186 Bison declaration to request a pure (reentrant) parser. *Note A
187 Pure (Reentrant) Parser: Pure Decl.
188
189 `%right'
190 Bison declaration to assign right associativity to token(s).
191 *Note Operator Precedence: Precedence Decl.
192
193 `%start'
194 Bison declaration to specify the start symbol. *Note The
195 Start-Symbol: Start Decl.
196
197 `%token'
198 Bison declaration to declare token(s) without specifying
199 precedence. *Note Token Type Names: Token Decl.
200
201 `%token_table'
202 Bison declaration to include a token name table in the parser file.
203 *Note Decl Summary::.
204
205 `%type'
206 Bison declaration to declare nonterminals. *Note Nonterminal
207 Symbols: Type Decl.
208
209 `%union'
210 Bison declaration to specify several possible data types for
211 semantic values. *Note The Collection of Value Types: Union Decl.
212
213 These are the punctuation and delimiters used in Bison input:
214
215 `%%'
216 Delimiter used to separate the grammar rule section from the Bison
217 declarations section or the additional C code section. *Note The
218 Overall Layout of a Bison Grammar: Grammar Layout.
219
220 `%{ %}'
221 All code listed between `%{' and `%}' is copied directly to the
222 output file uninterpreted. Such code forms the "C declarations"
223 section of the input file. *Note Outline of a Bison Grammar:
224 Grammar Outline.
225
226 `/*...*/'
227 Comment delimiters, as in C.
228
229 `:'
230 Separates a rule's result from its components. *Note Syntax of
231 Grammar Rules: Rules.
232
233 `;'
234 Terminates a rule. *Note Syntax of Grammar Rules: Rules.
235
236 `|'
237 Separates alternate rules for the same result nonterminal. *Note
238 Syntax of Grammar Rules: Rules.
239
240 \1f
241 File: bison.info, Node: Glossary, Next: Index, Prev: Table of Symbols, Up: Top
242
243 Glossary
244 ********
245
246 Backus-Naur Form (BNF)
247 Formal method of specifying context-free grammars. BNF was first
248 used in the `ALGOL-60' report, 1963. *Note Languages and
249 Context-Free Grammars: Language and Grammar.
250
251 Context-free grammars
252 Grammars specified as rules that can be applied regardless of
253 context. Thus, if there is a rule which says that an integer can
254 be used as an expression, integers are allowed _anywhere_ an
255 expression is permitted. *Note Languages and Context-Free
256 Grammars: Language and Grammar.
257
258 Dynamic allocation
259 Allocation of memory that occurs during execution, rather than at
260 compile time or on entry to a function.
261
262 Empty string
263 Analogous to the empty set in set theory, the empty string is a
264 character string of length zero.
265
266 Finite-state stack machine
267 A "machine" that has discrete states in which it is said to exist
268 at each instant in time. As input to the machine is processed, the
269 machine moves from state to state as specified by the logic of the
270 machine. In the case of the parser, the input is the language
271 being parsed, and the states correspond to various stages in the
272 grammar rules. *Note The Bison Parser Algorithm: Algorithm.
273
274 Grouping
275 A language construct that is (in general) grammatically divisible;
276 for example, `expression' or `declaration' in C. *Note Languages
277 and Context-Free Grammars: Language and Grammar.
278
279 Infix operator
280 An arithmetic operator that is placed between the operands on
281 which it performs some operation.
282
283 Input stream
284 A continuous flow of data between devices or programs.
285
286 Language construct
287 One of the typical usage schemas of the language. For example,
288 one of the constructs of the C language is the `if' statement.
289 *Note Languages and Context-Free Grammars: Language and Grammar.
290
291 Left associativity
292 Operators having left associativity are analyzed from left to
293 right: `a+b+c' first computes `a+b' and then combines with `c'.
294 *Note Operator Precedence: Precedence.
295
296 Left recursion
297 A rule whose result symbol is also its first component symbol; for
298 example, `expseq1 : expseq1 ',' exp;'. *Note Recursive Rules:
299 Recursion.
300
301 Left-to-right parsing
302 Parsing a sentence of a language by analyzing it token by token
303 from left to right. *Note The Bison Parser Algorithm: Algorithm.
304
305 Lexical analyzer (scanner)
306 A function that reads an input stream and returns tokens one by
307 one. *Note The Lexical Analyzer Function `yylex': Lexical.
308
309 Lexical tie-in
310 A flag, set by actions in the grammar rules, which alters the way
311 tokens are parsed. *Note Lexical Tie-ins::.
312
313 Literal string token
314 A token which consists of two or more fixed characters. *Note
315 Symbols::.
316
317 Look-ahead token
318 A token already read but not yet shifted. *Note Look-Ahead
319 Tokens: Look-Ahead.
320
321 LALR(1)
322 The class of context-free grammars that Bison (like most other
323 parser generators) can handle; a subset of LR(1). *Note
324 Mysterious Reduce/Reduce Conflicts: Mystery Conflicts.
325
326 LR(1)
327 The class of context-free grammars in which at most one token of
328 look-ahead is needed to disambiguate the parsing of any piece of
329 input.
330
331 Nonterminal symbol
332 A grammar symbol standing for a grammatical construct that can be
333 expressed through rules in terms of smaller constructs; in other
334 words, a construct that is not a token. *Note Symbols::.
335
336 Parse error
337 An error encountered during parsing of an input stream due to
338 invalid syntax. *Note Error Recovery::.
339
340 Parser
341 A function that recognizes valid sentences of a language by
342 analyzing the syntax structure of a set of tokens passed to it
343 from a lexical analyzer.
344
345 Postfix operator
346 An arithmetic operator that is placed after the operands upon
347 which it performs some operation.
348
349 Reduction
350 Replacing a string of nonterminals and/or terminals with a single
351 nonterminal, according to a grammar rule. *Note The Bison Parser
352 Algorithm: Algorithm.
353
354 Reentrant
355 A reentrant subprogram is a subprogram which can be in invoked any
356 number of times in parallel, without interference between the
357 various invocations. *Note A Pure (Reentrant) Parser: Pure Decl.
358
359 Reverse polish notation
360 A language in which all operators are postfix operators.
361
362 Right recursion
363 A rule whose result symbol is also its last component symbol; for
364 example, `expseq1: exp ',' expseq1;'. *Note Recursive Rules:
365 Recursion.
366
367 Semantics
368 In computer languages, the semantics are specified by the actions
369 taken for each instance of the language, i.e., the meaning of each
370 statement. *Note Defining Language Semantics: Semantics.
371
372 Shift
373 A parser is said to shift when it makes the choice of analyzing
374 further input from the stream rather than reducing immediately some
375 already-recognized rule. *Note The Bison Parser Algorithm:
376 Algorithm.
377
378 Single-character literal
379 A single character that is recognized and interpreted as is.
380 *Note From Formal Rules to Bison Input: Grammar in Bison.
381
382 Start symbol
383 The nonterminal symbol that stands for a complete valid utterance
384 in the language being parsed. The start symbol is usually listed
385 as the first nonterminal symbol in a language specification.
386 *Note The Start-Symbol: Start Decl.
387
388 Symbol table
389 A data structure where symbol names and associated data are stored
390 during parsing to allow for recognition and use of existing
391 information in repeated uses of a symbol. *Note Multi-function
392 Calc::.
393
394 Token
395 A basic, grammatically indivisible unit of a language. The symbol
396 that describes a token in the grammar is a terminal symbol. The
397 input of the Bison parser is a stream of tokens which comes from
398 the lexical analyzer. *Note Symbols::.
399
400 Terminal symbol
401 A grammar symbol that has no rules in the grammar and therefore is
402 grammatically indivisible. The piece of text it represents is a
403 token. *Note Languages and Context-Free Grammars: Language and
404 Grammar.
405
406 \1f
407 File: bison.info, Node: Index, Prev: Glossary, Up: Top
408
409 Index
410 *****
411
412 * Menu:
413
414 * $$: Actions.
415 * $N: Actions.
416 * %expect: Expect Decl.
417 * %left: Using Precedence.
418 * %nonassoc: Using Precedence.
419 * %prec: Contextual Precedence.
420 * %pure_parser: Pure Decl.
421 * %right: Using Precedence.
422 * %start: Start Decl.
423 * %token: Token Decl.
424 * %type: Type Decl.
425 * %union: Union Decl.
426 * @$ <1>: Action Features.
427 * @$: Actions and Locations.
428 * @N <1>: Action Features.
429 * @N: Actions and Locations.
430 * action: Actions.
431 * action data types: Action Types.
432 * action features summary: Action Features.
433 * actions in mid-rule: Mid-Rule Actions.
434 * actions, location: Actions and Locations.
435 * actions, semantic: Semantic Actions.
436 * additional C code section: C Code.
437 * algorithm of parser: Algorithm.
438 * associativity: Why Precedence.
439 * Backus-Naur form: Language and Grammar.
440 * Bison declaration summary: Decl Summary.
441 * Bison declarations: Declarations.
442 * Bison declarations (introduction): Bison Declarations.
443 * Bison grammar: Grammar in Bison.
444 * Bison invocation: Invocation.
445 * Bison parser: Bison Parser.
446 * Bison parser algorithm: Algorithm.
447 * Bison symbols, table of: Table of Symbols.
448 * Bison utility: Bison Parser.
449 * BISON_HAIRY: Environment Variables.
450 * BISON_SIMPLE: Environment Variables.
451 * BNF: Language and Grammar.
452 * C code, section for additional: C Code.
453 * C declarations section: C Declarations.
454 * C-language interface: Interface.
455 * calc: Infix Calc.
456 * calculator, infix notation: Infix Calc.
457 * calculator, multi-function: Multi-function Calc.
458 * calculator, simple: RPN Calc.
459 * character token: Symbols.
460 * compiling the parser: Rpcalc Compile.
461 * conflicts: Shift/Reduce.
462 * conflicts, reduce/reduce: Reduce/Reduce.
463 * conflicts, suppressing warnings of: Expect Decl.
464 * context-dependent precedence: Contextual Precedence.
465 * context-free grammar: Language and Grammar.
466 * controlling function: Rpcalc Main.
467 * dangling else: Shift/Reduce.
468 * data type of locations: Location Type.
469 * data types in actions: Action Types.
470 * data types of semantic values: Value Type.
471 * debugging: Debugging.
472 * declaration summary: Decl Summary.
473 * declarations, Bison: Declarations.
474 * declarations, Bison (introduction): Bison Declarations.
475 * declarations, C: C Declarations.
476 * declaring literal string tokens: Token Decl.
477 * declaring operator precedence: Precedence Decl.
478 * declaring the start symbol: Start Decl.
479 * declaring token type names: Token Decl.
480 * declaring value types: Union Decl.
481 * declaring value types, nonterminals: Type Decl.
482 * default action: Actions.
483 * default data type: Value Type.
484 * default location type: Location Type.
485 * default stack limit: Stack Overflow.
486 * default start symbol: Start Decl.
487 * defining language semantics: Semantics.
488 * else, dangling: Shift/Reduce.
489 * environment variables: Environment Variables.
490 * error: Error Recovery.
491 * error recovery: Error Recovery.
492 * error recovery, simple: Simple Error Recovery.
493 * error reporting function: Error Reporting.
494 * error reporting routine: Rpcalc Error.
495 * examples, simple: Examples.
496 * exercises: Exercises.
497 * file format: Grammar Layout.
498 * finite-state machine: Parser States.
499 * formal grammar: Grammar in Bison.
500 * format of grammar file: Grammar Layout.
501 * glossary: Glossary.
502 * grammar file: Grammar Layout.
503 * grammar rule syntax: Rules.
504 * grammar rules section: Grammar Rules.
505 * grammar, Bison: Grammar in Bison.
506 * grammar, context-free: Language and Grammar.
507 * grouping, syntactic: Language and Grammar.
508 * infix notation calculator: Infix Calc.
509 * interface: Interface.
510 * introduction: Introduction.
511 * invoking Bison: Invocation.
512 * invoking Bison under VMS: VMS Invocation.
513 * LALR(1): Mystery Conflicts.
514 * language semantics, defining: Semantics.
515 * layout of Bison grammar: Grammar Layout.
516 * left recursion: Recursion.
517 * lexical analyzer: Lexical.
518 * lexical analyzer, purpose: Bison Parser.
519 * lexical analyzer, writing: Rpcalc Lexer.
520 * lexical tie-in: Lexical Tie-ins.
521 * literal string token: Symbols.
522 * literal token: Symbols.
523 * location <1>: Locations.
524 * location: Locations Overview.
525 * location actions: Actions and Locations.
526 * look-ahead token: Look-Ahead.
527 * LR(1): Mystery Conflicts.
528 * main function in simple example: Rpcalc Main.
529 * mfcalc: Multi-function Calc.
530 * mid-rule actions: Mid-Rule Actions.
531 * multi-function calculator: Multi-function Calc.
532 * multicharacter literal: Symbols.
533 * mutual recursion: Recursion.
534 * nonterminal symbol: Symbols.
535 * operator precedence: Precedence.
536 * operator precedence, declaring: Precedence Decl.
537 * options for invoking Bison: Invocation.
538 * overflow of parser stack: Stack Overflow.
539 * parse error: Error Reporting.
540 * parser: Bison Parser.
541 * parser stack: Algorithm.
542 * parser stack overflow: Stack Overflow.
543 * parser state: Parser States.
544 * polish notation calculator: RPN Calc.
545 * position, textual <1>: Locations.
546 * position, textual: Locations Overview.
547 * precedence declarations: Precedence Decl.
548 * precedence of operators: Precedence.
549 * precedence, context-dependent: Contextual Precedence.
550 * precedence, unary operator: Contextual Precedence.
551 * preventing warnings about conflicts: Expect Decl.
552 * pure parser: Pure Decl.
553 * recovery from errors: Error Recovery.
554 * recursive rule: Recursion.
555 * reduce/reduce conflict: Reduce/Reduce.
556 * reduction: Algorithm.
557 * reentrant parser: Pure Decl.
558 * reverse polish notation: RPN Calc.
559 * right recursion: Recursion.
560 * rpcalc: RPN Calc.
561 * rule syntax: Rules.
562 * rules section for grammar: Grammar Rules.
563 * running Bison (introduction): Rpcalc Gen.
564 * semantic actions: Semantic Actions.
565 * semantic value: Semantic Values.
566 * semantic value type: Value Type.
567 * shift/reduce conflicts: Shift/Reduce.
568 * shifting: Algorithm.
569 * simple examples: Examples.
570 * single-character literal: Symbols.
571 * stack overflow: Stack Overflow.
572 * stack, parser: Algorithm.
573 * stages in using Bison: Stages.
574 * start symbol: Language and Grammar.
575 * start symbol, declaring: Start Decl.
576 * state (of parser): Parser States.
577 * string token: Symbols.
578 * summary, action features: Action Features.
579 * summary, Bison declaration: Decl Summary.
580 * suppressing conflict warnings: Expect Decl.
581 * symbol: Symbols.
582 * symbol table example: Mfcalc Symtab.
583 * symbols (abstract): Language and Grammar.
584 * symbols in Bison, table of: Table of Symbols.
585 * syntactic grouping: Language and Grammar.
586 * syntax error: Error Reporting.
587 * syntax of grammar rules: Rules.
588 * terminal symbol: Symbols.
589 * textual position <1>: Locations.
590 * textual position: Locations Overview.
591 * token: Language and Grammar.
592 * token type: Symbols.
593 * token type names, declaring: Token Decl.
594 * tracing the parser: Debugging.
595 * unary operator precedence: Contextual Precedence.
596 * using Bison: Stages.
597 * value type, semantic: Value Type.
598 * value types, declaring: Union Decl.
599 * value types, nonterminals, declaring: Type Decl.
600 * value, semantic: Semantic Values.
601 * VMS: VMS Invocation.
602 * warnings, preventing: Expect Decl.
603 * writing a lexical analyzer: Rpcalc Lexer.
604 * YYABORT: Parser Function.
605 * YYACCEPT: Parser Function.
606 * YYBACKUP: Action Features.
607 * yychar: Look-Ahead.
608 * yyclearin: Error Recovery.
609 * yydebug: Debugging.
610 * YYDEBUG: Debugging.
611 * YYEMPTY: Action Features.
612 * yyerrok: Error Recovery.
613 * YYERROR: Action Features.
614 * yyerror: Error Reporting.
615 * YYERROR_VERBOSE: Error Reporting.
616 * YYINITDEPTH: Stack Overflow.
617 * yylex: Lexical.
618 * YYLEX_PARAM: Pure Calling.
619 * yylloc: Token Positions.
620 * YYLLOC_DEFAULT: Location Default Action.
621 * YYLTYPE: Token Positions.
622 * yylval: Token Values.
623 * YYMAXDEPTH: Stack Overflow.
624 * yynerrs: Error Reporting.
625 * yyparse: Parser Function.
626 * YYPARSE_PARAM: Pure Calling.
627 * YYPRINT: Debugging.
628 * YYRECOVERING: Error Recovery.
629 * |: Rules.
630
631