📄 flexdoc.1
字号:
1708(pattern)S2017(therefore)S2411(matches)S10 I2770(either)S10 R3034(the)S3186(string)S3444("foo")S10 I3689(or)S10 R3807(the)S3959(string)S4216("ba")S4421(followed)S4807(by)S4935(zero-or-)S2160 V1080(more)S1312(r's.)S1494(To)S1631(match)S1902("foo")S2143(or)S2252(zero-or-more)S2810("bar"'s,)S3144(use:)S2400 V1180(foo|\(bar\)*)S2640 V1080(and)S1250(to)S1353(match)S1624(zero-or-more)S2182("foo"'s-or-"bar"'s:)S2880 V1180(\(foo|bar\)*)S3168 V1080(Some)S1334(notes)S1571(on)S1696(patterns:)S3336 V1080(-)S1440(A)S1551(negated)S1902(character)S2311(class)S2545(such)S2767(as)S2889(the)S3050(example)S3429("[\303A-Z]")S(above)240 3820 A10 I(will)151 4098 A4287(match)S4571(a)S4659(newline)S10 R5010(unless)S3456 V1440("\\n")S1647(\(or)S1812(an)S1954(equivalent)S2420(escape)S2736(sequence\))S3186(is)S3300(one)S3492(of)S3623(the)S3793(characters)S(explicitly)380 4250 A4677(present)S5014(in)S5138(the)S3576 V1440(negated)S1786(character)S2190(class)S2420(\(e.g.,)S2658("[\303A-Z\\n]"\).)S3207(This)S3420(is)S3521(unlike)S3806(how)S4013(many)S4270(other)S4511(regular)S4831(expression)S3696 V1440(tools)S1695(treat)S1935(negated)S2308(character)S2739(classes,)S3104(but)S3292(unfortunately)S3894(the)S4076(inconsistency)S4682(is)S4808(historically)S3816 V1440(entrenched.)S1977(Matching)S2407(newlines)S2810(means)S3112(that)S3308(a)S3398(pattern)S3724(like)S3921([\303"]*)S4160(can)S4346(match)S4638(an)S4779(entire)S(input)206 5055 A3936 V1440(\(over\257owing)S1985(the)S2133(scanner's)S(input)206 2539 A2770(buffer\))S3076(unless)S3352(there's)S3652(another)S(quote)223 3979 A4227(in)S4330(the)S(input.)231 4478 A4104 V1080(-)S1440(A)S1544(rule)S1732(can)S1903(have)S2124(at)S2228(most)S2454(one)S2631(instance)S2993(of)S(trailing)291 3109 A3432(context)S3760(\(the)S3949('/')S4077(operator)S4445(or)S4561(the)S4716('$')S4866(operator\).)S4224 V1440(The)S1626(start)S(condition,)404 1828 A('\303',)127 2260 A2415(and)S2588("<<EOF>>")S3117(patterns)S3464(can)S3632(only)S3838(occur)S4090(at)S4191(the)S4342(beginning)S4771(of)S4883(a)S4956(pattern,)S4344 V1440(and,)S1643(as)S1760(well)S1967(as)S2084(with)S2296('/')S2425(and)S2603('$',)S(cannot)268 2779 A3080(be)S(grouped)329 3208 A3570(inside)S3843(parentheses.)S4396(A)S('\303')102 4502 A4637(which)S4916(does)S5133(not)S4464 V1440(occur)S1691(at)S1791(the)S1941(beginning)S2369(of)S2480(a)S2552(rule)S2736(or)S2847(a)S2919('$')S3064(which)S3337(does)S3548(not)S3703(occur)S3954(at)S4054(the)S4204(end)S4376(of)S4487(a)S4559(rule)S4743(loses)S4971(its)S5093(spe-)S4584 V1440(cial)S1611(properties)S2039(and)S2209(is)S2301(treated)S2601(as)S2710(a)S2780(normal)S3090(character.)S4752 V1440(The)S1622(following)S2038(are)S(illegal:)280 2187 A4992 V1540(foo/bar$)S5112 V1540(<sc1>foo<sc2>bar)S5352 V1440(Note)S1661(that)S1837(the)S1985(first)S2173(of)S2282(these,)S2539(can)S2704(be)S(written)286 2824 A3135("foo/bar\\n".)S5520 V1440(The)S1622(following)S(will)157 2038 A2220(result)S2469(in)S2572('$')S2715(or)S('\303')102 2824 A2951(being)S3199(treated)S3499(as)S3608(a)S3678(normal)S3988(character:)S5760 V1540(foo|\(bar$\))S5880 V1540(foo|\303bar)S6120 V1440(If)S1540(what's)S1841(wanted)S2164(is)S2263(a)S2340("foo")S2588(or)S2704(a)S(bar-followed-by-a-newline,)1112 2781 A3925(the)S4080(following)S4503(could)S4759(be)S4887(used)S5104(\(the)S6240 V1440(special)S1745('|')S1858(action)S2129(is)S2221(explained)S2637(below\):)S6480 V1540(foo)S1824(|)S6600 V1540(bar$)S1844(/*)S1947(action)S2218(goes)S2427(here)S2626(*/)S6840 V1440(A)S1538(similar)S1843(trick)S(will)157 2053 A2235(work)S2467(for)S2610(matching)S3009(a)S3079(foo)S3238(or)S3347(a)S3417(bar-at-the-beginning-of-a-line.)S7008 V9 R720(H)S722(HO)S790(OW)S858(W)S984(T)S986(TH)S1044(HE)S1112(E)S1208(I)S1210(IN)S1243(NP)S1311(PU)S1363(UT)S1431(T)S1527(I)S1529(IS)S1562(S)S1652(M)S1654(MA)S1736(AT)S1804(TC)S1862(CH)S1924(HE)S1992(ED)S2050(D)S7128 V10 R1080(When)S1349(the)S1501(generated)S1922(scanner)S2259(is)S2355(run,)S2543(it)S2628(analyzes)S3004(its)S(input)206 3128 A(looking)306 3363 A3698(for)S3845(strings)S4142(which)S4417(match)S4692(any)S4866(of)S4979(its)S5104(pat-)S7248 V1080(terns.)S1352(If)S1446(it)S1528(finds)S1755(more)S1988(than)S2186(one)S2356(match,)S2652(it)S2733(takes)S2965(the)S3113(one)S3283(matching)S3682(the)S3830(most)S4050(text)S4226(\(for)S(trailing)291 4403 A4719(context)S5040(rules,)S7368 V1080(this)S1252(includes)S1614(the)S1764(length)S2042(of)S2153(the)S(trailing)291 2303 A2621(part,)S2830(even)S(though)278 3047 A3352(it)S(will)157 3435 A3619(then)S3819(be)S3941(returned)S4305(to)S4411(the)S(input\).)265 4562 A4880(If)S4976(it)S5060(finds)S7488 V1080(two)S1256(or)S1365(more)S1597(matches)S1952(of)S2061(the)S2209(same)S2441(length,)S2742(the)S2890(rule)S3072(listed)S3315(first)S3503(in)S3606(the)S10 I3754(flex)S10 R(input)206 3925 A4156(file)S4316(is)S4408(chosen.)S7903 V720(Page)S941(5)S2681(\()S2723(26)S2848(May)S(1990)200 3057 A3265(\))S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Page: 6 6BP/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 V1080(Once)S1321(the)S1472(match)S1746(is)S1841(determined,)S2347(the)S2499(text)S(corresponding)575 2679 A3283(to)S3390(the)S3542(match)S3817(\(called)S4121(the)S10 I4273(token\))S10 R4554(is)S4650(made)S4897(available)S1080 V1080(in)S1215(the)S1395(global)S1703(character)S2131(pointer)S10 B2473(yytext,)S10 R2818(and)S3020(its)S3172(length)S3480(in)S3615(the)S3794(global)S4101(integer)S10 B4437(yyleng.)S10 R4797(The)S10 I5010(action)S1200 V10 R(corresponding)575 1080 A1683(to)S1789(the)S1941(matched)S2311(pattern)S2620(is)S2716(then)S2918(executed)S3305(\(a)S3413(more)S3649(detailed)S3997(description)S4473(of)S4586(actions)S4900(follows\),)S1320 V1080(and)S1250(then)S1448(the)S1596(remaining)S(input)206 2029 A2260(is)S2352(scanned)S2701(for)S2844(another)S3171(match.)S1488 V1080(If)S1185(no)S1322(match)S1605(is)S(found,)259 1709 A2005(then)S2215(the)S10 I2375(default)S2691(rule)S10 R2890(is)S2994(executed:)S3418(the)S3579(next)S3790(character)S4199(in)S4315(the)S(input)206 4476 A4720(is)S4825(considered)S1608 V1080(matched)S1446(and)S1616(copied)S1909(to)S2012(the)S2160(standard)S2526(output.)S2857(Thus,)S3108(the)S3256(simplest)S3616(legal)S10 I3837(flex)S10 R(input)206 4008 A4239(is:)S1848 V1180(%%)S2088 V1080(which)S1351(generates)S1757(a)S1827(scanner)S2160(that)S2336(simply)S2634(copies)S2916(its)S(input)206 3036 A3267(\(one)S3471(character)S3867(at)S3965(a)S4035(time\))S4273(to)S4376(its)S4496(output.)S2256 V9 R720(A)S722(AC)S790(CT)S852(TI)S910(IO)S943(ON)S1011(NS)S1079(S)S2376 V10 R1080(Each)S1310(pattern)S1618(in)S1724(a)S1797(rule)S1982(has)S2144(a)S(corresponding)575 2217 A2820(action,)S3119(which)S3393(can)S3561(be)S3684(any)S3857(arbitrary)S4234(C)S4330(statement.)S4795(The)S4981(pattern)S2496 V1080(ends)S1294(at)S1397(the)S1550(first)S(non-escaped)503 1743 A(whitespace)448 2276 A2754(character;)S3183(the)S3336(remainder)S3775(of)S3889(the)S4041(line)S4221(is)S4317(its)S4441(action.)S4766(If)S4863(the)S5015(action)S2616 V1080(is)S1180(empty,)S1489(then)S1695(when)S1946(the)S2102(pattern)S2415(is)S2515(matched)S2889(the)S(input)206 3045 A3284(token)S3540(is)S3640(simply)S3946(discarded.)S4415(For)S4588(example,)S4987(here)S5194(is)S2736 V1080(the)S1228(specification)S1768(for)S1911(a)S1981(program)S2347(which)S2618(deletes)S2923(all)S3049(occurrences)S3556(of)S3665("zap)S3871(me")S4060(from)S4281(its)S(input:)234 4401 A2976 V1180(%%)S3096 V1180("zap)S1386(me")S3336 V1080(\(It)S(will)157 1211 A(copy)195 1403 A1633(all)S1769(other)S2011(characters)S2456(in)S2569(the)S(input)206 2727 A2968(to)S3082(the)S3241(output)S3533(since)S3776(they)S(will)157 3985 A4178(be)S4309(matched)S4686(by)S4822(the)S4981(default)S3456 V1080(rule.\))S3624 V1080(Here)S1303(is)S1396(a)S1467(program)S1834(which)S2106(compresses)S(multiple)335 2596 A2957(blanks)S3245(and)S3417(tabs)S3606(down)S3856(to)S3961(a)S4033(single)S4300(blank,)S4575(and)S4747(throws)S5048(away)S3744 V(whitespace)448 1080 A(found)234 1553 A1812(at)S1910(the)S2058(end)S2228(of)S2337(a)S2407(line:)S3984 V1180(%%)S4104 V1180([)S1239(\\t]+)S1586(putchar\()S1947(')S2006(')S2065(\);)S4224 V1180([)S1239(\\t]+$)S1611(/*)S(ignore)257 1714 A1996(this)S2166(token)S2414(*/)S4512 V1080(If)S1185(the)S1345(action)S1628(contains)S2000(a)S2082('{',)S2260(then)S2470(the)S2630(action)S2913(spans)S(till)112 3173 A3322(the)S3482(balancing)S3910('}')S4063(is)S(found,)259 4167 A4463(and)S4645(the)S4805(action)S5088(may)S4632 V1080(cross)S(multiple)335 1322 A1692(lines.)S10 I1967(flex)S10 R(knows)262 2148 A(about)223 2445 A2703(C)S2805(strings)S3107(and)S3286(comments)S3733(and)S3912(won't)S4181(be)S4310(fooled)S4601(by)S(braces)258 4735 A(found)234 5027 A4752 V1080(within)S1366(them,)S1621(but)S1778(also)S1969(allows)S2261(actions)S2575(to)S2682(begin)S2934(with)S10 B3142(%{)S10 R3311(and)S(will)157 3485 A3671(consider)S4041(the)S4193(action)S4468(to)S4575(be)S4699(all)S4829(the)S4981(text)S5161(up)S4872 V1080(to)S1183(the)S1331(next)S10 B1529(%})S10 R1694(\(regardless)S2162(of)S2271(ordinary)S(braces)258 2637 A2920(inside)S3185(the)S3333(action\).)S5040 V1080(An)S1240(action)S1523(consisting)S1968(solely)S2246(of)S2368(a)S2451(vertical)S2792(bar)S2959(\('|'\))S3153(means)S3448("same)S3734(as)S3856(the)S4017(action)S4301(for)S4457(the)S4618(next)S4829(rule.")S5115(See)S5160 V1080(below)S1351(for)S1494(an)S(illustration.)461 1614 A5328 V1080(Actions)S1419(can)S1585(include)S1907(arbitrary)S2282(C)S2376(code,)S2618(including)S10 B3024(return)S10 R3332(statements)S3784(to)S3889(return)S4157(a)S4229(value)S4474(to)S4579(whatever)S4976(routine)S5448 V1080(called)S10 B1347(yylex\(\).)S10 R1689(Each)S1917(time)S10 B2122(yylex\(\))S10 R2439(is)S2532(called)S2799(it)S2881(continues)S3292(processing)S3748(tokens)S4035(from)S4256(where)S4528(it)S4609(last)S4774(left)S4934(off)S(until)184 5077 A5568 V1080(it)S1166(either)S(reaches)303 1426 A1759(the)S1912(end)S2087(of)S2201(the)S2354(file)S2519(or)S2633(executes)S3010(a)S3085(return.)S3406(Once)S3650(it)S(reaches)303 3737 A4071(an)S(end-of-file,)457 4197 A4685(however,)S5088(then)S5688 V1080(any)S1263(subsequent)S1747(call)S1931(to)S10 B2047(yylex\(\))S10 R(will)157 2376 A2571(simply)S2882(immediately)S3423(return,)S3727(unless)S10 B(yyrestart\(\))460 4016 A10 R4514(is)S4619(first)S4820(called)S5098(\(see)S5808 V1080(below\).)S5976 V1080(Actions)S1418(are)S1567(not)S1720(allowed)S2064(to)S2167(modify)S2482(yytext)S2758(or)S2867(yyleng.)S6144 V1080(There)S1341(are)S1490(a)S1560(number)S1892(of)S2001(special)S2306(directives)S2723(which)S2994(can)S3159(be)S3279(included)S3650(within)S3932(an)S4052(action:)S6312 V1080(-)S10 B1440(ECHO)S10 R1761(copies)S2043(yytext)S2319(to)S2422(the)S2570(scanner's)S2976(output.)S6480 V1080(-)S10 B1440(BEGIN)S10 R1789(followed)S2172(by)S2297(the)S2445(name)S2688(of)S2797(a)S2867(start)S(condition)379 3067 A(places)252 3472 A3750(the)S3899(scanner)S4233(in)S4337(the)S(corresponding)575 4486 A5087(start)S6600 V(condition)379 1440 A1844(\(see)S2032(below\).)S6768 V1080(-)S10 B1440(REJECT)S10 R1865(directs)S2162(the)S2313(scanner)S2649(to)S(proceed)319 2755 A3103(on)S3232(to)S3339(the)S("second)320 3491 A3840(best")S4072(rule)S4258(which)S4533(matched)S4903(the)S(input)206 5055 A6888 V1440(\(or)S1608(a)S1703(pre\256x)S1988(of)S2122(the)S(input\).)265 2295 A2635(The)S2841(rule)S3047(is)S3163(chosen)S3491(as)S3624(described)S(above)240 4059 A4348(in)S4475("How)S4761(the)S(Input)212 4933 A5194(is)S7008 V1440(Matched",)S1884(and)S10 B2055(yytext)S10 R2344(and)S10 B2515(yyleng)S10 R2820(set)S
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -