点睛之笔是什么意思| 化疗前要做什么检查| 棕色和什么颜色搭配好看| 芒硝是什么东西| 心智不成熟是什么意思| 谷什么意思| 不假思索的假是什么意思| 啷个是什么意思| 手脚软无力是什么原因引起的| 差是什么意思| 勃勃生机是什么意思| 烦躁不安的意思是什么| 什么路人不能走| 梦见打死蛇是什么意思| 人参长什么样子图片| 广州番禺有什么好玩的地方| 脚抽筋是什么原因引起的| 下面痒是什么原因| 红糖不能和什么一起吃| 没睡好头疼是什么原因| 得之坦然失之淡然是什么意思| 为什么心里老是想着死| 肩颈疼痛挂什么科| 甲状腺结节是什么病| 缺席是什么意思| 潜伏是什么意思| 预测是什么意思| 抽血化验挂什么科| 花牛是什么| 肩胛骨疼是什么原因| 纷至沓来是什么意思| 湿疹是什么症状及图片| 疾苦的疾是什么意思| hyundai是什么牌子| 心境情感障碍是什么病| 下体痒是什么原因| 怀孕的脉象是什么样的| 乙肝表面抗体弱阳性什么意思| 气罐和火罐有什么区别| 幽门梗阻是什么意思| 左室舒张功能减低什么意思| 奋不顾身的顾是什么意思| 苹果对身体有什么好处| 放下身段是什么意思| legrand是什么牌子| 2010年属虎的是什么命| 多吃海带有什么好处和坏处| 梅毒是什么| 耳语是什么意思| 什么是意识| 宜祭祀是什么意思| 消防队属于什么编制| 什么是心脏早搏| 洋姜学名叫什么| 吃什么可以通便| acl医学上是什么意思| 小狗什么时候可以洗澡| 杏花什么季节开| 盗汗吃什么药| 三秋是什么意思| 西瓜可以做成什么美食| 查肝炎做什么检查项目| 指甲上有白点是什么原因| 减肥为什么要多喝水| 养老院护工都做些什么| 伏特加是什么酒| 爻卦是什么意思| 女性绝经期在什么年龄是正常的| 拍肺片挂什么科| 孔子名什么| 伊索寓言有什么故事| 喉咙干吃什么药| 为什么现在不建议输液| 微醺什么意思| 汤去掉三点水念什么| 3月27号是什么星座| 老汉推车是什么姿势| 早泄吃什么中药| 民兵是干什么的| 感冒看什么科| rolex是什么牌子的手表| 五七干校是什么意思| 哪吒妈妈叫什么名字| 炖牛肉不能放什么调料| 收缩压和舒张压是什么意思| 便秘去药店买什么药吃| 0101是什么意思| 夜尿多吃什么药| 茵陈和什么泡水喝对肝脏最好| 男孩什么时辰出生最好| 结肠炎不能吃什么食物| 煜字五行属什么| 喝酒手掌发红是什么原因| 浙江有什么旅游景点| 鼻涕由清变黄说明什么| 义字少一点念什么| e抗体阳性说明什么| 病毒是什么生物| 什么是幸福| 狂鸟读什么| 海参几头是什么意思| 哮喘病有什么症状| 外围是什么| ph什么意思| 冰释前嫌什么意思| 壬水命是什么意思| 三点水真读什么| 洗涤剂是什么| 生意盎然什么意思| 阿拉伯人是什么种人| 男人的精子对女人有什么好处| 枸杞泡茶有什么功效| 湿疹是什么样子| 什么药吃了会产生幻觉| 藏毛窦是什么病| 羽字属于五行属什么| 冬至为什么吃水饺| 小孩牙龈黑紫色是什么原因| 犬和狗有什么区别| 64年出生属什么| 男女之间的吸引靠什么| 黑眼圈是什么病| 来来来喝完这杯还有三杯是什么歌| 阴阳失调是什么意思| 獠牙是什么意思| 破太岁是什么意思| 穆斯林是什么| 八字加一笔是什么字| 须知是什么意思| 粽子叶是什么植物的叶子| plcc是什么意思| 辩证思维是什么意思| 蟑螂是什么样子的| 毛囊炎用什么药| 女命比肩代表什么| 鬼佬是什么意思| 镜检是什么| 望尘莫及是什么意思| 虹字五行属什么| 茶麸是什么东西| 鼓包是什么意思| 梅毒有什么症状| 膀胱充盈差是什么意思| 特发性震颤吃什么药| 鲫鱼喜欢吃什么| 10月21日是什么星座| 中唐筛查是检查什么| 脖子发痒是什么原因| 牙髓是什么| guess是什么意思| 总咳嗽是什么原因| 头孢长什么样| 身体缺钾是什么原因造成的| 一血是什么意思| 钛对人体有什么好处| 狗子是什么意思| 萧邦手表什么档次| 口腔脱皮是什么原因引起的| 尿比重高是什么意思| 咳黄痰是什么原因| 风湿是什么原因造成的| 心理障碍是什么病| 全科门诊主要看什么| 喝冰糖水有什么好处和坏处| 草缸适合养什么鱼| 男人梦见血是什么预兆| 医是什么结构| 灵芝长什么样子图片| 肌张力高是什么意思| 婴儿什么时候会说话| 烧心吃什么| 肺主什么| 血管堵塞用什么药| 薏米长什么样子的图片| 脚底板痛什么原因| 函询是什么意思| 宿便是什么颜色| 前列腺ca是什么意思| 乳腺发炎有什么症状| 66年属什么| 癫痫是什么症状| a型血与o型血生的孩子是什么血型| 梨状肌综合症吃什么药| 性格内向的人适合做什么工作| 蓝莓有什么功效| 蝶窦炎是什么病| 口吃什么意思| 睾酮是什么| 丁火是什么意思| 纷乐是什么药| 吞咽困难是什么感觉| 送长辈什么礼物合适| 局气是什么意思| 自然是什么意思| 2.17是什么星座| 肾阳虚女性什么症状| 龙猫是什么动物| 肺的作用和功能是什么| 入木三分什么意思| 鸽子咳嗽吃什么药最好| 鸟喜欢吃什么| 股骨长径是指胎儿什么| 爱钻牛角尖是什么意思| 脑炎的后遗症是什么| 丁胺卡那又叫什么药名| 化疗后白细胞低吃什么补得快| 为什么一同房就出血| 关节炎吃什么药好得快| 女人漏尿是什么原因| 天蝎女和什么星座最配| 空调睡眠是什么意思| 肠溶片是什么意思| 仙是什么意思| 松针是什么| cns医学上是什么意思| 竹蔗是什么| 东面墙适合挂什么画| 护理学和护理有什么区别| 为什么叫马桶| 什么是地中海贫血| rhd阳性是什么意思| 甲状腺功能检查挂什么科| 打茶围是什么意思| 走路腿软没劲是什么原因引起的| 三班倒什么意思| 腿胖是什么原因引起的| 12月23日什么星座| 减肥早餐吃什么| 外交部部长是什么级别| 汇报是什么意思| 白癜风早期症状是什么| 五月十三日是什么星座| 意志是什么意思| 低碳生活是什么意思| 宫颈活检cin1级是什么意思| 昔字五行属什么| feedback是什么意思| 竹荪是什么东西| 腰膝酸软是什么症状| 什么他妈的叫他妈的惊喜| 风热火眼是什么意思| 磨牙是缺什么| 尿素氮偏低是什么意思| 被隐翅虫咬了用什么药| 猪肉炒什么好吃| 吃什么油最好| 治疗勃起困难有什么药| 泌乳素过高女性会出现什么症状| 甲状腺炎吃什么药好| 高血压用什么药最好| 419是什么意思| 草字头加弓念什么| 甲亢是什么引起的| 梦到父母离婚是什么意思| 计抛是什么意思| pvc是什么意思| 六月十二日是什么日子| 水钻是什么材质| 什么是气血不足| 风平浪静是什么生肖| 小肚子疼是什么原因女性| 电邮地址是什么| 下肢静脉血栓吃什么药| 梅核气西医叫什么| 百度Jump to content

注意!有人冒充暖心公司人员骗取材料费安装费

From Wikipedia, the free encyclopedia
Lex
Original author(s)Mike Lesk, Eric Schmidt
Initial release1975; 50 years ago (1975)
Repository
Written inC
Operating systemUnix, Unix-like, Plan 9
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License
百度 对此,一方面,我们抓住供应端,通过加大土地供应,增加住房供给;另一方面,我们抓住需求端,遏制投资性购房,打击投机性购房,保障住房刚性需求,鼓励改善性住房需求。

Lex is a computer program that generates lexical analyzers ("scanners" or "lexers").[1][2] It is commonly used with the yacc parser generator and is the standard lexical analyzer generator on many Unix and Unix-like systems. An equivalent tool is specified as part of the POSIX standard.[3]

Lex reads an input stream specifying the lexical analyzer and writes source code which implements the lexical analyzer in the C programming language.

In addition to C, some old versions of Lex could generate a lexer in Ratfor.[4]

History

[edit]

Lex was originally written by Mike Lesk and Eric Schmidt[5] and described in 1975.[6][7] In the following years, Lex became the standard lexical analyzer generator on many Unix and Unix-like systems. In 1983, Lex was one of several UNIX tools available for Charles River Data Systems' UNOS operating system under Bell Laboratories license.[8] Although originally distributed as proprietary software, some versions of Lex are now open-source. Open-source versions of Lex, based on the original proprietary code, are now distributed with open-source operating systems such as OpenSolaris and Plan 9 from Bell Labs. One popular open-source version of Lex, called flex, or the "fast lexical analyzer", is not derived from proprietary coding.

Structure of a Lex file

[edit]

The structure of a Lex file is intentionally similar to that of a yacc file: files are divided into three sections, separated by lines that contain only two percent signs, as follows:

  • The definitions section defines macros and imports header files written in C. It is also possible to write any C code here, which will be copied verbatim into the generated source file.
  • The rules section associates regular expression patterns with C statements. When the lexer sees text in the input matching a given pattern, it will execute the associated C code.
  • The C code section contains C statements and functions that are copied verbatim to the generated source file. These statements presumably contain code called by the rules in the rules section. In large programs it is more convenient to place this code in a separate file linked in at compile time.

Example of a Lex file

[edit]

The following is an example Lex file for the flex version of Lex. It recognizes strings of numbers (positive integers) in the input, and simply prints them out.

/*** Definition section ***/

%{
/* C code to be copied verbatim */
#include <stdio.h>
%}

%%
    /*** Rules section ***/

    /* [0-9]+ matches a string of one or more digits */
[0-9]+  {
            /* yytext is a string containing the matched text. */
            printf("Saw an integer: %s\n", yytext);
        }

.|\n    {   /* Ignore all other characters. */   }

%%
/*** C Code section ***/

int main(void)
{
    /* Call the lexer, then quit. */
    yylex();
    return 0;
}

If this input is given to flex, it will be converted into a C file, lex.yy.c. This can be compiled into an executable which matches and outputs strings of integers. For example, given the input:

abc123z.!&*2gj6

the program will print:

Saw an integer: 123
Saw an integer: 2
Saw an integer: 6

Using Lex with other programming tools

[edit]

Using Lex with parser generators

[edit]

Lex, as with other lexical analyzers, limits rules to those which can be described by regular expressions. Due to this, Lex can be implemented by a finite-state automata as shown by the Chomsky hierarchy of languages. To recognize more complex languages, Lex is often used with parser generators such as Yacc or Bison. Parser generators use a formal grammar to parse an input stream.

It is typically preferable to have a parser, one generated by Yacc for instance, accept a stream of tokens (a "token-stream") as input, rather than having to process a stream of characters (a "character-stream") directly. Lex is often used to produce such a token-stream.

Scannerless parsing refers to parsing the input character-stream directly, without a distinct lexer.

Lex and make

[edit]

make is a utility that can be used to maintain programs involving Lex. Make assumes that a file that has an extension of .l is a Lex source file. The make internal macro LFLAGS can be used to specify Lex options to be invoked automatically by make.[9]

See also

[edit]

References

[edit]
  1. ^ Levine, John R.; Mason, Tony; Brown, Doug (1992). lex & yacc (2 ed.). O'Reilly. pp. 1–2. ISBN 1-56592-000-7.
  2. ^ Levine, John (August 2009). flex & bison. O'Reilly Media. p. 304. ISBN 978-0-596-15597-1.
  3. ^ The Open Group Base Specifications Issue 7, 2018 edition § Shell & Utilities § Utilities § lex
  4. ^ John R. Levine; John Mason; Doug Brown (1992). Lex & Yacc. O'Reilly. ISBN 9781565920002.
  5. ^ Lesk, M.E.; Schmidt, E. "Lex – A Lexical Analyzer Generator". Archived from the original on 2025-08-14. Retrieved August 16, 2010.
  6. ^ Lesk, M.E.; Schmidt, E. (July 21, 1975). "Lex – A Lexical Analyzer Generator" (PDF). UNIX TIME-SHARING SYSTEM:UNIX PROGRAMMER’S MANUAL, Seventh Edition, Volume 2B. bell-labs.com. Retrieved Dec 20, 2011.
  7. ^ Lesk, M.E. (October 1975). "Lex – A Lexical Analyzer Generator". Comp. Sci. Tech. Rep. No. 39. Murray Hill, New Jersey: Bell Laboratories.
  8. ^ The Insider's Guide To The Universe (PDF). Charles River Data Systems, Inc. 1983. p. 13.
  9. ^ "make". The Open Group Base Specifications (6). The IEEE and The Open Group. 2004. IEEE Std 1003.1, 2004 Edition.
[edit]
itp是什么意思 猫咪疫苗什么时候打 医共体是什么意思 眼睛浮肿是什么原因引起的 月亮为什么会有圆缺变化
9月3日是什么纪念日 四曾念什么 悄悄的什么 卵巢低回声是什么意思 什么是皈依
吃什么补充蛋白质 手背上长痣代表什么 何炅的老婆叫什么名字 鼻孔里面痒是什么原因 肝囊肿有什么症状表现
脾胃气虚吃什么药 item是什么意思 睾丸疼痛挂什么科 痣发痒是什么原因 拔萝卜是什么意思
缺钙有什么症状hcv8jop4ns2r.cn 赟怎么读 什么意思xinmaowt.com 灵芝有什么功效与作用hcv7jop6ns9r.cn 二级b超是检查什么hcv9jop4ns3r.cn 抗核抗体阳性对怀孕有什么影响hcv9jop7ns4r.cn
登高望远是什么生肖baiqunet.com 天地银行是什么意思hcv9jop2ns8r.cn 小阴唇是什么hcv8jop1ns4r.cn 请问支气管炎吃什么药最有效hcv8jop9ns6r.cn 医生规培是什么意思aiwuzhiyu.com
甲子年是什么意思hcv9jop2ns4r.cn 现在干什么挣钱helloaicloud.com 提刑官相当于现在什么官hcv8jop7ns9r.cn 男生为什么喜欢摸胸hcv8jop4ns2r.cn 前额头疼是什么原因引起的hcv8jop2ns8r.cn
羊癫疯是什么引起的adwl56.com 什么食物降尿酸效果好hcv7jop7ns3r.cn 鬃狮蜥吃什么hcv8jop5ns2r.cn 乳房胀痛挂什么科hcv8jop7ns1r.cn 蝉是什么生肖hcv8jop7ns0r.cn
百度