Wednesday, September 29, 2010

the lex and yacc page

http://dinosaur.compilertools.net/

overview
A compiler or interpreter for a programminning language is often decomposed into two parts:
  1. Read the source program and discover its structure.
  2. Process this structure, e.g. to generate the target program.

compiler compiler flex bison

1. today's goal
.learn how to use lexical scanner flex and context parser bison

Thursday, September 23, 2010

flex and bison

CHAPTER 1 In troducin g Flex an d Bison
(p1)

Flex and Bison are tools for building programs that handle structured input.

Lexical Analysis and Parsing
The earliest compilers back in the 1950s used utterly ad hoc techniques to analyze the syntax of the source code of programs they were compiling.

One of the key insights was to break the job into two parts: lexical analysis (also called lexing or scanning) and syntax analysis (or parsing).

Roughly speaking, scanning divides the input into meaningful chunks, called tokens, and parsing figures out how the tokens relate to each other


Regular Expressions and Scanning
Scanners generally work by looking for patterns of characters in the input. For example,
in a C program, an integer constant is a string of one or more digits, a variable name is a letter followed by zero or more letters or digits, and the various operators are single characters or pairs of characters
. A straightforward way to describe these patterns is regular expressions, often shortened to regex or regexp.

Thursday, September 9, 2010

preface

p15
p16
scope of this book
(page 17)

(p18)
availability of lex & yacc
yacc: stephen johnson

(p21)
Ch1 lex and yacc
Lex and yacc help you write programs that transform structured input.