当前位置:网站首页>用LEX(FLEX)生成PL语言的词法分析器
用LEX(FLEX)生成PL语言的词法分析器
2022-07-28 17:20:00 【Ssaty.】
第1关:什么是lex/flex?
相信你学习过编译原理之后,一定是跃跃欲试,想要自己实现一个词法分析器,但是呢,别着急动手,要学会站在巨人的肩膀上。你是否发现,自己编写一大段重复或者类似的scanf和if语句来识别字符串十分麻烦?实际上,我们已经有了lex这个强大的工具。Lex是Lexical Compiler的缩写,是Unix环境下非常著名的工具,主要功能是生成一个词法分析器(scanner)的C源码,描述规则采用正则表达式(regular expression)。Flex(The Fast Lexical Analyzer)是GNU/Linux下的lex版本。
/* 简单词法分析器 */
/* 功能:能够识别出以小写字母ab结尾的所有字符串(仅含大小写字母)并给打印'Hit!' */
/* 说明:在下面的begin和end之间添加代码,已经实现了标识符和整常量的识别,你需要完成剩下的部分,加油吧! */
/* 提示:你只需要保证合法的输入(以ab结尾的字符串)有结果,不合法的输入将会包含在.规则中~ */
%{
边栏推荐
- Is the software testing industry really saturated?
- DevCon. Exe export output to the specified file
- Introduction and advanced level of MySQL (II)
- Why did wechat change from "small and beautiful" to "big and fat" when it expanded 575 times in 11 years?
- RTC clock: a calendar
- Easynlp Chinese text and image generation model takes you to become an artist in seconds
- Youqilin system installation beyondcomare
- [data analysis] realize SVDD decision boundary visualization based on MATLAB
- How to adjust the brightness of win11? Four methods of adjusting screen brightness in win11
- VIM learning manual
猜你喜欢

What is the future of software testing? How to learn?

架构实战营第8模块作业

【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码

Pytorch GPU yolov5 reports an error

VIM learning manual

The login interface of modern personal blog system modstartblog v5.4.0 has been revised and the contact information has been added

6-20 vulnerability exploitation proftpd test

How to solve the problem that the win11 computer camera cannot be seen when it is turned on and the display screen is black?

As for the white box test, you have to be skillful in these skills~

Pytest custom hook function
随机推荐
Qt: one signal binds multiple slots
Remember a uniapp experience
【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码
Swiftui component how to implement textfield of hidden part of phone number mask (tutorial includes source code)
Live broadcast platform software development, JS implementation by alphabetical order
QT - CPP database operation
Overview and working principle of single chip microcomputer crystal oscillator
架构实战营第8模块作业
Pointer learning of C language -- the consolidation of pointer knowledge and the relationship with functions, arrays and structures
DevCon.exe 导出output至指定文件
UE4.25 Slate源码解读
Parity rearrangement of Bm14 linked list
Is software testing really as good as online?
From Bayesian filter to Kalman filter (2)
Introduction and advanced level of MySQL (I)
RFs self study notes (III): clutter model - first determine the number with Poisson distribution, and then use uniform distribution as probability distribution
Application value of MES production management system to equipment
BM16 delete duplicate elements in the ordered linked list -ii
Why did wechat change from "small and beautiful" to "big and fat" when it expanded 575 times in 11 years?
How to solve the problem that easycvr device cannot be online again after offline?