下载此文档

吉大编译课件scanning-5.ppt


文档分类:IT计算机 | 页数:约34页 举报非法文档有奖
1/34
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/34 下载此文档
文档列表 文档介绍
Compiler Construction Principles & Implementation Techniques
Dr. Zheng Xiaojuan
Professor
Software College of Northeast Normal University
March. 2010
1
Summary for Last Lecture
Regular Expression (RE)
Some concepts and operations on strings & set of strings;
Definition of RE
Regular Definition
Generating NFA from Regular Expression
rules
2
Outline
Overview
General Function of a Scanner
Some Issues about Scanning
Finite Automata
Definition and Implementation of DFA
Non-Determinate Finite Automata
Transforming NFA into DFA
Minimizing DFA
Regular Expressions
Definition of Regular Expressions
Regular Definition
From Regular Expression to DFA
Design and Implementation of a Scanner
Developing a Scanner from DFA
A Scanner Generator – Lex



3
Design and Implementation of a Scanner
Developing a Scanner Manually
A Scanner Generator – Lex
4
Developing a Scanner Manually
Develop a
Scanner
Lexical Definition in
Regular Expression
NFA
DFA
transforming
transforming
minimized
DFA
minimizing
implement
5
Implement Scanner with DFA
Implementation of DFA
Just checking whether a string is acceptable by the DFA;
Implementation of a Scanner
not checking;
but recognizing an acceptable string(word) and establish its internal representation
<token-type, semantic information>
6
Implement Scanner with DFA
Some Issues
Independent or Attached
Skip these special characters
Blank, Tab, comments, return (line number)
When to stop scanning
At the end of the source file
Keywords & identifier
How to know the end of recognizing one token?
7
立即接受状态和延迟接受状态
;
:
=
other
d
d
other
立即接受状态
立即接受状态
延迟接受状态
延迟接受状态
 return(SEMI,;)
 return(ASS,:=)
 return(COLON,:) BACK()
 return(NUM,number) BACK()
*
*
8
Defining Lexical Structure of C0
letter = a|…|z|A|…|Z
digit = 0|…|9
NZ-digit = 1|…|9
Reserved = {| }| read| write
Identifier =letter(letter|digit)*

吉大编译课件scanning-5 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数34
  • 收藏数0 收藏
  • 顶次数0
  • 上传人精选文库
  • 文件大小0 KB
  • 时间2015-12-20