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

📄 flexdoc.1

📁 操作系统设计与实现源码
💻 1
📖 第 1 页 / 共 5 页
字号:
5211(8)S8143 VEP%%Page: 9 9BP/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(\(If)102 1080 A(your)184 1213 A1428(environment)S(supports)340 1967 A2339(function)S2706(prototypes,)S3187(then)S3392(it)S(will)157 3480 A3669(be)S3796("int)S3975(yylex\()S4264(void)S4474(\)".\))S4665(This)S(de\256nition)385 4876 A1080 V1080(may)S1278(be)S1398(changed)S1758(by)S1883(rede\256ning)S2316(the)S2464("YY_DECL")S3031(macro.)S3358(For)S3523(example,)S(you)150 3914 A4089(could)S4337(use:)S1320 V(#undef)279 1180 A1484(YY_DECL)S1440 V1180(#de\256ne)S1501(YY_DECL)S1986(\257oat)S2190(lexscan\()S2551(a,)S2646(b)S2721(\))S2780(\257oat)S2984(a,)S3079(b;)S1680 V1080(to)S1194(give)S1403(the)S1562(scanning)S1955(routine)S2276(the)S2435(name)S10 I2690(lexscan,)S10 R3054(returning)S3460(a)S3542(\257oat,)S3783(and)S3965(taking)S4253(two)S4441(\257oats)S4696(as)S4817(arguments.)S1800 V1080(Note)S1315(that)S1505(if)S(you)150 1606 A1795(give)S2007(arguments)S2465(to)S2582(the)S2743(scanning)S3138(routine)S3461(using)S3716(a)S(K&R-style/non-prototyped)1089 3799 A4926(function)S1920 V1080(declaration,)S(you)150 1578 A1753(must)S1973(terminate)S2379(the)S(de\256nition)385 2527 A2937(with)S3141(a)S3211(semi-colon)S3683(\(;\).)S2088 V1080(Whenever)S10 B1524(yylex\(\))S10 R1845(is)S1942(called,)S2238(it)S2324(scans)S2572(tokens)S2864(from)S3090(the)S3243(global)S(input)206 3524 A3760(\256le)S10 I3920(yyin)S10 R4119(\(which)S4430(defaults)S4780(to)S4889(stdin\).)S5199(It)S2208 V1080(continues)S(until)184 1491 A1701(it)S1783(either)S(reaches)303 2039 A2368(an)S2489(end-of-\256le)S2941(\(at)S3074(which)S3346(point)S3578(it)S3660(returns)S3966(the)S4115(value)S4359(0\))S4468(or)S4577(one)S4747(of)S4856(its)S4976(actions)S2328 V1080(executes)S1454(a)S10 I1526(return)S10 R1804(statement.)S2267(In)S2378(the)S2528(former)S2830(case,)S3056(when)S3302(called)S3571(again)S3817(the)S3968(scanner)S(will)157 4304 A4489(immediately)S5020(return)S2448 V1080(unless)S10 B(yyrestart\(\))460 1371 A10 R1871(is)S1977(called)S2257(to)S2374(point)S10 I2619(yyin)S10 R2826(at)S2938(the)S3100(new)S(input)206 3307 A3552(\256le.)S3770(\()S10 B(yyrestart\(\))460 3843 A10 R4342(takes)S4588(one)S4772(argument,)S5216(a)S2568 V10 B1080(FILE)S1350(*)S10 R1435(pointer.\))S1839(In)S1958(the)S2116(latter)S2359(case)S2568(\(i.e.,)S2785(when)S3038(an)S3168(action)S3449(executes)S3831(a)S3911(return\),)S4246(the)S4404(scanner)S4748(may)S4957(then)S5166(be)S2688 V1080(called)S1346(again)S1589(and)S1759(it)S(will)157 1840 A2022(resume)S2338(scanning)S2720(where)S2992(it)S3073(left)S3233(off.)S2856 V1080(By)S1224(default)S1531(\(and)S1737(for)S1883(purposes)S2268(of)S2380(ef\256ciency\),)S2865(the)S3016(scanner)S3352(uses)S3553(block-reads)S4051(rather)S4315(than)S4516(simple)S10 I4812(getc\(\))S10 R5076(calls)S2976 V1080(to)S1196(read)S1408(characters)S1856(from)S10 I2090(yyin.)S10 R2321(The)S2515(nature)S2804(of)S2925(how)S3135(it)S3228(gets)S3427(its)S(input)206 3559 A3802(can)S3979(be)S4111(controlled)S4556(by)S4693(rede\256ning)S5138(the)S3096 V10 B1080(YY_INPUT)S10 R1622(macro.)S1957(YY_INPUT's)S(calling)274 2557 A2864(sequence)S3266(is)S3366("YY_INPUT\(buf,result,max_size\)".)S4881(Its)S5015(action)S3216 V1080(is)S1177(to)S(place)213 1285 A1528(up)S1658(to)S10 I1766(max_size)S10 R2165(characters)S2605(in)S2713(the)S2866(character)S3267(array)S10 I3505(buf)S10 R3663(and)S3838(return)S4109(in)S4217(the)S4369(integer)S4678(variable)S10 I5032(result)S3336 V10 R1080(either)S1340(the)S1494(number)S1832(of)S1947(characters)S2388(read)S2593(or)S2708(the)S2862(constant)S3228(YY_NULL)S3725(\(0)S3840(on)S3971(Unix)S4203(systems\))S4586(to)S4695(indicate)S5045(EOF.)S3456 V1080(The)S1262(default)S1567(YY_INPUT)S2086(reads)S2324(from)S2545(the)S2693(global)S2969(\256le-pointer)S3442("yyin".)S3624 V1080(A)S1178(sample)S(rede\256nition)464 1488 A1977(of)S2086(YY_INPUT)S2605(\(in)S2742(the)S(de\256nitions)424 2890 A3339(section)S3649(of)S3758(the)S(input)206 3906 A4137(\256le\):)S3864 V1180(%{)S3984 V(#undef)279 1180 A1484(YY_INPUT)S4104 V1180(#de\256ne)S1501(YY_INPUT\(buf,result,max_size\))S2876(\\)S4224 V1280({)S1353(\\)S4344 V1280(int)S1411(c)S1481(=)S(getchar\(\);)393 1563 A1981(\\)S4464 V1280(result)S1529(=)S1611(\(c)S1715(==)S1854(EOF\))S2104(?)S2174(YY_NULL)S2665(:)S2718(\(buf[0])S3029(=)S3111(c,)S3206(1\);)S3343(\\)S4584 V1280(})S4704 V1180(%})S4944 V1080(This)S(de\256nition)385 1284 A(will)157 1694 A1876(change)S2186(the)S(input)206 2334 A2565(processing)S3020(to)S3123(occur)S3372(one)S3542(character)S3938(at)S4036(a)S4106(time.)S5112 V1080(You)S1282(also)S1473(can)S1643(add)S1818(in)S1926(things)S2201(like)S2382(keeping)S2730(track)S2962(of)S3076(the)S(input)206 3229 A3465(line)S3646(number)S3983(this)S4158(way;)S4384(but)S(don't)212 4542 A4784(expect)S(your)184 5077 A5232 V1080(scanner)S1413(to)S1516(go)S1641(very)S1845(fast.)S5400 V1080(When)S1360(the)S1523(scanner)S(receives)331 1871 A2242(an)S2377(end-of-\256le)S2843(indication)S3285(from)S3521(YY_INPUT,)S4080(it)S4176(then)S4390(checks)S4705(the)S10 B4869(yywrap\(\))S5520 V10 R1080(function.)S1496(If)S10 B1595(yywrap\(\))S10 R2018(returns)S2329(false)S2551(\(zero\),)S2849(then)S3053(it)S3140(is)S3238(assumed)S3615(that)S3797(the)S3951(function)S4317(has)S(gone)195 4482 A4708(ahead)S4974(and)S5149(set)S5640 V1080(up)S10 I1217(yyin)S10 R1422(to)S1538(point)S1782(to)S1898(another)S(input)206 2238 A2482(\256le,)S2674(and)S2857(scanning)S3252(continues.)S3725(If)S3831(it)S3925(returns)S4243(true)S(\(non-zero\),)451 4438 A4927(then)S5138(the)S5760 V1080(scanner)S1413(terminates,)S1883(returning)S2277(0)S2352(to)S2455(its)S2575(caller.)S5928 V1080(The)S1262(default)S10 B1567(yywrap\(\))S10 R1984(always)S2289(returns)S2594(1.)S2719(Presently,)S3145(to)S3249(rede\256ne)S3600(it)S(you)150 3682 A3858(must)S4079(\256rst)S("#undef)320 4262 A4608(yywrap",)S5002(as)S5112(it)S5194(is)S6048 V1080(currently)S1481(implemented)S2043(as)S2164(a)S2246(macro.)S2585(As)S2734(indicated)S3140(by)S3277(the)S3437(hedging)S3797(in)S3912(the)S4072(previous)S4455(sentence,)S4864(it)S4957(may)S5166(be)S6168 V1080(changed)S1440(to)S1543(a)S1613(true)S1795(function)S2155(in)S2258(the)S2406(near)S2605(future.)S6336 V1080(The)S1269(scanner)S1609(writes)S1888(its)S10 B2015(ECHO)S10 R2343(output)S2631(to)S2741(the)S10 I2896(yyout)S10 R3147(global)S3431(\(default,)S(stdout\),)304 3803 A4140(which)S4419(may)S4625(be)S4753(rede\256ned)S5161(by)S6456 V1080(the)S1228(user)S1421(simply)S1719(by)S1844(assigning)S2248(it)S2329(to)S2432(some)S2669(other)S10 B2901(FILE)S10 R3161(pointer.)S6624 V9 R720(S)S722(ST)S774(TA)S832(AR)S900(RT)S962(T)S1058(C)S1060(CO)S1122(ON)S1190(ND)S1258(DI)S1326(IT)S1359(TI)S1417(IO)S1450(ON)S1518(NS)S1586(S)S6744 V10 I1080(\257ex)S10 R1252(provides)S1630(a)S1707(mechanism)S2197(for)S(conditionally)530 2348 A2911(activating)S3341(rules.)S3620(Any)S3826(rule)S4016(whose)S4306(pattern)S4619(is)S4719(pre\256xed)S5082(with)S6864 V1080("<sc>")S(will)157 1385 A1567(only)S1770(be)S1890(active)S2156(when)S2399(the)S2547(scanner)S2880(is)S2972(in)S3075(the)S3223(start)S(condition)379 3422 A3826(named)S4119("sc".)S4360(For)S4525(example,)S7104 V1180(<STRING>[\303"]*)S2052({)S2125(/*)S2228(eat)S2371(up)S2496(the)S2644(string)S(body)200 2898 A(...)75 3123 A3223(*/)S7224 V(...)75 1480 A7344 V1480(})S7903 V720(Page)S941(9)S2681(\()S2723(26)S2848(May)S(1990)200 3057 A3265(\))S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Page: 10 10BP/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(will)157 1080 A1262(be)S1382(active)S1648(only)S1851(when)S2094(the)S2242(scanner)S2575(is)S2667(in)S2770(the)S2918("STRING")S3390(start)S(condition,)404 3589 A4018(and)S1200 V(<INITIAL,STRING,QUOTE>\\.)1297 1180 A2677({)S2750(/*)S2853(handle)S3146(an)S3266(escape)S(...)75 3560 A3660(*/)S1320 V(...)75 1480 A1440 V1480(})S1680 V(will)157 1080 A1262(be)S1382(active)S1648(only)S1851(when)S2094(the)S2242(current)S2553(start)S(condition)379 2752 A3156(is)S3248(either)S3503("INITIAL",)S4007("STRING",)S4504(or)S("QUOTE".)450 4613 A1848 V1080(Start)S(conditions)418 1300 A1747(are)S1901(declared)S2273(in)S2381(the)S(de\256nitions)424 2534 A2988(\(\256rst\))S3243(section)S3558(of)S3672(the)S(input)206 3825 A4061(using)S4308(unindented)S4784(lines)S5004(begin-)S1968 V1080(ning)S1286(with)S1493(either)S10 B1751(%s)S10 R1918(or)S10 B2030(%x)S10 R2208(followed)S2594(by)S2721(a)S2793(list)S2943(of)S3054(names.)S3388(The)S3572(former)S3874(declares)S10 I4232(inclusive)S10 R4617(start)S(conditions,)443 4818 A2088 V1080(the)S1235(latter)S10 I(exclusive)370 1475 A10 R1877(start)S(conditions.)443 2083 A2584(A)S2690(start)S(condition)379 2897 A3309(is)S3409(activated)S3806(using)S4056(the)S10 B4212(BEGIN)S10 R4569(action.)S(Until)207 4898 A5138(the)S2208 V1080(next)S10 B1283(BEGIN)S10 R1636(action)S1911(is)S2007(executed,)S2419(rules)S2644(with)S2852(the)S3004(given)S3256(start)S(condition)379 3459 A(will)157 3867 A4053(be)S4177(active)S4447(and)S4621(rules)S4846(with)S5054(other)S2328 V1080(start)S(conditions)418 1281 A(will)157 1726 A1910(be)S2032(inactive.)S2428(If)S2523(the)S2673(start)S(condition)379 2874 A3280(is)S10 I3374(inclusive,)S10 R3784(then)S3984(rules)S4207(with)S4413(no)S4540(start)S(conditions)418 4742 A5188(at)S2448 V1080(all)S(will)157 1209 A1394(also)S1584(be)S1707(active.)S2026(If)S2122(it)S2206(is)S10 I(exclusive,)395 2301 A10 R2724(then)S10 I2924(only)S10 R3124(rules)S3347(quali\256ed)S3726(with)S3932(the)S4082(start)S(condition)379 4283 A(will)157 4689 A4873(be)S4995(active.)S2568 V1080(A)S1180(set)S1319(of)S1430(rules)S1653(contingent)S2104(on)S2231(the)S2381(same)S2615(exclusive)S3022(start)S(condition)379 3223 A3629(describe)S3992(a)S4065(scanner)S4401(which)S4675(is)S4770(independent)S2688 V1080(of)S1199(any)S1379(of)S1498(the)S1656(other)S1898(rules)S2129(in)S2241(the)S10 I2398(\257ex)S10 R(input.)231 2572 A(Because)336 2862 A3232(of)S3350(this,)S3554(exclusive)S3968(start)S(conditions)418 4176 A4628(make)S4880(it)S4970(easy)S5183(to)S2808 V1080(specify)S1405("mini-scanners")S2086(which)S2366(scan)S2579(portions)S2942(of)S3060(the)S(input)206 3217 A3457(that)S3642(are)S3800(syntactically)S4343(different)S4726(from)S4957(the)S5115(rest)S2928 V1080(\(e.g.,)S1309(comments\).)S3096 V1080(If)S1177(the)S1329(distinction)S1782(between)S2148(inclusive)S2541(and)S2716(exclusive)S3126(start)S(conditions)418 3330 A3778(is)S(still)151 3875 A4056(a)S(little)185 4131 A4346(vague,)S4641(here's)S4918(a)S4993(simple)S3216 V1080(example)S(illustrating)436 1446 A1907(the)S(connection)441 2055 A2521(between)S2882(the)S3030(two.)S3256(The)S3438(set)S3575(of)S3684(rules:)S3456 V1180(%s)S1328(example)S3576 V1180(%%)S3696 V1180(<example>foo)S2044(/*)S2147(do)S2272(something)S2715(*/)S3936 V1080(is)S1172(equivalent)S1616(to)S4176 V1180(%x)S1339(example)S4296 V1180(%%)S4416 V1180(<INITIAL,example>foo)S2241(/*)S2344(do)S2469(something)S2912(*/)S4704 V1080(The)S1262(default)S1567(rule)S1749(\(to)S10 B1886(ECHO)S10 R2207(any)S2377(unmatched)S2843(character\))S3273(remains)S3617(active)S3883(in)S3986(start)S(conditions.)443 4185 A4872 V10 B1080(BEGIN\(0\))S10 R1556(returns)S1870(to)S1982(the)S2139(original)S2486(state)S2705(where)S2986(only)S3198(the)S3355(rules)S3586(with)S3800(no)S3935(start)S(conditions)418 4144 A4597(are)S4756(active.)S5082(This)S4992 V1080(state)S1300(can)S1475(also)S1672(be)S1802(referred)S2158(to)S2271(as)S2390(the)S(start-condition)587 2548 A3170("INITIAL",)S3683(so)S10 B3806(BEGIN\(INITIAL\))S10 R4629(is)S4730(equivalent)S5183(to)S5112 V10 B1080(BEGIN\(0\).)S10 R1575(\(The)S1794(parentheses)S(around)279 2

⌨️ 快捷键说明

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