图书介绍

flex与bisonPDF|Epub|txt|kindle电子书版本网盘下载

flex与bison
  • JohnLevine编著 著
  • 出版社: 南京:东南大学出版社
  • ISBN:9787564119324
  • 出版时间:2010
  • 标注页数:273页
  • 文件大小:13MB
  • 文件页数:289页
  • 主题词:软件工具-程序设计-英文

PDF下载


点此进入-本书在线PDF格式电子书下载【推荐-云解压-方便快捷】直接下载PDF格式图书。移动端-PC端通用
种子下载[BT下载速度快]温馨提示:(请使用BT下载软件FDM进行下载)软件下载地址页直链下载[便捷但速度慢]  [在线试读本书]   [在线获取解压码]

下载说明

flex与bisonPDF格式电子书版下载

下载的文件为RAR压缩包。需要使用解压软件进行解压得到PDF格式图书。

建议使用BT下载工具Free Download Manager进行下载,简称FDM(免费,没有广告,支持多平台)。本站资源全部打包为BT种子。所以需要使用专业的BT下载软件进行下载。如BitComet qBittorrent uTorrent等BT下载工具。迅雷目前由于本站不是热门资源。不推荐使用!后期资源热门了。安装了迅雷也可以迅雷进行下载!

(文件页数 要大于 标注页数,上中下等多册电子书除外)

注意:本站所有压缩包均有解压码: 点击下载压缩包解压工具

图书目录

1.Introducing Flex and Bison1

Lexical Analysis and Parsing1

Regular Expressions and Scanning2

Our First Flex Program2

Programs in Plain Flex4

Putting Flex and Bison Together5

The Scanner as Coroutine6

Tokens and Values7

Grammars and Parsing9

BNF Grammars10

Bison's Rule Input Language11

Compiling Flex and Bison Programs Together13

Ambiguous Grammars:Not Quite14

Adding a Few More Rules15

Flex and Bison vs.Handwritten Scanners and Parsers16

Exercises17

2.Using Flex19

Regular Expressions19

Regular Expression Examples21

How Flex Handles Ambiguous Patterns22

Context-Dependent Tokens22

File I/O in Flex Scanners23

Reading Several Files24

The I/O Structure of a Flex Scanner25

Input to a Flex Scanner26

Flex Scanner Output27

Start States and Nested Input Files28

Symbol Tables and a Concordance Generator32

Managing Symbol Tables32

Using a Symbol Table35

C Language Cross-Reference38

Exercises45

3.Using Bison47

How a Bison Parser Marches Its Input47

Shift/Reduce Parsing48

What Bison's LALR(1) Parser Cannot Parse50

A Bison Parser51

Abstract Syntax Trees51

An Improved Calculator That Creates ASTs52

Literal Character Tokens54

Building the AST Calculator57

Shift/Reduce Conflicts and Operator Precedence57

When Not to Use Precedence Rules60

An Advanced Calculator61

Advanced Calculator Parser64

Calculator Statement Syntax65

Calculator Expression Syntax66

Top-Level Calculator Grammar67

Basic Parser Error Recovery67

The Advanced Calculator Lexer68

Reserved Words69

Building and Interpreting ASTs70

Evaluating Functions in the Calculator76

User-Defined Functions76

Using the Advanced Calculator78

Exercises79

4.Parsing SQL81

A Quick Overview of SQL81

Relational Databases82

Manipulating Relations83

Three Ways to Use SQL83

SQL to RPN84

The Lexer85

Scanning SQL Keywords86

Scanning Numbers90

Scanning Operators and Punctuation91

Scanning Functions and Names92

Comments and Miscellany93

The Parser94

The Top-Level Parsing Rules96

SQL Expressions96

Select Statements101

Delete Statement106

Insert and Replace Statements107

Update Statement110

Create Database110

Create Table111

User Variables114

The Parser Routines115

The Makefile for the SQL Parser116

Exercises117

5.A Reference for Flex Specifications119

Structure of a Flex Specification119

Definition Section119

Rules Section119

User Subroutines120

BEGIN120

C++ Scanners121

Context Sensitivity121

Left Context121

Right Context122

Definitions(Substitutions)122

ECHO123

Input Management123

Stdio File Chaining123

Input Buffers123

Input from Strings124

File Nesting124

input()124

YY_INPUT125

Flex Library125

Interactive and Batch Scanners126

