⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flexdoc.1

📁 操作系统设计与实现源码
💻 1
📖 第 1 页 / 共 5 页
字号:
2958(up)S3084(appropriately.)S3697(It)S3785(may)S3985(either)S4242(be)S4364(one)S4536(which)S4809(matched)S5177(as)S7128 V1440(much)S1706(text)S1900(as)S2026(the)S2191(originally)S2624(chosen)S2945(rule)S3144(but)S3314(came)S3569(later)S3791(in)S3911(the)S10 I4076(\257ex)S10 R(input)206 4258 A4506(\256le,)S4702(or)S4828(one)S5015(which)S7248 V1440(matched)S1811(less)S1992(text.)S2223(For)S2393(example,)S2789(the)S2942(following)S(will)157 3363 A3550(both)S(count)223 3758 A4011(the)S4164(words)S4440(in)S4548(the)S(input)206 4702 A4939(and)S5115(call)S7368 V1440(the)S1588(routine)S1898(special\(\))S2271(whenever)S2688("frob")S2963(is)S3055(seen:)S7903 V720(September)S1176(13,)S(1996)200 1326 A2681(\()S2723(26)S2848(May)S(1990)200 3057 A3265(\))S4990(Page)S5211(6)S8143 VEP%%Page: 7 7BP/slant 0 def/height 0 def480 V10 R720(FLEX)S981(\()S1023(1)S1081(\))S2756(Version)S3100(2.3)S4866(FLEX)S5127(\()S5169(1)S5227(\))S960 V1740(int)S(word_count)480 1871 A2376(=)S2458(0;)S1080 V1540(%%)S1320 V1540(frob)S1908(special\(\);)S2309(REJECT;)S1440 V1540([\303)S(\\t\\n]+)225 1633 A(++word_count;)622 1933 A1680 V(Without)329 1440 A1808(the)S10 B1970(REJECT,)S10 R2431(any)S2615("frob"'s)S2977(in)S3095(the)S(input)206 3258 A3504(would)S3795(not)S3963(be)S(counted)318 4098 A4456(as)S4580(words,)S4891(since)S5138(the)S1800 V1440(scanner)S1779(normally)S2173(executes)S2551(only)S2759(one)S2934(action)S3210(per)S3369(token.)S(Multiple)346 3672 A10 B4048(REJECT's)S10 R4548(are)S4702(allowed,)S(each)185 5076 A1920 V1440(one)S1613(\256nding)S1925(the)S2076(next)S2277(best)S2467(choice)S2758(to)S2864(the)S3015(currently)S3407(active)S3676(rule.)S3911(For)S4079(example,)S4473(when)S4719(the)S4870(following)S2040 V1440(scanner)S1773(scans)S2016(the)S2164(token)S2412("abcd",)S2734(it)S(will)157 2815 A2997(write)S3230("abcdabcaba")S3807(to)S3910(the)S4058(output:)S2280 V1540(%%)S2400 V1540(a)S1785(|)S2520 V1540(ab)S1810(|)S2640 V1540(abc)S1830(|)S2760 V1540(abcd)S1855(ECHO;)S2183(REJECT;)S2880 V1540(.|\\n)S1788(/*)S1891(eat)S2034(up)S2159(any)S2329(unmatched)S2795(character)S3191(*/)S3120 V1440(\(The)S1660(\256rst)S1846(three)S2077(rules)S2302(share)S2544(the)S2696(fourth's)S3044(action)S3319(since)S3556(they)S3759(use)S3923(the)S4076(special)S4386('|')S4504(action.\))S10 B4864(REJECT)S3240 V10 R1440(is)S1546(a)S1630(particularly)S2134(expensive)S2575(feature)S2895(in)S3012(terms)S3274(scanner)S3620(performance;)S4196(if)S4296(it)S4390(is)S4495(used)S4717(in)S10 I4833(any)S10 R5016(of)S5138(the)S3360 V1440(scanner's)S1861(actions)S2186(it)S(will)157 2282 A2479(slow)S2709(down)S10 I2972(all)S10 R3118(of)S3243(the)S3407(scanner's)S3829(matching.)S4294(Furthermore,)S10 B4864(REJECT)S3480 V10 R(cannot)268 1440 A1733(be)S1853(used)S2062(with)S2266(the)S10 I2414(-f)S10 R2501(or)S10 I2610(-F)S10 R2731(options)S3051(\(see)S3239(below\).)S3648 V1440(Note)S1669(also)S1865(that)S2050(unlike)S2335(the)S2492(other)S2733(special)S3047(actions,)S10 B3391(REJECT)S10 R3822(is)S3923(a)S10 I4002(branch;)S10 R4354(code)S4578(immediately)S5115(fol-)S3768 V1440(lowing)S1744(it)S1825(in)S1928(the)S2076(action)S(will)157 2347 A10 I2529(not)S10 R2682(be)S2802(executed.)S3936 V1080(-)S10 B1440(yymore\(\))S10 R1858(tells)S2052(the)S2202(scanner)S2537(that)S2715(the)S2865(next)S3065(time)S3271(it)S3354(matches)S3711(a)S3783(rule,)S3992(the)S(corresponding)575 4142 A4744(token)S(should)267 4994 A4056 V1440(be)S10 I(appended)390 1565 A10 R1985(onto)S2193(the)S2346(current)S2662(value)S2910(of)S10 B3024(yytext)S10 R3316(rather)S3581(than)S3783(replacing)S4187(it.)S4322(For)S4491(example,)S4886(given)S5138(the)S4176 V(input)206 1440 A("mega-kludge")607 1671 A2303(the)S2451(following)S(will)157 2867 A3049(write)S("mega-mega-kludge")859 3282 A4166(to)S4269(the)S4417(output:)S4416 V1540(%%)S4536 V1540(mega-)S1892(ECHO;)S2220(yymore\(\);)S4656 V(kludge)273 1540 A1888(ECHO;)S4896 V1440(First)S1656("mega-")S2021(is)S2119(matched)S2491(and)S2667(echoed)S2983(to)S3092(the)S3246(output.)S3583(Then)S("kludge")355 3821 A4208(is)S4307(matched,)S4705(but)S4865(the)S5020(previ-)S5016 V1440(ous)S1609("mega-")S1973(is)S(still)151 2070 A2251(hanging)S(around)279 2604 A2913(at)S3016(the)S3169(beginning)S3600(of)S10 B3714(yytext)S10 R4007(so)S4126(the)S10 B4279(ECHO)S10 R4605(for)S4753(the)S("kludge")355 4906 A5136 V1440(rule)S(will)157 1639 A1838(actually)S2199(write)S("mega-kludge".)632 2449 A3148(The)S3347(presence)S3742(of)S10 B3869(yymore\(\))S10 R4304(in)S4425(the)S4591(scanner's)S5015(action)S5256 V1440(entails)S1728(a)S1798(minor)S2063(performance)S2598(penalty)S2919(in)S3022(the)S3170(scanner's)S3576(matching)S3975(speed.)S5424 V1080(-)S10 B1440(yyless\(n\))S10 R1851(returns)S2167(all)S2305(but)S2470(the)S2630(\256rst)S10 I2824(n)S10 R2911(characters)S3358(of)S3479(the)S3639(current)S3962(token)S4222(back)S4449(to)S4564(the)S(input)206 4724 A4967(stream,)S5544 V1440(where)S1720(they)S(will)157 1926 A2116(be)S2243(rescanned)S2678(when)S2928(the)S3083(scanner)S(looks)217 3423 A3672(for)S3822(the)S3977(next)S4182(match.)S10 B4510(yytext)S10 R4805(and)S10 B4982(yyleng)S5664 V10 R1440(are)S1598(adjusted)S1967(appropriately)S2538(\(e.g.,)S10 B2776(yyleng)S10 R(will)157 3089 A3280(now)S3487(be)S3616(equal)S3869(to)S10 I3982(n)S10 R4067(\).)S4186(For)S4361(example,)S4762(on)S4897(the)S(input)206 5055 A5784 V("foobar")345 1440 A1810(the)S1958(following)S(will)157 2374 A2556(write)S2789(out)S("foobarbar":)502 2942 A6024 V1540(%%)S6144 V(foobar)263 1540 A1903(ECHO;)S2231(yyless\(3\);)S6264 V1540([a-z]+)S1889(ECHO;)S6504 V1440(An)S1604(argument)S2025(of)S2150(0)S2241(to)S10 B2360(yyless)S10 R(will)157 2652 A2850(cause)S3115(the)S3279(entire)S3550(current)S(input)206 3877 A4124(string)S4395(to)S4515(be)S4652(scanned)S5018(again.)S6624 V1440(Unless)S(you've)279 1740 A2045(changed)S2405(how)S2603(the)S2751(scanner)S(will)157 3084 A3266(subsequently)S3815(process)S4142(its)S(input)206 4262 A4493(\(using)S10 B4769(BEGIN,)S10 R5143(for)S6744 V1440(example\),)S1865(this)S(will)157 2035 A2217(result)S2466(in)S2569(an)S2689(endless)S(loop.)203 3010 A6912 V1080(-)S10 B(unput\(c\))371 1440 A10 R1860(puts)S2076(the)S2248(character)S10 I2669(c)S10 R2764(back)S3004(onto)S3232(the)S(input)206 3405 A3661(stream.)S4030(It)S(will)157 4142 A4349(be)S4494(the)S4667(next)S4890(character)S7032 V1440(scanned.)S1864(The)S2071(following)S2512(action)S(will)157 2808 A3015(take)S3233(the)S3406(current)S3742(token)S4015(and)S4209(cause)S4482(it)S4587(to)S4714(be)S4858(rescanned)S7152 V1440(enclosed)S1817(in)S1920(parentheses.)S7392 V1540({)S7512 V1540(int)S1671(i;)S7903 V720(Page)S941(7)S2681(\()S2723(26)S2848(May)S(1990)200 3057 A3265(\))S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Page: 8 8BP/slant 0 def/height 0 def480 V10 R720(FLEX)S981(\()S1023(1)S1081(\))S2756(Version)S3100(2.3)S4866(FLEX)S5127(\()S5169(1)S5227(\))S960 V(unput\()262 1540 A('\)')102 1827 A1954(\);)S1080 V1540(for)S1683(\()S1742(i)S1795(=)S1877(yyleng)S2175(-)S2234(1;)S2337(i)S2390(>=)S2529(0;)S2632(--i)S2753(\))S1200 V(unput\()262 1640 A1927(yytext[i])S2299(\);)S1320 V(unput\()262 1540 A('\(')102 1827 A1954(\);)S1440 V1540(})S1680 V1440(Note)S1680(that)S1875(since)S(each)185 2126 A10 B(unput\(\))326 2356 A10 R2727(puts)S2939(the)S3107(given)S3375(character)S3791(back)S4026(at)S4144(the)S10 I4312(beginning)S10 R4758(of)S4887(the)S(input)206 5055 A1800 V1440(stream,)S1759(pushing)S2101(back)S2316(strings)S2609(must)S2829(be)S(done)195 2949 A(back-to-front.)557 3169 A1968 V1080(-)S10 B(input\(\))298 1440 A10 R1764(reads)S2003(the)S2152(next)S2351(character)S2748(from)S2970(the)S(input)206 3120 A3353(stream.)S3699(For)S3866(example,)S4259(the)S4409(following)S4827(is)S4921(one)S5093(way)S2088 V1440(to)S1543(eat)S1686(up)S1811(C)S1903(comments:)S2328 V1540(%%)S2448 V1540("/*")S1900({)S2568 V1840(register)S2168(int)S2299(c;)S2808 V1840(for)S1983(\()S2042(;)S2095(;)S2148(\))S2928 V1940({)S3048 V1940(while)S2189(\()S2248(\(c)S2352(=)S(input\(\)\))308 2434 A2767(!=)S2883('*')S3026(&&)S3168 V2140(c)S2210(!=)S2326(EOF)S2542(\))S3288 V2040(;)S2168(/*)S2271(eat)S2414(up)S2539(text)S2715(of)S2824(comment)S3223(*/)S3528 V1940(if)S2027(\()S2086(c)S2156(==)S2295('*')S2438(\))S3648 V2040({)S3768 V2040(while)S2289(\()S2348(\(c)S2452(=)S(input\(\)\))308 2534 A2867(==)S3006('*')S3149(\))S3888 V2140(;)S4008 V2040(if)S2127(\()S2186(c)S2256(==)S2395('/')S2516(\))S4128 V2140(break;)S2492(/*)S(found)234 2595 A2854(the)S3002(end)S3172(*/)S4248 V2040(})S4488 V1940(if)S2027(\()S2086(c)S2156(==)S2295(EOF)S2511(\))S4608 V2040({)S4728 V2040(error\()S2296("EOF)S2553(in)S2656(comment")S3096(\);)S4848 V2040(break;)S4968 V2040(})S5088 V1940(})S5208 V1840(})S5448 V1440(\(Note)S1704(that)S1889(if)S1985(the)S2142(scanner)S2484(is)S2585(compiled)S2993(using)S10 B3245(C++,)S10 R3492(then)S10 B(input\(\))298 3700 A10 R4033(is)S4135(instead)S4455(referred)S4811(to)S4924(as)S10 B5043(yyin-)S5568 V(put\(\),)239 1440 A10 R1704(in)S1807(order)S2045(to)S2148(avoid)S2396(a)S2466(name)S2709(clash)S2941(with)S3145(the)S10 B3293(C++)S10 R3505(stream)S3799(by)S3924(the)S4072(name)S4315(of)S10 I(input.\))265 4424 A5736 V10 R1080(-)S10 B1440(yyterminate\(\))S10 R2056(can)S2223(be)S2346(used)S2558(in)S2664(lieu)S2843(of)S2955(a)S3028(return)S3297(statement)S3711(in)S3817(an)S3940(action.)S4264(It)S4354(terminates)S4802(the)S4953(scanner)S5856 V1440(and)S1618(returns)S1931(a)S2008(0)S2090(to)S2200(the)S2355(scanner's)S2768(caller,)S3050(indicating)S3484("all)S(done".)261 3658 A3976(Subsequent)S4471(calls)S4688(to)S4798(the)S4953(scanner)S5976 V(will)157 1440 A1640(immediately)S2186(return)S2470(unless)S(preceded)364 2764 A3171(by)S3314(a)S3402(call)S3591(to)S10 B(yyrestart\(\))460 3712 A10 R4215(\(see)S4421(below\).)S4795(By)S4956(default,)S6096 V10 B1440(yyterminate\(\))S10 R2068(is)S2174(also)S2375(called)S2655(when)S2912(an)S3045(end-of-\256le)S3509(is)S(encountered.)517 3614 A4194(It)S4294(is)S4399(a)S4482(macro)S4772(and)S4955(may)S5166(be)S6216 V1440(rede\256ned.)S6384 V9 R720(T)S722(TH)S780(HE)S848(E)S944(G)S946(GE)S1014(EN)S1072(NE)S1140(ER)S1198(RA)S1260(AT)S1328(TE)S1386(ED)S1444(D)S1550(S)S1552(SC)S1604(CA)S1666(AN)S1734(NN)S1802(NE)S1870(ER)S1928(R)S6504 V10 R1080(The)S1269(output)S1557(of)S10 I1673(\257ex)S10 R1845(is)S1944(the)S2099(\256le)S10 B2260(lex.yy.c,)S10 R2635(which)S2913(contains)S3280(the)S3435(scanning)S3824(routine)S10 B4142(yylex\(\),)S10 R4491(a)S4569(number)S4909(of)S5026(tables)S6624 V1080(used)S1296(by)S1428(it)S1516(for)S1666(matching)S2072(tokens,)S2391(and)S2567(a)S2643(number)S2981(of)S(auxiliary)358 3096 A3485(routines)S3840(and)S4016(macros.)S4388(By)S4536(default,)S10 B4872(yylex\(\))S10 R5194(is)S6744 V1080(declared)S1447(as)S1556(follows:)S6984 V1180(int)S1311(yylex\(\))S7104 V1280({)S7224 V(...)75 1280 A1380(various)S(de\256nitions)424 1701 A2150(and)S2320(the)S2468(actions)S2778(in)S2881(here)S(...)75 3080 A7344 V1280(})S7903 V720(September)S1176(13,)S(1996)200 1326 A2681(\()S2723(26)S2848(May)S(1990)200 3057 A3265(\))S4990(Page)S

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -