资源简介
一个简单的词法分析器例子,运用lex编程实现将一段C语言程序转换为词法单元识别。
代码片段和文件信息
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /home/daffy/u0/vern/flex/RCS/flex.sklv 2.85 95/04/24 10:48:47 vern Exp $
*/
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#include
/* cfront 1.2 defines “c_plusplus“ instead of “__cplusplus“ */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif
#ifdef __cplusplus
#include
#include
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
/* The “const“ storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
#if __STDC__
#define YY_USE_PROTOS
#define YY_USE_CONST
#endif /* __STDC__ */
#endif /* ! __cplusplus */
#ifdef __TURBOC__
#pragma warn -rch
#pragma warn -use
#include
#include
#define YY_USE_CONST
#define YY_USE_PROTOS
#endif
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
#else
#define YY_PROTO(proto) ()
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Promotes a possibly negative possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative
* we want to instead treat it as an 8-bit unsigned char hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
/* Enter a start condition. This macro really ought to take a parameter
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN yy_start = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yy_start - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning “start processing a new file“. */
#define YY_NEW_FILE yyrestart( yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#define YY_BUF_SIZE 16384
typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern int yyleng;
extern FILE *yyin *yyout;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
/* The funky do-while in the following #define is used to turn the definition
* int a single C statement (which needs a semi-colon terminator). This
* avoids problems with code like:
*
* if ( condition_holds )
* yyless( 5 );
* else
* do_something_else();
*
* Prior to using the do-while the compiler would get upset at the
* “else“ because it interpreted the “if“ statement as being all
* done when it reached the ‘;‘ after the yyless() call.
*/
/* Return all but the first ‘n‘ matched characters back to the input stream. */
#defin属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-01-17 13:23 lex\
目录 0 2014-01-17 12:58 lex\lex词法分析\
目录 0 2014-01-17 12:58 lex\lex词法分析\Debug\
文件 204895 2011-06-14 20:30 lex\lex词法分析\Debug\lex.exe
文件 215244 2011-06-14 20:30 lex\lex词法分析\Debug\lex.ilk
文件 427008 2011-06-14 20:30 lex\lex词法分析\Debug\lex.pdb
文件 204891 2011-06-14 12:54 lex\lex词法分析\Debug\lex.yy.exe
文件 215080 2011-06-14 12:54 lex\lex词法分析\Debug\lex.yy.ilk
文件 30813 2011-06-14 12:55 lex\lex词法分析\Debug\lex.yy.obj
文件 175936 2011-06-14 12:54 lex\lex词法分析\Debug\lex.yy.pch
文件 427008 2011-06-14 12:54 lex\lex词法分析\Debug\lex.yy.pdb
文件 0 2014-01-17 12:58 lex\lex词法分析\Debug\output.txt
文件 33792 2011-06-14 20:40 lex\lex词法分析\Debug\vc60.idb
文件 53248 2011-06-14 12:55 lex\lex词法分析\Debug\vc60.pdb
文件 176 2011-06-14 20:37 lex\lex词法分析\input.txt
文件 4301 2010-04-02 19:43 lex\lex词法分析\lex.dsp
文件 531 2010-04-02 18:50 lex\lex词法分析\lex.dsw
文件 204858 2010-04-04 18:37 lex\lex词法分析\lex.exe
文件 1050 2011-06-14 20:38 lex\lex词法分析\lex.l
文件 50176 2011-06-14 20:44 lex\lex词法分析\lex.ncb
文件 48640 2011-06-14 20:44 lex\lex词法分析\lex.opt
文件 240 2011-06-14 20:38 lex\lex词法分析\lex.plg
文件 40834 2010-04-04 18:36 lex\lex词法分析\lex.yy.c
文件 3476 2011-06-14 12:56 lex\lex词法分析\lex.yy.dsp
文件 520 2011-06-14 12:56 lex\lex词法分析\lex.yy.dsw
文件 41984 2011-06-14 12:56 lex\lex词法分析\lex.yy.ncb
文件 48640 2011-06-14 12:56 lex\lex词法分析\lex.yy.opt
文件 1076 2011-06-14 12:55 lex\lex词法分析\lex.yy.plg
文件 574 2014-01-17 12:59 lex\lex词法分析\output.txt
文件 162 2011-06-15 01:08 lex\lex词法分析\~$实验二 报告.doc
文件 50672 2014-01-17 13:23 lex\报告.docx
............此处省略1个文件信息
相关资源
- C++获取计算机的CPU ID,硬盘序列号等
- C++头文件转delphi工具 + 源码
- 国际象棋的qt源代码
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C流程图生成器,用C语言代码 生成C语
- C++纯文字DOS超小RPG游戏
- 小甲鱼C语言课件 源代码
- 学校超市选址问题(数据结构C语言版
- VC++MFC小游戏实例教程(实例)+MFC类库
- c语言看发的网络协议 ,源代码
- LU分解法解线性方程组的C语言代码
- 手机话费管理系统(c语言编写)
- C语言实现的DES对称加密算法
- 数据结构,迷宫问题C语言版源代码
- C语言 学生信息管理系统 源代码
- C语言版3D魔方游戏源代码
- 编译原理实验-词法分析(c语言代码)
- C语言中 文件读取和写入的详细操作代
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
川公网安备 51152502000135号
评论
共有 条评论