Line Numbers and yylineno126

Literal Block126

Multiple Lexers in One Program127

Combined Lexers127

Multiple Lexers128

Options When Building a Scanner128

Portability of Flex Lexers129

Porting Generated C Lexers129

Reentrant Scanners130

Extra Data for Reentrant Scanners130

Access to Reentrant Scanner Data131

Reentrant Scanners,Nested Files,and Multiple Scanners131

Using Reentrant Scanners with Bison132

Regular Expression Syntax132

Metacharacters132

REJECT135

Returning Values from yylex()135

Start States135

unput()137

yyinput() yyunput()137

yyleng137

yyless()137

yylex() and YY_DECL138

yymore()138

yyrestart()139

yy_scan_string and yy_scan_buffer139

YY_USER_ACTION139

yywrap()139

6.A Reference for Bison Specifications141

Structure of a Bison Grammar141

Symbols141

Definition Section142

Rules Section142

User Subroutines Section142

Actions142

Embedded Actions143

Symbol Types for Embedded Actions144

Ambiguity and Conflicts144

Types of Conflicts144

Shift/Reduce Conflicts144

Reduce/Reduce Conflicts145

%expect145

GLR Parsers145

Bugs in Bison Programs146

Infinite Recursion146

Interchanging Precedence146

Embedded Actions146

C++ Parsers147

%code Blocks147

End Marker147

Error Token and Error Recovery147

%destructor148

Inherited Attributes($0)148

Symbol Types for Inherited Attributes149

%initial-action149

Lexical Feedback150

Literal Block151

Literal Tokens151

Locations152

%parse-param152

Portability of Bison Parsers153

Porting Bison Grammars153

Porting Generated C Parsers153

Libraries153

Character Codes153

Precedence and Associativity Declarations154

Precedence154

Associativity154

Precedence Declarations154

Using Precedence and Associativity to Resolve Conflicts155

Typical Uses of Precedence155

Recursive Rules155

Left and Right Recursion156

Rules157

Special Characters158

%start Declaration159

Symbol Values160

Declaring Symbol Types160

Explicit Symbol Types160

Tokens161

Token Numbers161

Token Values161

%type Declaration162

%union Declaration163

Variant and Multiple Grammars163

Combined Parsers163

Multiple Parsers165

Using %name-prefix or the-p Flag165

Lexers for Multiple Parsers165

Pure Parsers165

y.output Files166

Bison Library167

main()167

yyerror()167

YYABORT168

YYACCEPT168

YYBACKUP168

yyclearin169

yydebug and YYDEBUG169

YYDEBUG169

yydebug169

yyerrok169

YYERROR170

yyerror()170

yyparse()171

YYRECOVERING()171

7.Ambiguitiesand Conflicts173

The Pointer Model and Conflicts173

Kinds of Conflicts175

Parser States176

Contents of name.output178

Reduce/Reduce Conflicts178

Shift/Reduce Conflicts180

Review of Conflicts in name.output182

Common Examples of Conflicts183

Expression Grammars183

IF/THEN/ELSE185

Nested List Grammar186

How Do You Fix the Conflict?187

IF/THEN/ELSE(Shift/Reduce)188

Loop Within a Loop(Shift/Reduce)190

Expression Precedence(Shift/Reduce)191

Limited Lookahead(Shift/Reduce or Reduce/Reduce)191

Overlap of Alternatives(Reduce/Reduce)192

Summary194

Exercises194

8.Error Reporting and Recovery197

Error Reporting197

Locations199

Adding Locations to the Parser200

Adding Locations to the Lexer201

More Sophisticated Locations with Filenames202

Error Recovery204

Bison Error Recovery205

Freeing Discarded Symbols206

Error Recovery in Interactive Parsers206

Where to Put Error Tokens207

Compiler Error Recovery208

Exercises208

9.Advanced Flexand Bison209

Pure Scanners and Parsers209

Pure Scanners in Flex210

Pure Parsers in Bison212

Using Pure Scanners and Parsers Together213

A Reentrant Calculator214

GLR Parsing230

GLR Version of the SQL Parser231

C++ Parsers234

A C++ Calculator235

C++ Parser Naming235

A C++ Parser236

Interfacing a Scanner with a C++ Parser239

Should You Write Your Parser in C++?241

Exercises241

Appendix:SQL Parser Grammar and Cross-Reference243

Glossary259

Index263

热门推荐