- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
The general format of Lex source is:
Lex 源的一般格式:
{definitions}
{定义}
%%
%%
{rules}
{规则}
%%
%%
{user subroutines}
{用户子程序}
where the definitions and the user subroutines are often omitted. The second %% is
optional, but the first is required to mark the beginning of the rules. The absolute
minimum Lex program is thus
定义和用户子程序部分是通常省略。第二个%%是可选的,但首先是需要记录规则的开头。绝
对最小的 Lex 程序是这样如此
%%
%%
(no definitions, no rules) which translates into a program which copies the input
to the output unchanged.
(没有定义,没有规则)转译成一个程序中把输入完全没有变化地复制到输出。
In the outline of Lex programs shown above, the rules represent the user’s control
decisions; they are a table, in which the left column contains regular expressions
(see section 3) and the right column contains actions, program fragments to be
executed when the expressions are recognized. Thus an individual rule might appear
integer printf(found keyword INT);
在上面显示的 Lex 程序里,规则代表用户控制的决定;在表中,左列包含正则表达式 (见第
三段)和右边栏包含动作,当表达式被组织时程序片段将执行。因此独立的规则可能出现
Integer printf( “发现的关键词 INT”);
to look for the string integer in the input stream and print the message “found
keyword INT” whenever it appears. In this example the host procedural language is
C and the C library function printf is used to print the string. The end of the
expression is indicated by the first blank or tab character. If the action is merely
a single C expression, it can just be given on the right side of the line; if it
is compound, or takes more than a line, it should be enclosed in braces. As a slightly
more useful example, suppose it is desired to change a number of words from British
to American spelling. Lex rules such as
为了寻找输入流中的字符串整数和输出信息 “发现的关键词 int”而不管它何时出现。在这
个例子中,本地程序语言是 C 和 C 库函数函数 printf 是用来输出字符串。表达式的最后部分
是用第一个空白处或制表符指出的。如果这种动作只不过是一个单一的 C 表达方式,它可能
只出现在右侧;如果它是复合的,或着超过几行,它都必须加上注释。在一个稍微有用的例子,
假设这是准备把英式拼法改成美式拼法。Lex 规则如下:
colour……………………输出( “color”)
您可能关注的文档
最近下载
- 山东省烟台市蓬莱实验初级中学2024-2025学年度第一学期9年级道德与法治素养形成期中测试(图片版,含答案).docx VIP
- 全国2025年10月自考00185《商品流通概论》真题及答案.docx VIP
- 2023年4月 自考 06056 心理学史 试题.pdf VIP
- 涉案财物管理系统V2.0T-用户使用说明书.pdf VIP
- 2025年网络安全等级测评师(中级)考核试题与答案.pdf VIP
- 电梯学徒安全培训记录课件.pptx VIP
- 公务员制度专题二.ppt VIP
- tc官网软件资源中文产品手册voicetone.pdf VIP
- 路灯售后服务方案及措施.docx VIP
- 河北省部分高中2024-2025学年高一上学期11月阶段性测试语文试卷(含答案).docx VIP
原创力文档


文档评论(0)