flex与bison(影印版)
flex与bison(影印版)
John Levine
出版时间:2009年12月
页数:271
如果你需要分析或处理Linux或Unix中的文本数据,这本有用的书籍就向你讲解了如何使用flex和bison迅速解决问题。《flex与bison》被期待已久,是经典O’Reilly系列书籍《lex & yacc》的续篇。在原书出版以来的近20年中,flex和bison已被证明比原来的Unix工具更可靠、更强大。
《flex与bison》一书涵盖了Linux和Unix程序开发中相同的重要核心功能,以及一些重要的新主题。你会找到适用于新手的修订教程和适用于高级用户的参考资料,以及对每个程序的基本用法的解释,并且运用它们创建简单、独立的应用程序。有了《flex与bison》,你会发现这些灵活的工具提供的广泛用途。
“我很高兴看到John彻底详尽地重写这本经典书。他更新的示例和说明,能够帮助老用户和新手摆脱模仿那些已经根深蒂固的旧lex和yacc。”
——Joel E. Denny bison维护人员
John Levine, Taughannock Networks的创始人,著有20余本技术书籍,其中包括《lex & yacc》和《qmail》,均为O’Reilly出版。
  1. Preface
  2. 1. Introducing Flex and Bison
  3. Lexical Analysis and Parsing
  4. Regular Expressions and Scanning
  5. Our First Flex Program
  6. Programs in Plain Flex
  7. Putting Flex and Bison Together
  8. The Scanner as Coroutine
  9. Tokens and Values
  10. Grammars and Parsing
  11. BNF Grammars
  12. Bison’s Rule Input Language
  13. Compiling Flex and Bison Programs Together
  14. Ambiguous Grammars: Not Quite
  15. Adding a Few More Rules
  16. Flex and Bison vs. Handwritten Scanners and Parsers
  17. Exercises
  18. 2. Using Flex
  19. Regular Expressions
  20. Regular Expression Examples
  21. How Flex Handles Ambiguous Patterns
  22. Context-Dependent Tokens
  23. File I/O in Flex Scanners
  24. Reading Several Files
  25. The I/O Structure of a Flex Scanner
  26. Input to a Flex Scanner
  27. Flex Scanner Output
  28. Start States and Nested Input Files
  29. Symbol Tables and a Concordance Generator
  30. Managing Symbol Tables
  31. Using a Symbol Table
  32. C Language Cross-Reference
  33. Exercises
  34. 3. Using Bison
  35. How a Bison Parser Matches Its Input
  36. Shift/Reduce Parsing
  37. What Bison’s LALR(1) Parser Cannot Parse
  38. A Bison Parser
  39. Abstract Syntax Trees
  40. An Improved Calculator That Creates ASTs
  41. Literal Character Tokens
  42. Building the AST Calculator
  43. Shift/Reduce Conflicts and Operator Precedence
  44. When Not to Use Precedence Rules
  45. An Advanced Calculator
  46. Advanced Calculator Parser
  47. Calculator Statement Syntax
  48. Calculator Expression Syntax
  49. Top-Level Calculator Grammar
  50. Basic Parser Error Recovery
  51. The Advanced Calculator Lexer
  52. Reserved Words
  53. Building and Interpreting ASTs
  54. Evaluating Functions in the Calculator
  55. User-Defined Functions
  56. Using the Advanced Calculator
  57. Exercises
  58. 4. Parsing SQL
  59. A Quick Overview of SQL
  60. Relational Databases
  61. Manipulating Relations
  62. Three Ways to Use SQL
  63. SQL to RPN
  64. The Lexer
  65. Scanning SQL Keywords
  66. Scanning Numbers
  67. Scanning Operators and Punctuation
  68. Scanning Functions and Names
  69. Comments and Miscellany
  70. The Parser
  71. The Top-Level Parsing Rules
  72. SQL Expressions
  73. Select Statements
  74. Delete Statement
  75. Insert and Replace Statements
  76. Update Statement
  77. Create Database
  78. Create Table
  79. User Variables
  80. The Parser Routines
  81. The Makefile for the SQL Parser
  82. Exercises
  83. 5. A Reference for Flex Specifications
  84. Structure of a Flex Specification
  85. Definition Section
  86. Rules Section
  87. User Subroutines
  88. BEGIN
  89. C++ Scanners
  90. Context Sensitivity
  91. Left Context
  92. Right Context
  93. Definitions (Substitutions)
  94. ECHO
  95. Input Management
  96. Stdio File Chaining
  97. Input Buffers
  98. Input from Strings
  99. File Nesting
  100. input()
  101. YY_INPUT
  102. Flex Library
  103. Interactive and Batch Scanners
  104. Line Numbers and yylineno
  105. Literal Block
  106. Multiple Lexers in One Program
  107. Combined Lexers
  108. Multiple Lexers
  109. Options When Building a Scanner
  110. Portability of Flex Lexers
  111. Porting Generated C Lexers
  112. Reentrant Scanners
  113. Extra Data for Reentrant Scanners
  114. Access to Reentrant Scanner Data
  115. Reentrant Scanners, Nested Files, and Multiple Scanners
  116. Using Reentrant Scanners with Bison
  117. Regular Expression Syntax
  118. Metacharacters
  119. REJECT
  120. Returning Values from yylex()
  121. Start States
  122. unput()
  123. yyinput() yyunput()
  124. yyleng
  125. yyless()
  126. yylex() and YY_DECL
  127. yymore()
  128. yyrestart()
  129. yy_scan_string and yy_scan_buffer
  130. YY_USER_ACTION
  131. yywrap()
  132. 6. A Reference for Bison Specifications
  133. Structure of a Bison Grammar
  134. Symbols
  135. Definition Section
  136. Rules Section
  137. User Subroutines Section
  138. Actions
  139. Embedded Actions
  140. Symbol Types for Embedded Actions
  141. Ambiguity and Conflicts
  142. Types of Conflicts
  143. Shift/Reduce Conflicts
  144. Reduce/Reduce Conflicts
  145. %expect
  146. GLR Parsers
  147. Bugs in Bison Programs
  148. Infinite Recursion
  149. Interchanging Precedence
  150. Embedded Actions
  151. C++ Parsers
  152. %code Blocks
  153. End Marker
  154. Error Token and Error Recovery
  155. %destructor
  156. Inherited Attributes ($0)
  157. Symbol Types for Inherited Attributes
  158. %initial-action
  159. Lexical Feedback
  160. Literal Block
  161. Literal Tokens
  162. Locations
  163. %parse-param
  164. Portability of Bison Parsers
  165. Porting Bison Grammars
  166. Porting Generated C Parsers
  167. Libraries
  168. Character Codes
  169. Precedence and Associativity Declarations
  170. Precedence
  171. Associativity
  172. Precedence Declarations
  173. Using Precedence and Associativity to Resolve Conflicts
  174. Typical Uses of Precedence
  175. Recursive Rules
  176. Left and Right Recursion
  177. Rules
  178. Special Characters
  179. %start Declaration
  180. Symbol Values
  181. Declaring Symbol Types
  182. Explicit Symbol Types
  183. Tokens
  184. Token Numbers
  185. Token Values
  186. %type Declaration
  187. %union Declaration
  188. Variant and Multiple Grammars
  189. Combined Parsers
  190. Multiple Parsers
  191. Using %name-prefix or the -p Flag
  192. Lexers for Multiple Parsers
  193. Pure Parsers
  194. y.output Files
  195. Bison Library
  196. main()
  197. yyerror()
  198. YYABORT
  199. YYACCEPT
  200. YYBACKUP
  201. yyclearin
  202. yydebug and YYDEBUG
  203. YYDEBUG
  204. yydebug
  205. yyerrok
  206. YYERROR
  207. yyerror()
  208. yyparse()
  209. YYRECOVERING()
  210. 7. Ambiguities and Conflicts
  211. The Pointer Model and Conflicts
  212. Kinds of Conflicts
  213. Parser States
  214. Contents of name.output
  215. Reduce/Reduce Conflicts
  216. Shift/Reduce Conflicts
  217. Review of Conflicts in name.output
  218. Common Examples of Conflicts
  219. Expression Grammars
  220. IF/THEN/ELSE
  221. Nested List Grammar
  222. How Do You Fix the Conflict?
  223. IF/THEN/ELSE (Shift/Reduce)
  224. Loop Within a Loop (Shift/Reduce)
  225. Expression Precedence (Shift/Reduce)
  226. Limited Lookahead (Shift/Reduce or Reduce/Reduce)
  227. Overlap of Alternatives (Reduce/Reduce)
  228. Summary
  229. Exercises
  230. 8. Error Reporting and Recovery
  231. Error Reporting
  232. Locations
  233. Adding Locations to the Parser
  234. Adding Locations to the Lexer
  235. More Sophisticated Locations with Filenames
  236. Error Recovery
  237. Bison Error Recovery
  238. Freeing Discarded Symbols
  239. Error Recovery in Interactive Parsers
  240. Where to Put Error Tokens
  241. Compiler Error Recovery
  242. Exercises
  243. 9. Advanced Flex and Bison
  244. Pure Scanners and Parsers
  245. Pure Scanners in Flex
  246. Pure Parsers in Bison
  247. Using Pure Scanners and Parsers Together
  248. A Reentrant Calculator
  249. GLR Parsing
  250. GLR Version of the SQL Parser
  251. C++ Parsers
  252. A C++ Calculator
  253. C++ Parser Naming
  254. A C++ Parser
  255. Interfacing a Scanner with a C++ Parser
  256. Should You Write Your Parser in C++ ?
  257. Exercises
  258. Appendix: SQL Parser Grammar and Cross-Reference
  259. Glossary
  260. Index
书名:flex与bison(影印版)
作者:John Levine
国内出版社:东南大学出版社
出版时间:2009年12月
页数:271
书号:978-7-5641-1932-4
原版书出版商:O'Reilly Media
John Levine
 
John R. Levine is the author of several dozen books, including lex and yacc and
qmail published by O’Reilly, and The Internet for Dummies. He writes, consults, and
lectures on computer software, network and email security, and policy topics.
 
 
The animals on the cover of flex & bison are Nicobar pigeons (Caloenas nicobarica).
This large (approximately 40 cm) bird with gray, yellow, and iridescent green plumage
resides on islands from the Bay of Bengal and Malaysia through New Guinea. DNA
analysis suggests that it is the closest living relative of the Dodo (Raphus cucullatus).
购买选项
定价:46.00元
书号:978-7-5641-1932-4
出版社:东南大学出版社