BISON.INF 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. Info file bison.info, produced by Makeinfo, -*- Text -*- from input
  2. file bison.texinfo.
  3. This file documents the Bison parser generator.
  4. Copyright (C) 1988, 1989 Free Software Foundation, Inc.
  5. Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8. Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled ``GNU General Public License'' and
  11. ``Conditions for Using Bison'' are included exactly as in the
  12. original, and provided that the entire resulting derived work is
  13. distributed under the terms of a permission notice identical to this
  14. one.
  15. Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that the sections entitled ``GNU General Public
  18. License'', ``Conditions for Using Bison'' and this permission notice
  19. may be included in translations approved by the Free Software
  20. Foundation instead of in the original English.
  21. 
  22. File: bison.info, Node: Table of Symbols, Next: Glossary, Prev: Invocation, Up: Top
  23. Table of Bison Symbols
  24. **********************
  25. `error'
  26. A token name reserved for error recovery. This token may be
  27. used in grammar rules so as to allow the Bison parser to
  28. recognize an error in the grammar without halting the process.
  29. In effect, a sentence containing an error may be recognized as
  30. valid. On a parse error, the token `error' becomes the current
  31. look-ahead token. Actions corresponding to `error' are then
  32. executed, and the look-ahead token is reset to the token that
  33. originally caused the violation. *Note Error Recovery::.
  34. `YYABORT'
  35. Macro to pretend that an unrecoverable syntax error has
  36. occurred, by making `yyparse' return 1 immediately. The error
  37. reporting function `yyerror' is not called. *Note Parser
  38. Function::.
  39. `YYACCEPT'
  40. Macro to pretend that a complete utterance of the language has
  41. been read, by making `yyparse' return 0 immediately. *Note
  42. Parser Function::.
  43. `YYERROR'
  44. Macro to pretend that a syntax error has just been detected:
  45. call `yyerror' and then perform normal error recovery if
  46. possible (*note Error Recovery::.), or (if recovery is
  47. impossible) make `yyparse' return 1. *Note Error Recovery::.
  48. `YYLTYPE'
  49. Macro for the data type of `yylloc'; a structure with four
  50. members. *Note Token Positions::.
  51. `YYSTYPE'
  52. Macro for the data type of semantic values; `int' by default.
  53. *Note Value Type::.
  54. `yychar'
  55. External integer variable that contains the integer value of the
  56. current look-ahead token. (In a pure parser, it is a local
  57. variable within `yyparse'.) Error-recovery rule actions may
  58. examine this variable. *Note Action Features::.
  59. `yyclearin'
  60. Macro used in error-recovery rule actions. It clears the
  61. previous look-ahead token. *Note Error Recovery::.
  62. `yydebug'
  63. External integer variable set to zero by default. If `yydebug'
  64. is given a nonzero value, the parser will output information on
  65. input symbols and parser action. *Note Debugging::.
  66. `yyerrok'
  67. Macro to cause parser to recover immediately to its normal mode
  68. after a parse error. *Note Error Recovery::.
  69. `yyerror'
  70. User-supplied function to be called by `yyparse' on error. The
  71. function receives one argument, a pointer to a character string
  72. containing an error message. *Note Error Reporting::.
  73. `yylex'
  74. User-supplied lexical analyzer function, called with no
  75. arguments to get the next token. *Note Lexical::.
  76. `yylval'
  77. External variable in which `yylex' should place the semantic
  78. value associated with a token. (In a pure parser, it is a local
  79. variable within `yyparse', and its address is passed to
  80. `yylex'.) *Note Token Values::.
  81. `yylloc'
  82. External variable in which `yylex' should place the line and
  83. column numbers associated with a token. (In a pure parser, it
  84. is a local variable within `yyparse', and its address is passed
  85. to `yylex'.) You can ignore this variable if you don't use the
  86. `@' feature in the grammar actions. *Note Token Positions::.
  87. `yynerrs'
  88. Global variable which Bison increments each time there is a
  89. parse error. (In a pure parser, it is a local variable within
  90. `yyparse'.) *Note Error Reporting::.
  91. `yyparse'
  92. The parser function produced by Bison; call this function to
  93. start parsing. *Note Parser Function::.
  94. `%left'
  95. Bison declaration to assign left associativity to token(s).
  96. *Note Precedence Decl::.
  97. `%nonassoc'
  98. Bison declaration to assign nonassociativity to token(s). *Note
  99. Precedence Decl::.
  100. `%prec'
  101. Bison declaration to assign a precedence to a specific rule.
  102. *Note Contextual Precedence::.
  103. `%pure_parser'
  104. Bison declaration to request a pure (reentrant) parser. *Note
  105. Pure Decl::.
  106. `%right'
  107. Bison declaration to assign right associativity to token(s).
  108. *Note Precedence Decl::.
  109. `%start'
  110. Bison declaration to specify the start symbol. *Note Start
  111. Decl::.
  112. `%token'
  113. Bison declaration to declare token(s) without specifying
  114. precedence. *Note Token Decl::.
  115. `%type'
  116. Bison declaration to declare nonterminals. *Note Type Decl::.
  117. `%union'
  118. Bison declaration to specify several possible data types for
  119. semantic values. *Note Union Decl::.
  120. These are the punctuation and delimiters used in Bison input:
  121. `%%'
  122. Delimiter used to separate the grammar rule section from the
  123. Bison declarations section or the additional C code section.
  124. *Note Grammar Layout::.
  125. `%{ %}'
  126. All code listed between `%{' and `%}' is copied directly to the
  127. output file uninterpreted. Such code forms the ``C
  128. declarations'' section of the input file. *Note Grammar
  129. Outline::.
  130. `/*...*/'
  131. Comment delimiters, as in C.
  132. `:'
  133. Separates a rule's result from its components. *Note Rules::.
  134. `;'
  135. Terminates a rule. *Note Rules::.
  136. `|'
  137. Separates alternate rules for the same result nonterminal.
  138. *Note Rules::.
  139. 
  140. File: bison.info, Node: Glossary, Next: Index, Prev: Table of Symbols, Up: top
  141. Glossary
  142. ********
  143. Backus-Naur Form (BNF)
  144. Formal method of specifying context-free grammars. BNF was
  145. first used in the ``ALGOL-60'' report, 1963. *Note Language and
  146. Grammar::.
  147. Context-free grammars
  148. Grammars specified as rules that can be applied regardless of
  149. context. Thus, if there is a rule which says that an integer
  150. can be used as an expression, integers are allowed *anywhere* an
  151. expression is permitted. *Note Language and Grammar::.
  152. Dynamic allocation
  153. Allocation of memory that occurs during execution, rather than
  154. at compile time or on entry to a function.
  155. Empty string
  156. Analogous to the empty set in set theory, the empty string is a
  157. character string of length zero.
  158. Finite-state stack machine
  159. A ``machine'' that has discrete states in which it is said to
  160. exist at each instant in time. As input to the machine is
  161. processed, the machine moves from state to state as specified by
  162. the logic of the machine. In the case of the parser, the input
  163. is the language being parsed, and the states correspond to
  164. various stages in the grammar rules. *Note Algorithm::.
  165. Grouping
  166. A language construct that is (in general) grammatically
  167. divisible; for example, `expression' or `declaration' in C.
  168. *Note Language and Grammar::.
  169. Infix operator
  170. An arithmetic operator that is placed between the operands on
  171. which it performs some operation.
  172. Input stream
  173. A continuous flow of data between devices or programs.
  174. Language construct
  175. One of the typical usage schemas of the language. For example,
  176. one of the constructs of the C language is the `if' statement.
  177. *Note Language and Grammar::.
  178. Left associativity
  179. Operators having left associativity are analyzed from left to
  180. right: `a+b+c' first computes `a+b' and then combines with `c'.
  181. *Note Precedence::.
  182. Left recursion
  183. A rule whose result symbol is also its first component symbol;
  184. for example, `expseq1 : expseq1 ',' exp;'. *Note Recursion::.
  185. Left-to-right parsing
  186. Parsing a sentence of a language by analyzing it token by token
  187. from left to right. *Note Algorithm::.
  188. Lexical analyzer (scanner)
  189. A function that reads an input stream and returns tokens one by
  190. one. *Note Lexical::.
  191. Lexical tie-in
  192. A flag, set by actions in the grammar rules, which alters the
  193. way tokens are parsed. *Note Lexical Tie-ins::.
  194. Look-ahead token
  195. A token already read but not yet shifted. *Note Look-Ahead::.
  196. Nonterminal symbol
  197. A grammar symbol standing for a grammatical construct that can
  198. be expressed through rules in terms of smaller constructs; in
  199. other words, a construct that is not a token. *Note Symbols::.
  200. Parse error
  201. An error encountered during parsing of an input stream due to
  202. invalid syntax. *Note Error Recovery::.
  203. Parser
  204. A function that recognizes valid sentences of a language by
  205. analyzing the syntax structure of a set of tokens passed to it
  206. from a lexical analyzer.
  207. Postfix operator
  208. An arithmetic operator that is placed after the operands upon
  209. which it performs some operation.
  210. Reduction
  211. Replacing a string of nonterminals and/or terminals with a
  212. single nonterminal, according to a grammar rule. *Note
  213. Algorithm::.
  214. Reentrant
  215. A reentrant subprogram is a subprogram which can be in invoked
  216. any number of times in parallel, without interference between
  217. the various invocations. *Note Pure Decl::.
  218. Reverse polish notation
  219. A language in which all operators are postfix operators.
  220. Right recursion
  221. A rule whose result symbol is also its last component symbol;
  222. for example, `expseq1: exp ',' expseq1;'. *Note Recursion::.
  223. Semantics
  224. In computer languages the semantics are specified by the actions
  225. taken for each instance of the language, i.e., the meaning of
  226. each statement. *Note Semantics::.
  227. Shift
  228. A parser is said to shift when it makes the choice of analyzing
  229. further input from the stream rather than reducing immediately
  230. some already-recognized rule. *Note Algorithm::.
  231. Single-character literal
  232. A single character that is recognized and interpreted as is.
  233. *Note Grammar in Bison::.
  234. Start symbol
  235. The nonterminal symbol that stands for a complete valid
  236. utterance in the language being parsed. The start symbol is
  237. usually listed as the first nonterminal symbol in a language
  238. specification. *Note Start Decl::.
  239. Symbol table
  240. A data structure where symbol names and associated data are
  241. stored during parsing to allow for recognition and use of
  242. existing information in repeated uses of a symbol. *Note
  243. Multi-function Calc::.
  244. Token
  245. A basic, grammatically indivisible unit of a language. The
  246. symbol that describes a token in the grammar is a terminal symbol.
  247. The input of the Bison parser is a stream of tokens which comes
  248. from the lexical analyzer. *Note Symbols::.
  249. Terminal symbol
  250. A grammar symbol that has no rules in the grammar and therefore
  251. is grammatically indivisible. The piece of text it represents
  252. is a token. *Note Language and Grammar::.
  253. 
  254. File: bison.info, Node: Index, Prev: Glossary, Up: top
  255. Index
  256. *****
  257. * Menu:
  258. * $$: Actions.
  259. * $N: Actions.
  260. * %expect: Expect Decl.
  261. * %left: Using Precedence.
  262. * %nonassoc: Using Precedence.
  263. * %prec: Contextual Precedence.
  264. * %pure_parser: Pure Decl.
  265. * %right: Using Precedence.
  266. * %start: Start Decl.
  267. * %token: Token Decl.
  268. * %type: Type Decl.
  269. * %union: Union Decl.
  270. * @N: Action Features.
  271. * `calc': Infix Calc.
  272. * `else', dangling: Shift/Reduce.
  273. * `mfcalc': Multi-function Calc.
  274. * `rpcalc': RPN Calc.
  275. * BNF: Language and Grammar.
  276. * Backus-Naur form: Language and Grammar.
  277. * Bison declaration summary: Decl Summary.
  278. * Bison declarations: Declarations.
  279. * Bison declarations section (introduction): Bison Declarations.
  280. * Bison grammar: Grammar in Bison.
  281. * Bison invocation: Invocation.
  282. * Bison parser: Bison Parser.
  283. * Bison symbols, table of: Table of Symbols.
  284. * Bison utility: Bison Parser.
  285. * C code, section for additional: C Code.
  286. * C declarations section: C Declarations.
  287. * C-language interface: Interface.
  288. * YYABORT: Parser Function.
  289. * YYACCEPT: Parser Function.
  290. * YYDEBUG: Debugging.
  291. * action: Actions.
  292. * action data types: Action Types.
  293. * action features summary: Action Features.
  294. * actions in mid-rule: Mid-Rule Actions.
  295. * actions, semantic: Semantic Actions.
  296. * additional C code section: C Code.
  297. * algorithm of parser: Algorithm.
  298. * associativity: Why Precedence.
  299. * calculator, infix notation: Infix Calc.
  300. * calculator, multi-function: Multi-function Calc.
  301. * calculator, simple: RPN Calc.
  302. * character token: Symbols.
  303. * compiling the parser: Rpcalc Compile.
  304. * conflicts: Shift/Reduce.
  305. * conflicts, preventing warnings of: Expect Decl.
  306. * context-dependent precedence: Contextual Precedence.
  307. * context-free grammar: Language and Grammar.
  308. * controlling function: Rpcalc Main.
  309. * dangling `else': Shift/Reduce.
  310. * data types in actions: Action Types.
  311. * data types of semantic values: Value Type.
  312. * debugging: Debugging.
  313. * declaration summary: Decl Summary.
  314. * declarations section, Bison (introduction): Bison Declarations.
  315. * declarations, Bison: Declarations.
  316. * declarations, C: C Declarations.
  317. * declaring operator precedence: Precedence Decl.
  318. * declaring the start-symbol: Start Decl.
  319. * declaring token type names: Token Decl.
  320. * declaring value types: Union Decl.
  321. * declaring value types, nonterminals: Type Decl.
  322. * error: Error Recovery.
  323. * error recovery: Error Recovery.
  324. * error recovery, simple: Simple Error Recovery.
  325. * error reporting function: Error Reporting.
  326. * error reporting routine: Rpcalc Error.
  327. * examples, simple: Examples.
  328. * exercises: Exercises.
  329. * finite-state machine: Parser States.
  330. * formal grammar: Grammar in Bison.
  331. * glossary: Glossary.
  332. * grammar file: Grammar Layout.
  333. * grammar rule syntax: Rules.
  334. * grammar rules section: Grammar Rules.
  335. * grammar, context-free: Language and Grammar.
  336. * grouping, syntactic: Language and Grammar.
  337. * infix notation calculator: Infix Calc.
  338. * interface: Interface.
  339. * introduction: Introduction.
  340. * invoking Bison: Invocation.
  341. * language semantics: Semantics.
  342. * layout of Bison grammar: Grammar Layout.
  343. * left recursion: Recursion.
  344. * lexical analyzer: Lexical.
  345. * lexical analyzer, purpose: Bison Parser.
  346. * lexical analyzer, writing: Rpcalc Lexer.
  347. * lexical tie-in: Lexical Tie-ins.
  348. * literal token: Symbols.
  349. * look-ahead token: Look-Ahead.
  350. * main function in simple example: Rpcalc Main.
  351. * mid-rule actions: Mid-Rule Actions.
  352. * multi-function calculator: Multi-function Calc.
  353. * mutual recursion: Recursion.
  354. * nonterminal symbol: Symbols.
  355. * operator precedence: Precedence.
  356. * operator precedence, declaring: Precedence Decl.
  357. * options for Bison invocation: Invocation.
  358. * parse error: Error Reporting.
  359. * parser: Bison Parser.
  360. * parser stack: Algorithm.
  361. * parser state: Parser States.
  362. * polish notation calculator: RPN Calc.
  363. * precedence of operators: Precedence.
  364. * preventing warnings about conflicts: Expect Decl.
  365. * pure parser: Pure Decl.
  366. * recovery from errors: Error Recovery.
  367. * recursive rule: Recursion.
  368. * reduce/reduce conflict: Reduce/Reduce.
  369. * reduction: Algorithm.
  370. * reentrant parser: Pure Decl.
  371. * reverse polish notation: RPN Calc.
  372. * right recursion: Recursion.
  373. * rule syntax: Rules.
  374. * rules section for grammar: Grammar Rules.
  375. * running Bison (introduction): Rpcalc Gen.
  376. * semantic actions: Semantic Actions.
  377. * semantic value: Semantic Values.
  378. * semantic value type: Value Type.
  379. * semantics of the language: Semantics.
  380. * shift/reduce conflicts: Shift/Reduce.
  381. * shifting: Algorithm.
  382. * simple examples: Examples.
  383. * single-character literal: Symbols.
  384. * stack, parser: Algorithm.
  385. * stages in using Bison: Stages.
  386. * start symbol: Language and Grammar.
  387. * start-symbol, declaring: Start Decl.
  388. * state (of parser): Parser States.
  389. * summary, Bison declaration: Decl Summary.
  390. * summary, action features: Action Features.
  391. * symbol: Symbols.
  392. * symbol table example: Mfcalc Symtab.
  393. * symbols (abstract): Language and Grammar.
  394. * symbols in Bison, table of: Table of Symbols.
  395. * syntactic grouping: Language and Grammar.
  396. * syntax error: Error Reporting.
  397. * syntax of grammar rules: Rules.
  398. * terminal symbol: Symbols.
  399. * token: Language and Grammar.
  400. * token type: Symbols.
  401. * token type names, declaring: Token Decl.
  402. * tracing the parser: Debugging.
  403. * unary operator precedence: Contextual Precedence.
  404. * value type, semantic: Value Type.
  405. * value types, declaring: Union Decl.
  406. * value types, nonterminals, declaring: Type Decl.
  407. * warnings, preventing: Expect Decl.
  408. * writing a lexical analyzer: Rpcalc Lexer.
  409. * yychar: Look-Ahead.
  410. * yyclearin: Error Recovery.
  411. * yydebug: Debugging.
  412. * yyerrok: Error Recovery.
  413. * yyerror: Error Reporting.
  414. * yyerror: Rpcalc Error.
  415. * yylex: Lexical.
  416. * yylloc: Token Positions.
  417. * yylval: Token Values.
  418. * yynerrs: Error Reporting.
  419. * yyparse: Parser Function.
  420. * |: Rules.
  421. 
  422. Tag Table:
  423. Node: Top1138
  424. Node: Introduction2235
  425. Node: Conditions3309
  426. Node: Copying5162
  427. Node: Concepts18508
  428. Node: Language and Grammar19542
  429. Node: Grammar in Bison24008
  430. Node: Semantic Values25730
  431. Node: Semantic Actions27801
  432. Node: Bison Parser28978
  433. Node: Stages31213
  434. Node: Grammar Layout32430
  435. Node: Examples33672
  436. Node: RPN Calc34751
  437. Node: Rpcalc Decls35927
  438. Node: Rpcalc Rules37429
  439. Node: Rpcalc Input39159
  440. Node: Rpcalc Line40615
  441. Node: Rpcalc Expr41720
  442. Node: Rpcalc Lexer43671
  443. Node: Rpcalc Main46185
  444. Node: Rpcalc Error46561
  445. Node: Rpcalc Gen47534
  446. Node: Rpcalc Compile48642
  447. Node: Infix Calc49512
  448. Node: Simple Error Recovery52071
  449. Node: Multi-function Calc53946
  450. Node: Mfcalc Decl55484
  451. Node: Mfcalc Rules57436
  452. Node: Mfcalc Symtab58814
  453. Node: Exercises64961
  454. Node: Grammar File65469
  455. Node: Grammar Outline66237
  456. Node: C Declarations66994
  457. Node: Bison Declarations67595
  458. Node: Grammar Rules67987
  459. Node: C Code68419
  460. Node: Symbols69312
  461. Node: Rules72922
  462. Node: Recursion74544
  463. Node: Semantics76221
  464. Node: Value Type77310
  465. Node: Multiple Types77944
  466. Node: Actions78914
  467. Node: Action Types81277
  468. Node: Mid-Rule Actions82572
  469. Node: Declarations87849
  470. Node: Token Decl89092
  471. Node: Precedence Decl90396
  472. Node: Union Decl91943
  473. Node: Type Decl92780
  474. Node: Expect Decl93509
  475. Node: Start Decl95031
  476. Node: Pure Decl95428
  477. Node: Decl Summary96683
  478. Node: Multiple Parsers97884
  479. Node: Interface99569
  480. Node: Parser Function100404
  481. Node: Lexical101247
  482. Node: Calling Convention102631
  483. Node: Token Values103946
  484. Node: Token Positions105082
  485. Node: Pure Calling105956
  486. Node: Error Reporting106732
  487. Node: Action Features108436
  488. Node: Algorithm110921
  489. Node: Look-Ahead113041
  490. Node: Shift/Reduce115143
  491. Node: Precedence117531
  492. Node: Why Precedence118185
  493. Node: Using Precedence120037
  494. Node: Precedence Examples120998
  495. Node: How Precedence121697
  496. Node: Contextual Precedence122798
  497. Node: Parser States124586
  498. Node: Reduce/Reduce125820
  499. Node: Error Recovery128970
  500. Node: Context Dependency133818
  501. Node: Semantic Tokens134651
  502. Node: Lexical Tie-ins137674
  503. Node: Tie-in Recovery139167
  504. Node: Debugging141319
  505. Node: Invocation143736
  506. Node: Table of Symbols146257
  507. Node: Glossary151408
  508. Node: Index156729