home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume23 / flex2.3 / part02 < prev    next >
SHell self-extracting ARchive  |  1990-10-10  |  54.3 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: SHell self-extracting ARchive (archive/shar).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 53 75 62 6a 65 63 74 3a | 20 20 76 32 33 69 30 33 |Subject:| v23i03|
|00000010| 38 3a 20 20 46 6c 65 78 | 2c 20 61 20 66 61 73 74 |8: Flex|, a fast|
|00000020| 20 6c 65 78 20 72 65 70 | 6c 61 63 65 6d 65 6e 74 | lex rep|lacement|
|00000030| 2c 20 50 61 72 74 30 32 | 2f 31 30 0a 4e 65 77 73 |, Part02|/10.News|
|00000040| 67 72 6f 75 70 73 3a 20 | 63 6f 6d 70 2e 73 6f 75 |groups: |comp.sou|
|00000050| 72 63 65 73 2e 75 6e 69 | 78 0a 41 70 70 72 6f 76 |rces.uni|x.Approv|
|00000060| 65 64 3a 20 72 73 61 6c | 7a 40 75 75 6e 65 74 2e |ed: rsal|z@uunet.|
|00000070| 55 55 2e 4e 45 54 0a 58 | 2d 43 68 65 63 6b 73 75 |UU.NET.X|-Checksu|
|00000080| 6d 2d 53 6e 65 66 72 75 | 3a 20 38 30 62 39 33 36 |m-Snefru|: 80b936|
|00000090| 33 37 20 66 66 64 66 33 | 31 62 34 20 32 31 62 35 |37 ffdf3|1b4 21b5|
|000000a0| 38 30 38 61 20 64 65 37 | 64 66 63 34 63 0a 0a 53 |808a de7|dfc4c..S|
|000000b0| 75 62 6d 69 74 74 65 64 | 2d 62 79 3a 20 56 65 72 |ubmitted|-by: Ver|
|000000c0| 6e 20 50 61 78 73 6f 6e | 20 3c 76 65 72 6e 40 63 |n Paxson| <vern@c|
|000000d0| 73 2e 63 6f 72 6e 65 6c | 6c 2e 65 64 75 3e 0a 50 |s.cornel|l.edu>.P|
|000000e0| 6f 73 74 69 6e 67 2d 6e | 75 6d 62 65 72 3a 20 56 |osting-n|umber: V|
|000000f0| 6f 6c 75 6d 65 20 32 33 | 2c 20 49 73 73 75 65 20 |olume 23|, Issue |
|00000100| 33 38 0a 41 72 63 68 69 | 76 65 2d 6e 61 6d 65 3a |38.Archi|ve-name:|
|00000110| 20 66 6c 65 78 32 2e 33 | 2f 70 61 72 74 30 32 0a | flex2.3|/part02.|
|00000120| 0a 23 21 20 2f 62 69 6e | 2f 73 68 0a 23 20 54 68 |.#! /bin|/sh.# Th|
|00000130| 69 73 20 69 73 20 61 20 | 73 68 65 6c 6c 20 61 72 |is is a |shell ar|
|00000140| 63 68 69 76 65 2e 20 20 | 52 65 6d 6f 76 65 20 61 |chive. |Remove a|
|00000150| 6e 79 74 68 69 6e 67 20 | 62 65 66 6f 72 65 20 74 |nything |before t|
|00000160| 68 69 73 20 6c 69 6e 65 | 2c 20 74 68 65 6e 20 66 |his line|, then f|
|00000170| 65 65 64 20 69 74 0a 23 | 20 69 6e 74 6f 20 61 20 |eed it.#| into a |
|00000180| 73 68 65 6c 6c 20 76 69 | 61 20 22 73 68 20 66 69 |shell vi|a "sh fi|
|00000190| 6c 65 22 20 6f 72 20 73 | 69 6d 69 6c 61 72 2e 20 |le" or s|imilar. |
|000001a0| 20 54 6f 20 6f 76 65 72 | 77 72 69 74 65 20 65 78 | To over|write ex|
|000001b0| 69 73 74 69 6e 67 20 66 | 69 6c 65 73 2c 0a 23 20 |isting f|iles,.# |
|000001c0| 74 79 70 65 20 22 73 68 | 20 66 69 6c 65 20 2d 63 |type "sh| file -c|
|000001d0| 22 2e 0a 23 20 54 68 65 | 20 74 6f 6f 6c 20 74 68 |"..# The| tool th|
|000001e0| 61 74 20 67 65 6e 65 72 | 61 74 65 64 20 74 68 69 |at gener|ated thi|
|000001f0| 73 20 61 70 70 65 61 72 | 65 64 20 69 6e 20 74 68 |s appear|ed in th|
|00000200| 65 20 63 6f 6d 70 2e 73 | 6f 75 72 63 65 73 2e 75 |e comp.s|ources.u|
|00000210| 6e 69 78 20 6e 65 77 73 | 67 72 6f 75 70 3b 0a 23 |nix news|group;.#|
|00000220| 20 73 65 6e 64 20 6d 61 | 69 6c 20 74 6f 20 63 6f | send ma|il to co|
|00000230| 6d 70 2d 73 6f 75 72 63 | 65 73 2d 75 6e 69 78 40 |mp-sourc|es-unix@|
|00000240| 75 75 6e 65 74 2e 75 75 | 2e 6e 65 74 20 69 66 20 |uunet.uu|.net if |
|00000250| 79 6f 75 20 77 61 6e 74 | 20 74 68 61 74 20 74 6f |you want| that to|
|00000260| 6f 6c 2e 0a 23 20 43 6f | 6e 74 65 6e 74 73 3a 20 |ol..# Co|ntents: |
|00000270| 20 43 4f 50 59 49 4e 47 | 20 66 6c 65 78 64 6f 63 | COPYING| flexdoc|
|00000280| 2e 31 2e 30 31 0a 23 20 | 57 72 61 70 70 65 64 20 |.1.01.# |Wrapped |
|00000290| 62 79 20 72 73 61 6c 7a | 40 6c 69 74 63 68 69 2e |by rsalz|@litchi.|
|000002a0| 62 62 6e 2e 63 6f 6d 20 | 6f 6e 20 57 65 64 20 4f |bbn.com |on Wed O|
|000002b0| 63 74 20 31 30 20 31 33 | 3a 32 33 3a 35 38 20 31 |ct 10 13|:23:58 1|
|000002c0| 39 39 30 0a 50 41 54 48 | 3d 2f 62 69 6e 3a 2f 75 |990.PATH|=/bin:/u|
|000002d0| 73 72 2f 62 69 6e 3a 2f | 75 73 72 2f 75 63 62 20 |sr/bin:/|usr/ucb |
|000002e0| 3b 20 65 78 70 6f 72 74 | 20 50 41 54 48 0a 65 63 |; export| PATH.ec|
|000002f0| 68 6f 20 49 66 20 74 68 | 69 73 20 61 72 63 68 69 |ho If th|is archi|
|00000300| 76 65 20 69 73 20 63 6f | 6d 70 6c 65 74 65 2c 20 |ve is co|mplete, |
|00000310| 79 6f 75 20 77 69 6c 6c | 20 73 65 65 20 74 68 65 |you will| see the|
|00000320| 20 66 6f 6c 6c 6f 77 69 | 6e 67 20 6d 65 73 73 61 | followi|ng messa|
|00000330| 67 65 3a 0a 65 63 68 6f | 20 27 20 20 20 20 20 20 |ge:.echo| ' |
|00000340| 20 20 20 20 22 73 68 61 | 72 3a 20 45 6e 64 20 6f | "sha|r: End o|
|00000350| 66 20 61 72 63 68 69 76 | 65 20 32 20 28 6f 66 20 |f archiv|e 2 (of |
|00000360| 31 30 29 2e 22 27 0a 69 | 66 20 74 65 73 74 20 2d |10)."'.i|f test -|
|00000370| 66 20 27 43 4f 50 59 49 | 4e 47 27 20 2d 61 20 22 |f 'COPYI|NG' -a "|
|00000380| 24 7b 31 7d 22 20 21 3d | 20 22 2d 63 22 20 3b 20 |${1}" !=| "-c" ; |
|00000390| 74 68 65 6e 20 0a 20 20 | 65 63 68 6f 20 73 68 61 |then . |echo sha|
|000003a0| 72 3a 20 57 69 6c 6c 20 | 6e 6f 74 20 63 6c 6f 62 |r: Will |not clob|
|000003b0| 62 65 72 20 65 78 69 73 | 74 69 6e 67 20 66 69 6c |ber exis|ting fil|
|000003c0| 65 20 5c 22 27 43 4f 50 | 59 49 4e 47 27 5c 22 0a |e \"'COP|YING'\".|
|000003d0| 65 6c 73 65 0a 20 20 65 | 63 68 6f 20 73 68 61 72 |else. e|cho shar|
|000003e0| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 27 |: Extrac|ting \"'|
|000003f0| 43 4f 50 59 49 4e 47 27 | 5c 22 20 5c 28 31 38 30 |COPYING'|\" \(180|
|00000400| 32 20 63 68 61 72 61 63 | 74 65 72 73 5c 29 0a 20 |2 charac|ters\). |
|00000410| 20 73 65 64 20 22 73 2f | 5e 58 2f 2f 22 20 3e 27 | sed "s/|^X//" >'|
|00000420| 43 4f 50 59 49 4e 47 27 | 20 3c 3c 27 45 4e 44 5f |COPYING'| <<'END_|
|00000430| 4f 46 5f 46 49 4c 45 27 | 0a 58 46 6c 65 78 20 63 |OF_FILE'|.XFlex c|
|00000440| 61 72 72 69 65 73 20 74 | 68 65 20 63 6f 70 79 72 |arries t|he copyr|
|00000450| 69 67 68 74 20 75 73 65 | 64 20 66 6f 72 20 42 53 |ight use|d for BS|
|00000460| 44 20 73 6f 66 74 77 61 | 72 65 2c 20 73 6c 69 67 |D softwa|re, slig|
|00000470| 68 74 6c 79 20 6d 6f 64 | 69 66 69 65 64 0a 58 62 |htly mod|ified.Xb|
|00000480| 65 63 61 75 73 65 20 69 | 74 20 6f 72 69 67 69 6e |ecause i|t origin|
|00000490| 61 74 65 64 20 61 74 20 | 74 68 65 20 4c 61 77 72 |ated at |the Lawr|
|000004a0| 65 6e 63 65 20 42 65 72 | 6b 65 6c 65 79 20 28 6e |ence Ber|keley (n|
|000004b0| 6f 74 20 4c 69 76 65 72 | 6d 6f 72 65 21 29 20 4c |ot Liver|more!) L|
|000004c0| 61 62 6f 72 61 74 6f 72 | 79 2c 0a 58 77 68 69 63 |aborator|y,.Xwhic|
|000004d0| 68 20 6f 70 65 72 61 74 | 65 73 20 75 6e 64 65 72 |h operat|es under|
|000004e0| 20 61 20 63 6f 6e 74 72 | 61 63 74 20 77 69 74 68 | a contr|act with|
|000004f0| 20 74 68 65 20 44 65 70 | 61 72 74 6d 65 6e 74 20 | the Dep|artment |
|00000500| 6f 66 20 45 6e 65 72 67 | 79 3a 0a 58 0a 58 09 43 |of Energ|y:.X.X.C|
|00000510| 6f 70 79 72 69 67 68 74 | 20 28 63 29 20 31 39 39 |opyright| (c) 199|
|00000520| 30 20 54 68 65 20 52 65 | 67 65 6e 74 73 20 6f 66 |0 The Re|gents of|
|00000530| 20 74 68 65 20 55 6e 69 | 76 65 72 73 69 74 79 20 | the Uni|versity |
|00000540| 6f 66 20 43 61 6c 69 66 | 6f 72 6e 69 61 2e 0a 58 |of Calif|ornia..X|
|00000550| 09 41 6c 6c 20 72 69 67 | 68 74 73 20 72 65 73 65 |.All rig|hts rese|
|00000560| 72 76 65 64 2e 0a 58 0a | 58 09 54 68 69 73 20 63 |rved..X.|X.This c|
|00000570| 6f 64 65 20 69 73 20 64 | 65 72 69 76 65 64 20 66 |ode is d|erived f|
|00000580| 72 6f 6d 20 73 6f 66 74 | 77 61 72 65 20 63 6f 6e |rom soft|ware con|
|00000590| 74 72 69 62 75 74 65 64 | 20 74 6f 20 42 65 72 6b |tributed| to Berk|
|000005a0| 65 6c 65 79 20 62 79 0a | 58 09 56 65 72 6e 20 50 |eley by.|X.Vern P|
|000005b0| 61 78 73 6f 6e 2e 0a 58 | 0a 58 09 54 68 65 20 55 |axson..X|.X.The U|
|000005c0| 6e 69 74 65 64 20 53 74 | 61 74 65 73 20 47 6f 76 |nited St|ates Gov|
|000005d0| 65 72 6e 6d 65 6e 74 20 | 68 61 73 20 72 69 67 68 |ernment |has righ|
|000005e0| 74 73 20 69 6e 20 74 68 | 69 73 20 77 6f 72 6b 20 |ts in th|is work |
|000005f0| 70 75 72 73 75 61 6e 74 | 0a 58 09 74 6f 20 63 6f |pursuant|.X.to co|
|00000600| 6e 74 72 61 63 74 20 6e | 6f 2e 20 44 45 2d 41 43 |ntract n|o. DE-AC|
|00000610| 30 33 2d 37 36 53 46 30 | 30 30 39 38 20 62 65 74 |03-76SF0|0098 bet|
|00000620| 77 65 65 6e 20 74 68 65 | 20 55 6e 69 74 65 64 20 |ween the| United |
|00000630| 53 74 61 74 65 73 0a 58 | 09 44 65 70 61 72 74 6d |States.X|.Departm|
|00000640| 65 6e 74 20 6f 66 20 45 | 6e 65 72 67 79 20 61 6e |ent of E|nergy an|
|00000650| 64 20 74 68 65 20 55 6e | 69 76 65 72 73 69 74 79 |d the Un|iversity|
|00000660| 20 6f 66 20 43 61 6c 69 | 66 6f 72 6e 69 61 2e 0a | of Cali|fornia..|
|00000670| 58 0a 58 09 52 65 64 69 | 73 74 72 69 62 75 74 69 |X.X.Redi|stributi|
|00000680| 6f 6e 20 61 6e 64 20 75 | 73 65 20 69 6e 20 73 6f |on and u|se in so|
|00000690| 75 72 63 65 20 61 6e 64 | 20 62 69 6e 61 72 79 20 |urce and| binary |
|000006a0| 66 6f 72 6d 73 20 61 72 | 65 20 70 65 72 6d 69 74 |forms ar|e permit|
|000006b0| 74 65 64 0a 58 09 70 72 | 6f 76 69 64 65 64 20 74 |ted.X.pr|ovided t|
|000006c0| 68 61 74 3a 20 28 31 29 | 20 73 6f 75 72 63 65 20 |hat: (1)| source |
|000006d0| 64 69 73 74 72 69 62 75 | 74 69 6f 6e 73 20 72 65 |distribu|tions re|
|000006e0| 74 61 69 6e 20 74 68 69 | 73 20 65 6e 74 69 72 65 |tain thi|s entire|
|000006f0| 0a 58 09 63 6f 70 79 72 | 69 67 68 74 20 6e 6f 74 |.X.copyr|ight not|
|00000700| 69 63 65 20 61 6e 64 20 | 63 6f 6d 6d 65 6e 74 2c |ice and |comment,|
|00000710| 20 61 6e 64 20 28 32 29 | 20 64 69 73 74 72 69 62 | and (2)| distrib|
|00000720| 75 74 69 6f 6e 73 20 69 | 6e 63 6c 75 64 69 6e 67 |utions i|ncluding|
|00000730| 0a 58 09 62 69 6e 61 72 | 69 65 73 20 64 69 73 70 |.X.binar|ies disp|
|00000740| 6c 61 79 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |lay the |followin|
|00000750| 67 20 61 63 6b 6e 6f 77 | 6c 65 64 67 65 6d 65 6e |g acknow|ledgemen|
|00000760| 74 3a 20 20 60 60 54 68 | 69 73 20 70 72 6f 64 75 |t: ``Th|is produ|
|00000770| 63 74 0a 58 09 69 6e 63 | 6c 75 64 65 73 20 73 6f |ct.X.inc|ludes so|
|00000780| 66 74 77 61 72 65 20 64 | 65 76 65 6c 6f 70 65 64 |ftware d|eveloped|
|00000790| 20 62 79 20 74 68 65 20 | 55 6e 69 76 65 72 73 69 | by the |Universi|
|000007a0| 74 79 20 6f 66 20 43 61 | 6c 69 66 6f 72 6e 69 61 |ty of Ca|lifornia|
|000007b0| 2c 0a 58 09 42 65 72 6b | 65 6c 65 79 20 61 6e 64 |,.X.Berk|eley and|
|000007c0| 20 69 74 73 20 63 6f 6e | 74 72 69 62 75 74 6f 72 | its con|tributor|
|000007d0| 73 27 27 20 69 6e 20 74 | 68 65 20 64 6f 63 75 6d |s'' in t|he docum|
|000007e0| 65 6e 74 61 74 69 6f 6e | 20 6f 72 20 6f 74 68 65 |entation| or othe|
|000007f0| 72 0a 58 09 6d 61 74 65 | 72 69 61 6c 73 20 70 72 |r.X.mate|rials pr|
|00000800| 6f 76 69 64 65 64 20 77 | 69 74 68 20 74 68 65 20 |ovided w|ith the |
|00000810| 64 69 73 74 72 69 62 75 | 74 69 6f 6e 20 61 6e 64 |distribu|tion and|
|00000820| 20 69 6e 20 61 6c 6c 20 | 61 64 76 65 72 74 69 73 | in all |advertis|
|00000830| 69 6e 67 0a 58 09 6d 61 | 74 65 72 69 61 6c 73 20 |ing.X.ma|terials |
|00000840| 6d 65 6e 74 69 6f 6e 69 | 6e 67 20 66 65 61 74 75 |mentioni|ng featu|
|00000850| 72 65 73 20 6f 72 20 75 | 73 65 20 6f 66 20 74 68 |res or u|se of th|
|00000860| 69 73 20 73 6f 66 74 77 | 61 72 65 2e 20 20 4e 65 |is softw|are. Ne|
|00000870| 69 74 68 65 72 20 74 68 | 65 0a 58 09 6e 61 6d 65 |ither th|e.X.name|
|00000880| 20 6f 66 20 74 68 65 20 | 55 6e 69 76 65 72 73 69 | of the |Universi|
|00000890| 74 79 20 6e 6f 72 20 74 | 68 65 20 6e 61 6d 65 73 |ty nor t|he names|
|000008a0| 20 6f 66 20 69 74 73 20 | 63 6f 6e 74 72 69 62 75 | of its |contribu|
|000008b0| 74 6f 72 73 20 6d 61 79 | 20 62 65 0a 58 09 75 73 |tors may| be.X.us|
|000008c0| 65 64 20 74 6f 20 65 6e | 64 6f 72 73 65 20 6f 72 |ed to en|dorse or|
|000008d0| 20 70 72 6f 6d 6f 74 65 | 20 70 72 6f 64 75 63 74 | promote| product|
|000008e0| 73 20 64 65 72 69 76 65 | 64 20 66 72 6f 6d 20 74 |s derive|d from t|
|000008f0| 68 69 73 20 73 6f 66 74 | 77 61 72 65 0a 58 09 77 |his soft|ware.X.w|
|00000900| 69 74 68 6f 75 74 20 73 | 70 65 63 69 66 69 63 20 |ithout s|pecific |
|00000910| 70 72 69 6f 72 20 77 72 | 69 74 74 65 6e 20 70 65 |prior wr|itten pe|
|00000920| 72 6d 69 73 73 69 6f 6e | 2e 0a 58 0a 58 09 54 48 |rmission|..X.X.TH|
|00000930| 49 53 20 53 4f 46 54 57 | 41 52 45 20 49 53 20 50 |IS SOFTW|ARE IS P|
|00000940| 52 4f 56 49 44 45 44 20 | 60 60 41 53 20 49 53 27 |ROVIDED |``AS IS'|
|00000950| 27 20 41 4e 44 20 57 49 | 54 48 4f 55 54 20 41 4e |' AND WI|THOUT AN|
|00000960| 59 20 45 58 50 52 45 53 | 53 20 4f 52 0a 58 09 49 |Y EXPRES|S OR.X.I|
|00000970| 4d 50 4c 49 45 44 20 57 | 41 52 52 41 4e 54 49 45 |MPLIED W|ARRANTIE|
|00000980| 53 2c 20 49 4e 43 4c 55 | 44 49 4e 47 2c 20 57 49 |S, INCLU|DING, WI|
|00000990| 54 48 4f 55 54 20 4c 49 | 4d 49 54 41 54 49 4f 4e |THOUT LI|MITATION|
|000009a0| 2c 20 54 48 45 20 49 4d | 50 4c 49 45 44 0a 58 09 |, THE IM|PLIED.X.|
|000009b0| 57 41 52 52 41 4e 54 49 | 45 53 20 4f 46 20 4d 45 |WARRANTI|ES OF ME|
|000009c0| 52 43 48 41 4e 54 41 42 | 49 4c 49 54 59 20 41 4e |RCHANTAB|ILITY AN|
|000009d0| 44 20 46 49 54 4e 45 53 | 53 20 46 4f 52 20 41 20 |D FITNES|S FOR A |
|000009e0| 50 41 52 54 49 43 55 4c | 41 52 0a 58 09 50 55 52 |PARTICUL|AR.X.PUR|
|000009f0| 50 4f 53 45 2e 0a 58 0a | 58 54 68 69 73 20 62 61 |POSE..X.|XThis ba|
|00000a00| 73 69 63 61 6c 6c 79 20 | 73 61 79 73 20 22 64 6f |sically |says "do|
|00000a10| 20 77 68 61 74 65 76 65 | 72 20 79 6f 75 20 70 6c | whateve|r you pl|
|00000a20| 65 61 73 65 20 77 69 74 | 68 20 74 68 69 73 20 73 |ease wit|h this s|
|00000a30| 6f 66 74 77 61 72 65 20 | 65 78 63 65 70 74 0a 58 |oftware |except.X|
|00000a40| 72 65 6d 6f 76 65 20 74 | 68 69 73 20 6e 6f 74 69 |remove t|his noti|
|00000a50| 63 65 20 6f 72 20 74 61 | 6b 65 20 61 64 76 61 6e |ce or ta|ke advan|
|00000a60| 74 61 67 65 20 6f 66 20 | 74 68 65 20 55 6e 69 76 |tage of |the Univ|
|00000a70| 65 72 73 69 74 79 27 73 | 20 28 6f 72 20 74 68 65 |ersity's| (or the|
|00000a80| 20 66 6c 65 78 0a 58 61 | 75 74 68 6f 72 73 27 29 | flex.Xa|uthors')|
|00000a90| 20 6e 61 6d 65 22 2e 0a | 58 0a 58 4e 6f 74 65 20 | name"..|X.XNote |
|00000aa0| 74 68 61 74 20 74 68 65 | 20 22 66 6c 65 78 2e 73 |that the| "flex.s|
|00000ab0| 6b 65 6c 22 20 73 63 61 | 6e 6e 65 72 20 73 6b 65 |kel" sca|nner ske|
|00000ac0| 6c 65 74 6f 6e 20 63 61 | 72 72 69 65 73 20 6e 6f |leton ca|rries no|
|00000ad0| 20 63 6f 70 79 72 69 67 | 68 74 20 6e 6f 74 69 63 | copyrig|ht notic|
|00000ae0| 65 2e 0a 58 59 6f 75 20 | 61 72 65 20 66 72 65 65 |e..XYou |are free|
|00000af0| 20 74 6f 20 64 6f 20 77 | 68 61 74 65 76 65 72 20 | to do w|hatever |
|00000b00| 79 6f 75 20 70 6c 65 61 | 73 65 20 77 69 74 68 20 |you plea|se with |
|00000b10| 73 63 61 6e 6e 65 72 73 | 20 67 65 6e 65 72 61 74 |scanners| generat|
|00000b20| 65 64 20 75 73 69 6e 67 | 20 66 6c 65 78 3b 0a 58 |ed using| flex;.X|
|00000b30| 66 6f 72 20 74 68 65 6d | 2c 20 79 6f 75 20 61 72 |for them|, you ar|
|00000b40| 65 20 6e 6f 74 20 65 76 | 65 6e 20 62 6f 75 6e 64 |e not ev|en bound|
|00000b50| 20 62 79 20 74 68 65 20 | 61 62 6f 76 65 20 63 6f | by the |above co|
|00000b60| 70 79 72 69 67 68 74 2e | 0a 45 4e 44 5f 4f 46 5f |pyright.|.END_OF_|
|00000b70| 46 49 4c 45 0a 20 20 69 | 66 20 74 65 73 74 20 31 |FILE. i|f test 1|
|00000b80| 38 30 32 20 2d 6e 65 20 | 60 77 63 20 2d 63 20 3c |802 -ne |`wc -c <|
|00000b90| 27 43 4f 50 59 49 4e 47 | 27 60 3b 20 74 68 65 6e |'COPYING|'`; then|
|00000ba0| 0a 20 20 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |. ech|o shar: |
|00000bb0| 5c 22 27 43 4f 50 59 49 | 4e 47 27 5c 22 20 75 6e |\"'COPYI|NG'\" un|
|00000bc0| 70 61 63 6b 65 64 20 77 | 69 74 68 20 77 72 6f 6e |packed w|ith wron|
|00000bd0| 67 20 73 69 7a 65 21 0a | 20 20 66 69 0a 20 20 23 |g size!.| fi. #|
|00000be0| 20 65 6e 64 20 6f 66 20 | 27 43 4f 50 59 49 4e 47 | end of |'COPYING|
|00000bf0| 27 0a 66 69 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |'.fi.if |test -f |
|00000c00| 27 66 6c 65 78 64 6f 63 | 2e 31 2e 30 31 27 20 2d |'flexdoc|.1.01' -|
|00000c10| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|00000c20| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00000c30| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 63 |shar: Wi|ll not c|
|00000c40| 6c 6f 62 62 65 72 20 65 | 78 69 73 74 69 6e 67 20 |lobber e|xisting |
|00000c50| 66 69 6c 65 20 5c 22 27 | 66 6c 65 78 64 6f 63 2e |file \"'|flexdoc.|
|00000c60| 31 2e 30 31 27 5c 22 0a | 65 6c 73 65 0a 20 20 65 |1.01'\".|else. e|
|00000c70| 63 68 6f 20 73 68 61 72 | 3a 20 45 78 74 72 61 63 |cho shar|: Extrac|
|00000c80| 74 69 6e 67 20 5c 22 27 | 66 6c 65 78 64 6f 63 2e |ting \"'|flexdoc.|
|00000c90| 31 2e 30 31 27 5c 22 20 | 5c 28 34 39 38 33 39 20 |1.01'\" |\(49839 |
|00000ca0| 63 68 61 72 61 63 74 65 | 72 73 5c 29 0a 20 20 73 |characte|rs\). s|
|00000cb0| 65 64 20 22 73 2f 5e 58 | 2f 2f 22 20 3e 27 66 6c |ed "s/^X|//" >'fl|
|00000cc0| 65 78 64 6f 63 2e 31 2e | 30 31 27 20 3c 3c 27 45 |exdoc.1.|01' <<'E|
|00000cd0| 4e 44 5f 4f 46 5f 46 49 | 4c 45 27 0a 58 2e 54 48 |ND_OF_FI|LE'.X.TH|
|00000ce0| 20 46 4c 45 58 20 31 20 | 22 32 36 20 4d 61 79 20 | FLEX 1 |"26 May |
|00000cf0| 31 39 39 30 22 20 22 56 | 65 72 73 69 6f 6e 20 32 |1990" "V|ersion 2|
|00000d00| 2e 33 22 0a 58 2e 53 48 | 20 4e 41 4d 45 0a 58 66 |.3".X.SH| NAME.Xf|
|00000d10| 6c 65 78 20 2d 20 66 61 | 73 74 20 6c 65 78 69 63 |lex - fa|st lexic|
|00000d20| 61 6c 20 61 6e 61 6c 79 | 7a 65 72 20 67 65 6e 65 |al analy|zer gene|
|00000d30| 72 61 74 6f 72 0a 58 2e | 53 48 20 53 59 4e 4f 50 |rator.X.|SH SYNOP|
|00000d40| 53 49 53 0a 58 2e 42 20 | 66 6c 65 78 0a 58 2e 42 |SIS.X.B |flex.X.B|
|00000d50| 20 5b 2d 62 63 64 66 69 | 6e 70 73 74 76 46 49 4c | [-bcdfi|npstvFIL|
|00000d60| 54 38 20 2d 43 5b 65 66 | 6d 46 5d 20 2d 53 73 6b |T8 -C[ef|mF] -Ssk|
|00000d70| 65 6c 65 74 6f 6e 5d 0a | 58 2e 49 20 5b 66 69 6c |eleton].|X.I [fil|
|00000d80| 65 6e 61 6d 65 20 2e 2e | 2e 5d 0a 58 2e 53 48 20 |ename ..|.].X.SH |
|00000d90| 44 45 53 43 52 49 50 54 | 49 4f 4e 0a 58 2e 49 20 |DESCRIPT|ION.X.I |
|00000da0| 66 6c 65 78 0a 58 69 73 | 20 61 20 74 6f 6f 6c 20 |flex.Xis| a tool |
|00000db0| 66 6f 72 20 67 65 6e 65 | 72 61 74 69 6e 67 0a 58 |for gene|rating.X|
|00000dc0| 2e 49 20 73 63 61 6e 6e | 65 72 73 3a 0a 58 70 72 |.I scann|ers:.Xpr|
|00000dd0| 6f 67 72 61 6d 73 20 77 | 68 69 63 68 20 72 65 63 |ograms w|hich rec|
|00000de0| 6f 67 6e 69 7a 65 64 20 | 6c 65 78 69 63 61 6c 20 |ognized |lexical |
|00000df0| 70 61 74 74 65 72 6e 73 | 20 69 6e 20 74 65 78 74 |patterns| in text|
|00000e00| 2e 0a 58 2e 49 20 66 6c | 65 78 0a 58 72 65 61 64 |..X.I fl|ex.Xread|
|00000e10| 73 0a 58 74 68 65 20 67 | 69 76 65 6e 20 69 6e 70 |s.Xthe g|iven inp|
|00000e20| 75 74 20 66 69 6c 65 73 | 2c 20 6f 72 20 69 74 73 |ut files|, or its|
|00000e30| 20 73 74 61 6e 64 61 72 | 64 20 69 6e 70 75 74 20 | standar|d input |
|00000e40| 69 66 20 6e 6f 20 66 69 | 6c 65 20 6e 61 6d 65 73 |if no fi|le names|
|00000e50| 20 61 72 65 20 67 69 76 | 65 6e 2c 0a 58 66 6f 72 | are giv|en,.Xfor|
|00000e60| 20 61 20 64 65 73 63 72 | 69 70 74 69 6f 6e 20 6f | a descr|iption o|
|00000e70| 66 20 61 20 73 63 61 6e | 6e 65 72 20 74 6f 20 67 |f a scan|ner to g|
|00000e80| 65 6e 65 72 61 74 65 2e | 20 20 54 68 65 20 64 65 |enerate.| The de|
|00000e90| 73 63 72 69 70 74 69 6f | 6e 20 69 73 20 69 6e 0a |scriptio|n is in.|
|00000ea0| 58 74 68 65 20 66 6f 72 | 6d 20 6f 66 20 70 61 69 |Xthe for|m of pai|
|00000eb0| 72 73 0a 58 6f 66 20 72 | 65 67 75 6c 61 72 20 65 |rs.Xof r|egular e|
|00000ec0| 78 70 72 65 73 73 69 6f | 6e 73 20 61 6e 64 20 43 |xpressio|ns and C|
|00000ed0| 20 63 6f 64 65 2c 20 63 | 61 6c 6c 65 64 0a 58 2e | code, c|alled.X.|
|00000ee0| 49 20 72 75 6c 65 73 2e | 20 20 66 6c 65 78 0a 58 |I rules.| flex.X|
|00000ef0| 67 65 6e 65 72 61 74 65 | 73 20 61 73 20 6f 75 74 |generate|s as out|
|00000f00| 70 75 74 20 61 20 43 20 | 73 6f 75 72 63 65 20 66 |put a C |source f|
|00000f10| 69 6c 65 2c 0a 58 2e 42 | 20 6c 65 78 2e 79 79 2e |ile,.X.B| lex.yy.|
|00000f20| 63 2c 0a 58 77 68 69 63 | 68 20 64 65 66 69 6e 65 |c,.Xwhic|h define|
|00000f30| 73 20 61 20 72 6f 75 74 | 69 6e 65 0a 58 2e 42 20 |s a rout|ine.X.B |
|00000f40| 79 79 6c 65 78 28 29 2e | 0a 58 54 68 69 73 20 66 |yylex().|.XThis f|
|00000f50| 69 6c 65 20 69 73 20 63 | 6f 6d 70 69 6c 65 64 20 |ile is c|ompiled |
|00000f60| 61 6e 64 20 6c 69 6e 6b | 65 64 20 77 69 74 68 20 |and link|ed with |
|00000f70| 74 68 65 0a 58 2e 42 20 | 2d 6c 66 6c 0a 58 6c 69 |the.X.B |-lfl.Xli|
|00000f80| 62 72 61 72 79 20 74 6f | 20 70 72 6f 64 75 63 65 |brary to| produce|
|00000f90| 20 61 6e 20 65 78 65 63 | 75 74 61 62 6c 65 2e 20 | an exec|utable. |
|00000fa0| 20 57 68 65 6e 20 74 68 | 65 20 65 78 65 63 75 74 | When th|e execut|
|00000fb0| 61 62 6c 65 20 69 73 20 | 72 75 6e 2c 0a 58 69 74 |able is |run,.Xit|
|00000fc0| 20 61 6e 61 6c 79 7a 65 | 73 20 69 74 73 20 69 6e | analyze|s its in|
|00000fd0| 70 75 74 20 66 6f 72 20 | 6f 63 63 75 72 72 65 6e |put for |occurren|
|00000fe0| 63 65 73 0a 58 6f 66 20 | 74 68 65 20 72 65 67 75 |ces.Xof |the regu|
|00000ff0| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 73 2e |lar expr|essions.|
|00001000| 20 20 57 68 65 6e 65 76 | 65 72 20 69 74 20 66 69 | Whenev|er it fi|
|00001010| 6e 64 73 20 6f 6e 65 2c | 20 69 74 20 65 78 65 63 |nds one,| it exec|
|00001020| 75 74 65 73 0a 58 74 68 | 65 20 63 6f 72 72 65 73 |utes.Xth|e corres|
|00001030| 70 6f 6e 64 69 6e 67 20 | 43 20 63 6f 64 65 2e 0a |ponding |C code..|
|00001040| 58 2e 53 48 20 53 4f 4d | 45 20 53 49 4d 50 4c 45 |X.SH SOM|E SIMPLE|
|00001050| 20 45 58 41 4d 50 4c 45 | 53 0a 58 2e 4c 50 0a 58 | EXAMPLE|S.X.LP.X|
|00001060| 46 69 72 73 74 20 73 6f | 6d 65 20 73 69 6d 70 6c |First so|me simpl|
|00001070| 65 20 65 78 61 6d 70 6c | 65 73 20 74 6f 20 67 65 |e exampl|es to ge|
|00001080| 74 20 74 68 65 20 66 6c | 61 76 6f 72 20 6f 66 20 |t the fl|avor of |
|00001090| 68 6f 77 20 6f 6e 65 20 | 75 73 65 73 0a 58 2e 49 |how one |uses.X.I|
|000010a0| 20 66 6c 65 78 2e 0a 58 | 54 68 65 20 66 6f 6c 6c | flex..X|The foll|
|000010b0| 6f 77 69 6e 67 0a 58 2e | 49 20 66 6c 65 78 0a 58 |owing.X.|I flex.X|
|000010c0| 69 6e 70 75 74 20 73 70 | 65 63 69 66 69 65 73 20 |input sp|ecifies |
|000010d0| 61 20 73 63 61 6e 6e 65 | 72 20 77 68 69 63 68 20 |a scanne|r which |
|000010e0| 77 68 65 6e 65 76 65 72 | 20 69 74 20 65 6e 63 6f |whenever| it enco|
|000010f0| 75 6e 74 65 72 73 20 74 | 68 65 20 73 74 72 69 6e |unters t|he strin|
|00001100| 67 0a 58 22 75 73 65 72 | 6e 61 6d 65 22 20 77 69 |g.X"user|name" wi|
|00001110| 6c 6c 20 72 65 70 6c 61 | 63 65 20 69 74 20 77 69 |ll repla|ce it wi|
|00001120| 74 68 20 74 68 65 20 75 | 73 65 72 27 73 20 6c 6f |th the u|ser's lo|
|00001130| 67 69 6e 20 6e 61 6d 65 | 3a 0a 58 2e 6e 66 0a 58 |gin name|:.X.nf.X|
|00001140| 0a 58 20 20 20 20 25 25 | 0a 58 20 20 20 20 75 73 |.X %%|.X us|
|00001150| 65 72 6e 61 6d 65 20 20 | 20 20 70 72 69 6e 74 66 |ername | printf|
|00001160| 28 20 22 25 73 22 2c 20 | 67 65 74 6c 6f 67 69 6e |( "%s", |getlogin|
|00001170| 28 29 20 29 3b 0a 58 0a | 58 2e 66 69 0a 58 42 79 |() );.X.|X.fi.XBy|
|00001180| 20 64 65 66 61 75 6c 74 | 2c 20 61 6e 79 20 74 65 | default|, any te|
|00001190| 78 74 20 6e 6f 74 20 6d | 61 74 63 68 65 64 20 62 |xt not m|atched b|
|000011a0| 79 20 61 0a 58 2e 49 20 | 66 6c 65 78 0a 58 73 63 |y a.X.I |flex.Xsc|
|000011b0| 61 6e 6e 65 72 0a 58 69 | 73 20 63 6f 70 69 65 64 |anner.Xi|s copied|
|000011c0| 20 74 6f 20 74 68 65 20 | 6f 75 74 70 75 74 2c 20 | to the |output, |
|000011d0| 73 6f 20 74 68 65 20 6e | 65 74 20 65 66 66 65 63 |so the n|et effec|
|000011e0| 74 20 6f 66 20 74 68 69 | 73 20 73 63 61 6e 6e 65 |t of thi|s scanne|
|000011f0| 72 20 69 73 0a 58 74 6f | 20 63 6f 70 79 20 69 74 |r is.Xto| copy it|
|00001200| 73 20 69 6e 70 75 74 20 | 66 69 6c 65 20 74 6f 20 |s input |file to |
|00001210| 69 74 73 20 6f 75 74 70 | 75 74 20 77 69 74 68 20 |its outp|ut with |
|00001220| 65 61 63 68 20 6f 63 63 | 75 72 72 65 6e 63 65 0a |each occ|urrence.|
|00001230| 58 6f 66 20 22 75 73 65 | 72 6e 61 6d 65 22 20 65 |Xof "use|rname" e|
|00001240| 78 70 61 6e 64 65 64 2e | 0a 58 49 6e 20 74 68 69 |xpanded.|.XIn thi|
|00001250| 73 20 69 6e 70 75 74 2c | 20 74 68 65 72 65 20 69 |s input,| there i|
|00001260| 73 20 6a 75 73 74 20 6f | 6e 65 20 72 75 6c 65 2e |s just o|ne rule.|
|00001270| 20 20 22 75 73 65 72 6e | 61 6d 65 22 20 69 73 20 | "usern|ame" is |
|00001280| 74 68 65 0a 58 2e 49 20 | 70 61 74 74 65 72 6e 0a |the.X.I |pattern.|
|00001290| 58 61 6e 64 20 74 68 65 | 20 22 70 72 69 6e 74 66 |Xand the| "printf|
|000012a0| 22 20 69 73 20 74 68 65 | 0a 58 2e 49 20 61 63 74 |" is the|.X.I act|
|000012b0| 69 6f 6e 2e 0a 58 54 68 | 65 20 22 25 25 22 20 6d |ion..XTh|e "%%" m|
|000012c0| 61 72 6b 73 20 74 68 65 | 20 62 65 67 69 6e 6e 69 |arks the| beginni|
|000012d0| 6e 67 20 6f 66 20 74 68 | 65 20 72 75 6c 65 73 2e |ng of th|e rules.|
|000012e0| 0a 58 2e 4c 50 0a 58 48 | 65 72 65 27 73 20 61 6e |.X.LP.XH|ere's an|
|000012f0| 6f 74 68 65 72 20 73 69 | 6d 70 6c 65 20 65 78 61 |other si|mple exa|
|00001300| 6d 70 6c 65 3a 0a 58 2e | 6e 66 0a 58 0a 58 20 20 |mple:.X.|nf.X.X |
|00001310| 20 20 20 20 20 20 69 6e | 74 20 6e 75 6d 5f 6c 69 | in|t num_li|
|00001320| 6e 65 73 20 3d 20 30 2c | 20 6e 75 6d 5f 63 68 61 |nes = 0,| num_cha|
|00001330| 72 73 20 3d 20 30 3b 0a | 58 0a 58 20 20 20 20 25 |rs = 0;.|X.X %|
|00001340| 25 0a 58 20 20 20 20 5c | 5c 6e 20 20 20 20 2b 2b |%.X \|\n ++|
|00001350| 6e 75 6d 5f 6c 69 6e 65 | 73 3b 20 2b 2b 6e 75 6d |num_line|s; ++num|
|00001360| 5f 63 68 61 72 73 3b 0a | 58 20 20 20 20 2e 20 20 |_chars;.|X . |
|00001370| 20 20 20 2b 2b 6e 75 6d | 5f 63 68 61 72 73 3b 0a | ++num|_chars;.|
|00001380| 58 0a 58 20 20 20 20 25 | 25 0a 58 20 20 20 20 6d |X.X %|%.X m|
|00001390| 61 69 6e 28 29 0a 58 20 | 20 20 20 20 20 20 20 7b |ain().X | {|
|000013a0| 0a 58 20 20 20 20 20 20 | 20 20 79 79 6c 65 78 28 |.X | yylex(|
|000013b0| 29 3b 0a 58 20 20 20 20 | 20 20 20 20 70 72 69 6e |);.X | prin|
|000013c0| 74 66 28 20 22 23 20 6f | 66 20 6c 69 6e 65 73 20 |tf( "# o|f lines |
|000013d0| 3d 20 25 64 2c 20 23 20 | 6f 66 20 63 68 61 72 73 |= %d, # |of chars|
|000013e0| 20 3d 20 25 64 5c 5c 6e | 22 2c 0a 58 20 20 20 20 | = %d\\n|",.X |
|000013f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 6e 75 6d 5f | | num_|
|00001400| 6c 69 6e 65 73 2c 20 6e | 75 6d 5f 63 68 61 72 73 |lines, n|um_chars|
|00001410| 20 29 3b 0a 58 20 20 20 | 20 20 20 20 20 7d 0a 58 | );.X | }.X|
|00001420| 0a 58 2e 66 69 0a 58 54 | 68 69 73 20 73 63 61 6e |.X.fi.XT|his scan|
|00001430| 6e 65 72 20 63 6f 75 6e | 74 73 20 74 68 65 20 6e |ner coun|ts the n|
|00001440| 75 6d 62 65 72 20 6f 66 | 20 63 68 61 72 61 63 74 |umber of| charact|
|00001450| 65 72 73 20 61 6e 64 20 | 74 68 65 20 6e 75 6d 62 |ers and |the numb|
|00001460| 65 72 0a 58 6f 66 20 6c | 69 6e 65 73 20 69 6e 20 |er.Xof l|ines in |
|00001470| 69 74 73 20 69 6e 70 75 | 74 20 28 69 74 20 70 72 |its inpu|t (it pr|
|00001480| 6f 64 75 63 65 73 20 6e | 6f 20 6f 75 74 70 75 74 |oduces n|o output|
|00001490| 20 6f 74 68 65 72 20 74 | 68 61 6e 20 74 68 65 0a | other t|han the.|
|000014a0| 58 66 69 6e 61 6c 20 72 | 65 70 6f 72 74 20 6f 6e |Xfinal r|eport on|
|000014b0| 20 74 68 65 20 63 6f 75 | 6e 74 73 29 2e 20 20 54 | the cou|nts). T|
|000014c0| 68 65 20 66 69 72 73 74 | 20 6c 69 6e 65 0a 58 64 |he first| line.Xd|
|000014d0| 65 63 6c 61 72 65 73 20 | 74 77 6f 20 67 6c 6f 62 |eclares |two glob|
|000014e0| 61 6c 73 2c 20 22 6e 75 | 6d 5f 6c 69 6e 65 73 22 |als, "nu|m_lines"|
|000014f0| 20 61 6e 64 20 22 6e 75 | 6d 5f 63 68 61 72 73 22 | and "nu|m_chars"|
|00001500| 2c 20 77 68 69 63 68 20 | 61 72 65 20 61 63 63 65 |, which |are acce|
|00001510| 73 73 69 62 6c 65 0a 58 | 62 6f 74 68 20 69 6e 73 |ssible.X|both ins|
|00001520| 69 64 65 0a 58 2e 42 20 | 79 79 6c 65 78 28 29 0a |ide.X.B |yylex().|
|00001530| 58 61 6e 64 20 69 6e 20 | 74 68 65 0a 58 2e 42 20 |Xand in |the.X.B |
|00001540| 6d 61 69 6e 28 29 0a 58 | 72 6f 75 74 69 6e 65 20 |main().X|routine |
|00001550| 64 65 63 6c 61 72 65 64 | 20 61 66 74 65 72 20 74 |declared| after t|
|00001560| 68 65 20 73 65 63 6f 6e | 64 20 22 25 25 22 2e 20 |he secon|d "%%". |
|00001570| 20 54 68 65 72 65 20 61 | 72 65 20 74 77 6f 20 72 | There a|re two r|
|00001580| 75 6c 65 73 2c 20 6f 6e | 65 0a 58 77 68 69 63 68 |ules, on|e.Xwhich|
|00001590| 20 6d 61 74 63 68 65 73 | 20 61 20 6e 65 77 6c 69 | matches| a newli|
|000015a0| 6e 65 20 28 22 5c 5c 6e | 22 29 20 61 6e 64 20 69 |ne ("\\n|") and i|
|000015b0| 6e 63 72 65 6d 65 6e 74 | 73 20 62 6f 74 68 20 74 |ncrement|s both t|
|000015c0| 68 65 20 6c 69 6e 65 20 | 63 6f 75 6e 74 20 61 6e |he line |count an|
|000015d0| 64 0a 58 74 68 65 20 63 | 68 61 72 61 63 74 65 72 |d.Xthe c|haracter|
|000015e0| 20 63 6f 75 6e 74 2c 20 | 61 6e 64 20 6f 6e 65 20 | count, |and one |
|000015f0| 77 68 69 63 68 20 6d 61 | 74 63 68 65 73 20 61 6e |which ma|tches an|
|00001600| 79 20 63 68 61 72 61 63 | 74 65 72 20 6f 74 68 65 |y charac|ter othe|
|00001610| 72 20 74 68 61 6e 0a 58 | 61 20 6e 65 77 6c 69 6e |r than.X|a newlin|
|00001620| 65 20 28 69 6e 64 69 63 | 61 74 65 64 20 62 79 20 |e (indic|ated by |
|00001630| 74 68 65 20 22 2e 22 20 | 72 65 67 75 6c 61 72 20 |the "." |regular |
|00001640| 65 78 70 72 65 73 73 69 | 6f 6e 29 2e 0a 58 2e 4c |expressi|on)..X.L|
|00001650| 50 0a 58 41 20 73 6f 6d | 65 77 68 61 74 20 6d 6f |P.XA som|ewhat mo|
|00001660| 72 65 20 63 6f 6d 70 6c | 69 63 61 74 65 64 20 65 |re compl|icated e|
|00001670| 78 61 6d 70 6c 65 3a 0a | 58 2e 6e 66 0a 58 0a 58 |xample:.|X.nf.X.X|
|00001680| 20 20 20 20 2f 2a 20 73 | 63 61 6e 6e 65 72 20 66 | /* s|canner f|
|00001690| 6f 72 20 61 20 74 6f 79 | 20 50 61 73 63 61 6c 2d |or a toy| Pascal-|
|000016a0| 6c 69 6b 65 20 6c 61 6e | 67 75 61 67 65 20 2a 2f |like lan|guage */|
|000016b0| 0a 58 0a 58 20 20 20 20 | 25 7b 0a 58 20 20 20 20 |.X.X |%{.X |
|000016c0| 2f 2a 20 6e 65 65 64 20 | 74 68 69 73 20 66 6f 72 |/* need |this for|
|000016d0| 20 74 68 65 20 63 61 6c | 6c 20 74 6f 20 61 74 6f | the cal|l to ato|
|000016e0| 66 28 29 20 62 65 6c 6f | 77 20 2a 2f 0a 58 20 20 |f() belo|w */.X |
|000016f0| 20 20 23 69 6e 63 6c 75 | 64 65 20 3c 6d 61 74 68 | #inclu|de <math|
|00001700| 2e 68 3e 0a 58 20 20 20 | 20 25 7d 0a 58 0a 58 20 |.h>.X | %}.X.X |
|00001710| 20 20 20 44 49 47 49 54 | 20 20 20 20 5b 30 2d 39 | DIGIT| [0-9|
|00001720| 5d 0a 58 20 20 20 20 49 | 44 20 20 20 20 20 20 20 |].X I|D |
|00001730| 5b 61 2d 7a 5d 5b 61 2d | 7a 30 2d 39 5d 2a 0a 58 |[a-z][a-|z0-9]*.X|
|00001740| 0a 58 20 20 20 20 25 25 | 0a 58 0a 58 20 20 20 20 |.X %%|.X.X |
|00001750| 7b 44 49 47 49 54 7d 2b | 20 20 20 20 7b 0a 58 20 |{DIGIT}+| {.X |
|00001760| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 70 | | p|
|00001770| 72 69 6e 74 66 28 20 22 | 41 6e 20 69 6e 74 65 67 |rintf( "|An integ|
|00001780| 65 72 3a 20 25 73 20 28 | 25 64 29 5c 5c 6e 22 2c |er: %s (|%d)\\n",|
|00001790| 20 79 79 74 65 78 74 2c | 0a 58 20 20 20 20 20 20 | yytext,|.X |
|000017a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000017b0| 20 20 61 74 6f 69 28 20 | 79 79 74 65 78 74 20 29 | atoi( |yytext )|
|000017c0| 20 29 3b 0a 58 20 20 20 | 20 20 20 20 20 20 20 20 | );.X | |
|000017d0| 20 20 20 20 20 7d 0a 58 | 0a 58 20 20 20 20 7b 44 | }.X|.X {D|
|000017e0| 49 47 49 54 7d 2b 22 2e | 22 7b 44 49 47 49 54 7d |IGIT}+".|"{DIGIT}|
|000017f0| 2a 20 20 20 20 20 20 20 | 20 7b 0a 58 20 20 20 20 |* | {.X |
|00001800| 20 20 20 20 20 20 20 20 | 20 20 20 20 70 72 69 6e | | prin|
|00001810| 74 66 28 20 22 41 20 66 | 6c 6f 61 74 3a 20 25 73 |tf( "A f|loat: %s|
|00001820| 20 28 25 67 29 5c 5c 6e | 22 2c 20 79 79 74 65 78 | (%g)\\n|", yytex|
|00001830| 74 2c 0a 58 20 20 20 20 | 20 20 20 20 20 20 20 20 |t,.X | |
|00001840| 20 20 20 20 20 20 20 20 | 20 20 20 20 61 74 6f 66 | | atof|
|00001850| 28 20 79 79 74 65 78 74 | 20 29 20 29 3b 0a 58 20 |( yytext| ) );.X |
|00001860| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 7d | | }|
|00001870| 0a 58 0a 58 20 20 20 20 | 69 66 7c 74 68 65 6e 7c |.X.X |if|then||
|00001880| 62 65 67 69 6e 7c 65 6e | 64 7c 70 72 6f 63 65 64 |begin|en|d|proced|
|00001890| 75 72 65 7c 66 75 6e 63 | 74 69 6f 6e 20 20 20 20 |ure|func|tion |
|000018a0| 20 20 20 20 7b 0a 58 20 | 20 20 20 20 20 20 20 20 | {.X | |
|000018b0| 20 20 20 20 20 20 20 70 | 72 69 6e 74 66 28 20 22 | p|rintf( "|
|000018c0| 41 20 6b 65 79 77 6f 72 | 64 3a 20 25 73 5c 5c 6e |A keywor|d: %s\\n|
|000018d0| 22 2c 20 79 79 74 65 78 | 74 20 29 3b 0a 58 20 20 |", yytex|t );.X |
|000018e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 7d 0a | | }.|
|000018f0| 58 0a 58 20 20 20 20 7b | 49 44 7d 20 20 20 20 20 |X.X {|ID} |
|00001900| 20 20 20 70 72 69 6e 74 | 66 28 20 22 41 6e 20 69 | print|f( "An i|
|00001910| 64 65 6e 74 69 66 69 65 | 72 3a 20 25 73 5c 5c 6e |dentifie|r: %s\\n|
|00001920| 22 2c 20 79 79 74 65 78 | 74 20 29 3b 0a 58 0a 58 |", yytex|t );.X.X|
|00001930| 20 20 20 20 22 2b 22 7c | 22 2d 22 7c 22 2a 22 7c | "+"||"-"|"*"||
|00001940| 22 2f 22 20 20 20 70 72 | 69 6e 74 66 28 20 22 41 |"/" pr|intf( "A|
|00001950| 6e 20 6f 70 65 72 61 74 | 6f 72 3a 20 25 73 5c 5c |n operat|or: %s\\|
|00001960| 6e 22 2c 20 79 79 74 65 | 78 74 20 29 3b 0a 58 0a |n", yyte|xt );.X.|
|00001970| 58 20 20 20 20 22 7b 22 | 5b 5e 7d 5c 5c 6e 5d 2a |X "{"|[^}\\n]*|
|00001980| 22 7d 22 20 20 20 20 20 | 2f 2a 20 65 61 74 20 75 |"}" |/* eat u|
|00001990| 70 20 6f 6e 65 2d 6c 69 | 6e 65 20 63 6f 6d 6d 65 |p one-li|ne comme|
|000019a0| 6e 74 73 20 2a 2f 0a 58 | 0a 58 20 20 20 20 5b 20 |nts */.X|.X [ |
|000019b0| 5c 5c 74 5c 5c 6e 5d 2b | 20 20 20 20 20 20 20 20 |\\t\\n]+| |
|000019c0| 20 20 2f 2a 20 65 61 74 | 20 75 70 20 77 68 69 74 | /* eat| up whit|
|000019d0| 65 73 70 61 63 65 20 2a | 2f 0a 58 0a 58 20 20 20 |espace *|/.X.X |
|000019e0| 20 2e 20 20 20 20 20 20 | 20 20 20 20 20 70 72 69 | . | pri|
|000019f0| 6e 74 66 28 20 22 55 6e | 72 65 63 6f 67 6e 69 7a |ntf( "Un|recogniz|
|00001a00| 65 64 20 63 68 61 72 61 | 63 74 65 72 3a 20 25 73 |ed chara|cter: %s|
|00001a10| 5c 5c 6e 22 2c 20 79 79 | 74 65 78 74 20 29 3b 0a |\\n", yy|text );.|
|00001a20| 58 0a 58 20 20 20 20 25 | 25 0a 58 0a 58 20 20 20 |X.X %|%.X.X |
|00001a30| 20 6d 61 69 6e 28 20 61 | 72 67 63 2c 20 61 72 67 | main( a|rgc, arg|
|00001a40| 76 20 29 0a 58 20 20 20 | 20 69 6e 74 20 61 72 67 |v ).X | int arg|
|00001a50| 63 3b 0a 58 20 20 20 20 | 63 68 61 72 20 2a 2a 61 |c;.X |char **a|
|00001a60| 72 67 76 3b 0a 58 20 20 | 20 20 20 20 20 20 7b 0a |rgv;.X | {.|
|00001a70| 58 20 20 20 20 20 20 20 | 20 2b 2b 61 72 67 76 2c |X | ++argv,|
|00001a80| 20 2d 2d 61 72 67 63 3b | 20 20 2f 2a 20 73 6b 69 | --argc;| /* ski|
|00001a90| 70 20 6f 76 65 72 20 70 | 72 6f 67 72 61 6d 20 6e |p over p|rogram n|
|00001aa0| 61 6d 65 20 2a 2f 0a 58 | 20 20 20 20 20 20 20 20 |ame */.X| |
|00001ab0| 69 66 20 28 20 61 72 67 | 63 20 3e 20 30 20 29 0a |if ( arg|c > 0 ).|
|00001ac0| 58 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |X | |
|00001ad0| 20 79 79 69 6e 20 3d 20 | 66 6f 70 65 6e 28 20 61 | yyin = |fopen( a|
|00001ae0| 72 67 76 5b 30 5d 2c 20 | 22 72 22 20 29 3b 0a 58 |rgv[0], |"r" );.X|
|00001af0| 20 20 20 20 20 20 20 20 | 65 6c 73 65 0a 58 20 20 | |else.X |
|00001b00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 79 79 | | yy|
|00001b10| 69 6e 20 3d 20 73 74 64 | 69 6e 3b 0a 58 20 20 20 |in = std|in;.X |
|00001b20| 20 20 20 20 20 0a 58 20 | 20 20 20 20 20 20 20 79 | .X | y|
|00001b30| 79 6c 65 78 28 29 3b 0a | 58 20 20 20 20 20 20 20 |ylex();.|X |
|00001b40| 20 7d 0a 58 0a 58 2e 66 | 69 0a 58 54 68 69 73 20 | }.X.X.f|i.XThis |
|00001b50| 69 73 20 74 68 65 20 62 | 65 67 69 6e 6e 69 6e 67 |is the b|eginning|
|00001b60| 73 20 6f 66 20 61 20 73 | 69 6d 70 6c 65 20 73 63 |s of a s|imple sc|
|00001b70| 61 6e 6e 65 72 20 66 6f | 72 20 61 20 6c 61 6e 67 |anner fo|r a lang|
|00001b80| 75 61 67 65 20 6c 69 6b | 65 0a 58 50 61 73 63 61 |uage lik|e.XPasca|
|00001b90| 6c 2e 20 20 49 74 20 69 | 64 65 6e 74 69 66 69 65 |l. It i|dentifie|
|00001ba0| 73 20 64 69 66 66 65 72 | 65 6e 74 20 74 79 70 65 |s differ|ent type|
|00001bb0| 73 20 6f 66 0a 58 2e 49 | 20 74 6f 6b 65 6e 73 0a |s of.X.I| tokens.|
|00001bc0| 58 61 6e 64 20 72 65 70 | 6f 72 74 73 20 6f 6e 20 |Xand rep|orts on |
|00001bd0| 77 68 61 74 20 69 74 20 | 68 61 73 20 73 65 65 6e |what it |has seen|
|00001be0| 2e 0a 58 2e 4c 50 0a 58 | 54 68 65 20 64 65 74 61 |..X.LP.X|The deta|
|00001bf0| 69 6c 73 20 6f 66 20 74 | 68 69 73 20 65 78 61 6d |ils of t|his exam|
|00001c00| 70 6c 65 20 77 69 6c 6c | 20 62 65 20 65 78 70 6c |ple will| be expl|
|00001c10| 61 69 6e 65 64 20 69 6e | 20 74 68 65 20 66 6f 6c |ained in| the fol|
|00001c20| 6c 6f 77 69 6e 67 0a 58 | 73 65 63 74 69 6f 6e 73 |lowing.X|sections|
|00001c30| 2e 0a 58 2e 53 48 20 46 | 4f 52 4d 41 54 20 4f 46 |..X.SH F|ORMAT OF|
|00001c40| 20 54 48 45 20 49 4e 50 | 55 54 20 46 49 4c 45 0a | THE INP|UT FILE.|
|00001c50| 58 54 68 65 0a 58 2e 49 | 20 66 6c 65 78 0a 58 69 |XThe.X.I| flex.Xi|
|00001c60| 6e 70 75 74 20 66 69 6c | 65 20 63 6f 6e 73 69 73 |nput fil|e consis|
|00001c70| 74 73 20 6f 66 20 74 68 | 72 65 65 20 73 65 63 74 |ts of th|ree sect|
|00001c80| 69 6f 6e 73 2c 20 73 65 | 70 61 72 61 74 65 64 20 |ions, se|parated |
|00001c90| 62 79 20 61 20 6c 69 6e | 65 20 77 69 74 68 20 6a |by a lin|e with j|
|00001ca0| 75 73 74 0a 58 2e 42 20 | 25 25 0a 58 69 6e 20 69 |ust.X.B |%%.Xin i|
|00001cb0| 74 3a 0a 58 2e 6e 66 0a | 58 0a 58 20 20 20 20 64 |t:.X.nf.|X.X d|
|00001cc0| 65 66 69 6e 69 74 69 6f | 6e 73 0a 58 20 20 20 20 |efinitio|ns.X |
|00001cd0| 25 25 0a 58 20 20 20 20 | 72 75 6c 65 73 0a 58 20 |%%.X |rules.X |
|00001ce0| 20 20 20 25 25 0a 58 20 | 20 20 20 75 73 65 72 20 | %%.X | user |
|00001cf0| 63 6f 64 65 0a 58 0a 58 | 2e 66 69 0a 58 54 68 65 |code.X.X|.fi.XThe|
|00001d00| 0a 58 2e 49 20 64 65 66 | 69 6e 69 74 69 6f 6e 73 |.X.I def|initions|
|00001d10| 0a 58 73 65 63 74 69 6f | 6e 20 63 6f 6e 74 61 69 |.Xsectio|n contai|
|00001d20| 6e 73 20 64 65 63 6c 61 | 72 61 74 69 6f 6e 73 20 |ns decla|rations |
|00001d30| 6f 66 20 73 69 6d 70 6c | 65 0a 58 2e 49 20 6e 61 |of simpl|e.X.I na|
|00001d40| 6d 65 0a 58 64 65 66 69 | 6e 69 74 69 6f 6e 73 20 |me.Xdefi|nitions |
|00001d50| 74 6f 20 73 69 6d 70 6c | 69 66 79 20 74 68 65 20 |to simpl|ify the |
|00001d60| 73 63 61 6e 6e 65 72 20 | 73 70 65 63 69 66 69 63 |scanner |specific|
|00001d70| 61 74 69 6f 6e 2c 20 61 | 6e 64 20 64 65 63 6c 61 |ation, a|nd decla|
|00001d80| 72 61 74 69 6f 6e 73 20 | 6f 66 0a 58 2e 49 20 73 |rations |of.X.I s|
|00001d90| 74 61 72 74 20 63 6f 6e | 64 69 74 69 6f 6e 73 2c |tart con|ditions,|
|00001da0| 0a 58 77 68 69 63 68 20 | 61 72 65 20 65 78 70 6c |.Xwhich |are expl|
|00001db0| 61 69 6e 65 64 20 69 6e | 20 61 20 6c 61 74 65 72 |ained in| a later|
|00001dc0| 20 73 65 63 74 69 6f 6e | 2e 0a 58 2e 4c 50 0a 58 | section|..X.LP.X|
|00001dd0| 4e 61 6d 65 20 64 65 66 | 69 6e 69 74 69 6f 6e 73 |Name def|initions|
|00001de0| 20 68 61 76 65 20 74 68 | 65 20 66 6f 72 6d 3a 0a | have th|e form:.|
|00001df0| 58 2e 6e 66 0a 58 0a 58 | 20 20 20 20 6e 61 6d 65 |X.nf.X.X| name|
|00001e00| 20 64 65 66 69 6e 69 74 | 69 6f 6e 0a 58 0a 58 2e | definit|ion.X.X.|
|00001e10| 66 69 0a 58 54 68 65 20 | 22 6e 61 6d 65 22 20 69 |fi.XThe |"name" i|
|00001e20| 73 20 61 20 77 6f 72 64 | 20 62 65 67 69 6e 6e 69 |s a word| beginni|
|00001e30| 6e 67 20 77 69 74 68 20 | 61 20 6c 65 74 74 65 72 |ng with |a letter|
|00001e40| 20 6f 72 20 61 6e 20 75 | 6e 64 65 72 73 63 6f 72 | or an u|nderscor|
|00001e50| 65 20 28 27 5f 27 29 0a | 58 66 6f 6c 6c 6f 77 65 |e ('_').|Xfollowe|
|00001e60| 64 20 62 79 20 7a 65 72 | 6f 20 6f 72 20 6d 6f 72 |d by zer|o or mor|
|00001e70| 65 20 6c 65 74 74 65 72 | 73 2c 20 64 69 67 69 74 |e letter|s, digit|
|00001e80| 73 2c 20 27 5f 27 2c 20 | 6f 72 20 27 2d 27 20 28 |s, '_', |or '-' (|
|00001e90| 64 61 73 68 29 2e 0a 58 | 54 68 65 20 64 65 66 69 |dash)..X|The defi|
|00001ea0| 6e 69 74 69 6f 6e 20 69 | 73 20 74 61 6b 65 6e 20 |nition i|s taken |
|00001eb0| 74 6f 20 62 65 67 69 6e | 20 61 74 20 74 68 65 20 |to begin| at the |
|00001ec0| 66 69 72 73 74 20 6e 6f | 6e 2d 77 68 69 74 65 2d |first no|n-white-|
|00001ed0| 73 70 61 63 65 20 63 68 | 61 72 61 63 74 65 72 0a |space ch|aracter.|
|00001ee0| 58 66 6f 6c 6c 6f 77 69 | 6e 67 20 74 68 65 20 6e |Xfollowi|ng the n|
|00001ef0| 61 6d 65 20 61 6e 64 20 | 63 6f 6e 74 69 6e 75 69 |ame and |continui|
|00001f00| 6e 67 20 74 6f 20 74 68 | 65 20 65 6e 64 20 6f 66 |ng to th|e end of|
|00001f10| 20 74 68 65 20 6c 69 6e | 65 2e 0a 58 54 68 65 20 | the lin|e..XThe |
|00001f20| 64 65 66 69 6e 69 74 69 | 6f 6e 20 63 61 6e 20 73 |definiti|on can s|
|00001f30| 75 62 73 65 71 75 65 6e | 74 6c 79 20 62 65 20 72 |ubsequen|tly be r|
|00001f40| 65 66 65 72 72 65 64 20 | 74 6f 20 75 73 69 6e 67 |eferred |to using|
|00001f50| 20 22 7b 6e 61 6d 65 7d | 22 2c 20 77 68 69 63 68 | "{name}|", which|
|00001f60| 0a 58 77 69 6c 6c 20 65 | 78 70 61 6e 64 20 74 6f |.Xwill e|xpand to|
|00001f70| 20 22 28 64 65 66 69 6e | 69 74 69 6f 6e 29 22 2e | "(defin|ition)".|
|00001f80| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 2c 0a 58 | For ex|ample,.X|
|00001f90| 2e 6e 66 0a 58 0a 58 20 | 20 20 20 44 49 47 49 54 |.nf.X.X | DIGIT|
|00001fa0| 20 20 20 20 5b 30 2d 39 | 5d 0a 58 20 20 20 20 49 | [0-9|].X I|
|00001fb0| 44 20 20 20 20 20 20 20 | 5b 61 2d 7a 5d 5b 61 2d |D |[a-z][a-|
|00001fc0| 7a 30 2d 39 5d 2a 0a 58 | 0a 58 2e 66 69 0a 58 64 |z0-9]*.X|.X.fi.Xd|
|00001fd0| 65 66 69 6e 65 73 20 22 | 44 49 47 49 54 22 20 74 |efines "|DIGIT" t|
|00001fe0| 6f 20 62 65 20 61 20 72 | 65 67 75 6c 61 72 20 65 |o be a r|egular e|
|00001ff0| 78 70 72 65 73 73 69 6f | 6e 20 77 68 69 63 68 20 |xpressio|n which |
|00002000| 6d 61 74 63 68 65 73 20 | 61 0a 58 73 69 6e 67 6c |matches |a.Xsingl|
|00002010| 65 20 64 69 67 69 74 2c | 20 61 6e 64 0a 58 22 49 |e digit,| and.X"I|
|00002020| 44 22 20 74 6f 20 62 65 | 20 61 20 72 65 67 75 6c |D" to be| a regul|
|00002030| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 20 77 68 |ar expre|ssion wh|
|00002040| 69 63 68 20 6d 61 74 63 | 68 65 73 20 61 20 6c 65 |ich matc|hes a le|
|00002050| 74 74 65 72 0a 58 66 6f | 6c 6c 6f 77 65 64 20 62 |tter.Xfo|llowed b|
|00002060| 79 20 7a 65 72 6f 2d 6f | 72 2d 6d 6f 72 65 20 6c |y zero-o|r-more l|
|00002070| 65 74 74 65 72 73 2d 6f | 72 2d 64 69 67 69 74 73 |etters-o|r-digits|
|00002080| 2e 0a 58 41 20 73 75 62 | 73 65 71 75 65 6e 74 20 |..XA sub|sequent |
|00002090| 72 65 66 65 72 65 6e 63 | 65 20 74 6f 0a 58 2e 6e |referenc|e to.X.n|
|000020a0| 66 0a 58 0a 58 20 20 20 | 20 7b 44 49 47 49 54 7d |f.X.X | {DIGIT}|
|000020b0| 2b 22 2e 22 7b 44 49 47 | 49 54 7d 2a 0a 58 0a 58 |+"."{DIG|IT}*.X.X|
|000020c0| 2e 66 69 0a 58 69 73 20 | 69 64 65 6e 74 69 63 61 |.fi.Xis |identica|
|000020d0| 6c 20 74 6f 0a 58 2e 6e | 66 0a 58 0a 58 20 20 20 |l to.X.n|f.X.X |
|000020e0| 20 28 5b 30 2d 39 5d 29 | 2b 22 2e 22 28 5b 30 2d | ([0-9])|+"."([0-|
|000020f0| 39 5d 29 2a 0a 58 0a 58 | 2e 66 69 0a 58 61 6e 64 |9])*.X.X|.fi.Xand|
|00002100| 20 6d 61 74 63 68 65 73 | 20 6f 6e 65 2d 6f 72 2d | matches| one-or-|
|00002110| 6d 6f 72 65 20 64 69 67 | 69 74 73 20 66 6f 6c 6c |more dig|its foll|
|00002120| 6f 77 65 64 20 62 79 20 | 61 20 27 2e 27 20 66 6f |owed by |a '.' fo|
|00002130| 6c 6c 6f 77 65 64 0a 58 | 62 79 20 7a 65 72 6f 2d |llowed.X|by zero-|
|00002140| 6f 72 2d 6d 6f 72 65 20 | 64 69 67 69 74 73 2e 0a |or-more |digits..|
|00002150| 58 2e 4c 50 0a 58 54 68 | 65 0a 58 2e 49 20 72 75 |X.LP.XTh|e.X.I ru|
|00002160| 6c 65 73 0a 58 73 65 63 | 74 69 6f 6e 20 6f 66 20 |les.Xsec|tion of |
|00002170| 74 68 65 0a 58 2e 49 20 | 66 6c 65 78 0a 58 69 6e |the.X.I |flex.Xin|
|00002180| 70 75 74 20 63 6f 6e 74 | 61 69 6e 73 20 61 20 73 |put cont|ains a s|
|00002190| 65 72 69 65 73 20 6f 66 | 20 72 75 6c 65 73 20 6f |eries of| rules o|
|000021a0| 66 20 74 68 65 20 66 6f | 72 6d 3a 0a 58 2e 6e 66 |f the fo|rm:.X.nf|
|000021b0| 0a 58 0a 58 20 20 20 20 | 70 61 74 74 65 72 6e 20 |.X.X |pattern |
|000021c0| 20 20 61 63 74 69 6f 6e | 0a 58 0a 58 2e 66 69 0a | action|.X.X.fi.|
|000021d0| 58 77 68 65 72 65 20 74 | 68 65 20 70 61 74 74 65 |Xwhere t|he patte|
|000021e0| 72 6e 20 6d 75 73 74 20 | 62 65 20 75 6e 69 6e 64 |rn must |be unind|
|000021f0| 65 6e 74 65 64 20 61 6e | 64 20 74 68 65 20 61 63 |ented an|d the ac|
|00002200| 74 69 6f 6e 20 6d 75 73 | 74 20 62 65 67 69 6e 0a |tion mus|t begin.|
|00002210| 58 6f 6e 20 74 68 65 20 | 73 61 6d 65 20 6c 69 6e |Xon the |same lin|
|00002220| 65 2e 0a 58 2e 4c 50 0a | 58 53 65 65 20 62 65 6c |e..X.LP.|XSee bel|
|00002230| 6f 77 20 66 6f 72 20 61 | 20 66 75 72 74 68 65 72 |ow for a| further|
|00002240| 20 64 65 73 63 72 69 70 | 74 69 6f 6e 20 6f 66 20 | descrip|tion of |
|00002250| 70 61 74 74 65 72 6e 73 | 20 61 6e 64 20 61 63 74 |patterns| and act|
|00002260| 69 6f 6e 73 2e 0a 58 2e | 4c 50 0a 58 46 69 6e 61 |ions..X.|LP.XFina|
|00002270| 6c 6c 79 2c 20 74 68 65 | 20 75 73 65 72 20 63 6f |lly, the| user co|
|00002280| 64 65 20 73 65 63 74 69 | 6f 6e 20 69 73 20 73 69 |de secti|on is si|
|00002290| 6d 70 6c 79 20 63 6f 70 | 69 65 64 20 74 6f 0a 58 |mply cop|ied to.X|
|000022a0| 2e 42 20 6c 65 78 2e 79 | 79 2e 63 0a 58 76 65 72 |.B lex.y|y.c.Xver|
|000022b0| 62 61 74 69 6d 2e 0a 58 | 49 74 20 69 73 20 75 73 |batim..X|It is us|
|000022c0| 65 64 20 66 6f 72 20 63 | 6f 6d 70 61 6e 69 6f 6e |ed for c|ompanion|
|000022d0| 20 72 6f 75 74 69 6e 65 | 73 20 77 68 69 63 68 20 | routine|s which |
|000022e0| 63 61 6c 6c 20 6f 72 20 | 61 72 65 20 63 61 6c 6c |call or |are call|
|000022f0| 65 64 0a 58 62 79 20 74 | 68 65 20 73 63 61 6e 6e |ed.Xby t|he scann|
|00002300| 65 72 2e 20 20 54 68 65 | 20 70 72 65 73 65 6e 63 |er. The| presenc|
|00002310| 65 20 6f 66 20 74 68 69 | 73 20 73 65 63 74 69 6f |e of thi|s sectio|
|00002320| 6e 20 69 73 20 6f 70 74 | 69 6f 6e 61 6c 3b 0a 58 |n is opt|ional;.X|
|00002330| 69 66 20 69 74 20 69 73 | 20 6d 69 73 73 69 6e 67 |if it is| missing|
|00002340| 2c 20 74 68 65 20 73 65 | 63 6f 6e 64 0a 58 2e 42 |, the se|cond.X.B|
|00002350| 20 25 25 0a 58 69 6e 20 | 74 68 65 20 69 6e 70 75 | %%.Xin |the inpu|
|00002360| 74 20 66 69 6c 65 20 6d | 61 79 20 62 65 20 73 6b |t file m|ay be sk|
|00002370| 69 70 70 65 64 2c 20 74 | 6f 6f 2e 0a 58 2e 4c 50 |ipped, t|oo..X.LP|
|00002380| 0a 58 49 6e 20 74 68 65 | 20 64 65 66 69 6e 69 74 |.XIn the| definit|
|00002390| 69 6f 6e 73 20 61 6e 64 | 20 72 75 6c 65 73 20 73 |ions and| rules s|
|000023a0| 65 63 74 69 6f 6e 73 2c | 20 61 6e 79 0a 58 2e 49 |ections,| any.X.I|
|000023b0| 20 69 6e 64 65 6e 74 65 | 64 0a 58 74 65 78 74 20 | indente|d.Xtext |
|000023c0| 6f 72 20 74 65 78 74 20 | 65 6e 63 6c 6f 73 65 64 |or text |enclosed|
|000023d0| 20 69 6e 0a 58 2e 42 20 | 25 7b 0a 58 61 6e 64 0a | in.X.B |%{.Xand.|
|000023e0| 58 2e 42 20 25 7d 0a 58 | 69 73 20 63 6f 70 69 65 |X.B %}.X|is copie|
|000023f0| 64 20 76 65 72 62 61 74 | 69 6d 20 74 6f 20 74 68 |d verbat|im to th|
|00002400| 65 20 6f 75 74 70 75 74 | 20 28 77 69 74 68 20 74 |e output| (with t|
|00002410| 68 65 20 25 7b 7d 27 73 | 20 72 65 6d 6f 76 65 64 |he %{}'s| removed|
|00002420| 29 2e 0a 58 54 68 65 20 | 25 7b 7d 27 73 20 6d 75 |)..XThe |%{}'s mu|
|00002430| 73 74 20 61 70 70 65 61 | 72 20 75 6e 69 6e 64 65 |st appea|r uninde|
|00002440| 6e 74 65 64 20 6f 6e 20 | 6c 69 6e 65 73 20 62 79 |nted on |lines by|
|00002450| 20 74 68 65 6d 73 65 6c | 76 65 73 2e 0a 58 2e 4c | themsel|ves..X.L|
|00002460| 50 0a 58 49 6e 20 74 68 | 65 20 72 75 6c 65 73 20 |P.XIn th|e rules |
|00002470| 73 65 63 74 69 6f 6e 2c | 0a 58 61 6e 79 20 69 6e |section,|.Xany in|
|00002480| 64 65 6e 74 65 64 20 6f | 72 20 25 7b 7d 20 74 65 |dented o|r %{} te|
|00002490| 78 74 20 61 70 70 65 61 | 72 69 6e 67 20 62 65 66 |xt appea|ring bef|
|000024a0| 6f 72 65 20 74 68 65 0a | 58 66 69 72 73 74 20 72 |ore the.|Xfirst r|
|000024b0| 75 6c 65 20 6d 61 79 20 | 62 65 20 75 73 65 64 20 |ule may |be used |
|000024c0| 74 6f 20 64 65 63 6c 61 | 72 65 20 76 61 72 69 61 |to decla|re varia|
|000024d0| 62 6c 65 73 0a 58 77 68 | 69 63 68 20 61 72 65 20 |bles.Xwh|ich are |
|000024e0| 6c 6f 63 61 6c 20 74 6f | 20 74 68 65 20 73 63 61 |local to| the sca|
|000024f0| 6e 6e 69 6e 67 20 72 6f | 75 74 69 6e 65 20 61 6e |nning ro|utine an|
|00002500| 64 20 28 61 66 74 65 72 | 20 74 68 65 20 64 65 63 |d (after| the dec|
|00002510| 6c 61 72 61 74 69 6f 6e | 73 29 0a 58 63 6f 64 65 |laration|s).Xcode|
|00002520| 20 77 68 69 63 68 20 69 | 73 20 74 6f 20 62 65 20 | which i|s to be |
|00002530| 65 78 65 63 75 74 65 64 | 20 77 68 65 6e 65 76 65 |executed| wheneve|
|00002540| 72 20 74 68 65 20 73 63 | 61 6e 6e 69 6e 67 20 72 |r the sc|anning r|
|00002550| 6f 75 74 69 6e 65 20 69 | 73 20 65 6e 74 65 72 65 |outine i|s entere|
|00002560| 64 2e 0a 58 4f 74 68 65 | 72 20 69 6e 64 65 6e 74 |d..XOthe|r indent|
|00002570| 65 64 20 6f 72 20 25 7b | 7d 20 74 65 78 74 20 69 |ed or %{|} text i|
|00002580| 6e 20 74 68 65 20 72 75 | 6c 65 20 73 65 63 74 69 |n the ru|le secti|
|00002590| 6f 6e 20 69 73 20 73 74 | 69 6c 6c 20 63 6f 70 69 |on is st|ill copi|
|000025a0| 65 64 20 74 6f 20 74 68 | 65 20 6f 75 74 70 75 74 |ed to th|e output|
|000025b0| 2c 0a 58 62 75 74 20 69 | 74 73 20 6d 65 61 6e 69 |,.Xbut i|ts meani|
|000025c0| 6e 67 20 69 73 20 6e 6f | 74 20 77 65 6c 6c 2d 64 |ng is no|t well-d|
|000025d0| 65 66 69 6e 65 64 20 61 | 6e 64 20 69 74 20 6d 61 |efined a|nd it ma|
|000025e0| 79 20 77 65 6c 6c 20 63 | 61 75 73 65 20 63 6f 6d |y well c|ause com|
|000025f0| 70 69 6c 65 2d 74 69 6d | 65 0a 58 65 72 72 6f 72 |pile-tim|e.Xerror|
|00002600| 73 20 28 74 68 69 73 20 | 66 65 61 74 75 72 65 20 |s (this |feature |
|00002610| 69 73 20 70 72 65 73 65 | 6e 74 20 66 6f 72 0a 58 |is prese|nt for.X|
|00002620| 2e 49 20 50 4f 53 49 58 | 0a 58 63 6f 6d 70 6c 69 |.I POSIX|.Xcompli|
|00002630| 61 6e 63 65 3b 20 73 65 | 65 20 62 65 6c 6f 77 20 |ance; se|e below |
|00002640| 66 6f 72 20 6f 74 68 65 | 72 20 73 75 63 68 20 66 |for othe|r such f|
|00002650| 65 61 74 75 72 65 73 29 | 2e 0a 58 2e 4c 50 0a 58 |eatures)|..X.LP.X|
|00002660| 49 6e 20 74 68 65 20 64 | 65 66 69 6e 69 74 69 6f |In the d|efinitio|
|00002670| 6e 73 20 73 65 63 74 69 | 6f 6e 2c 20 61 6e 20 75 |ns secti|on, an u|
|00002680| 6e 69 6e 64 65 6e 74 65 | 64 20 63 6f 6d 6d 65 6e |nindente|d commen|
|00002690| 74 20 28 69 2e 65 2e 2c | 20 61 20 6c 69 6e 65 0a |t (i.e.,| a line.|
|000026a0| 58 62 65 67 69 6e 6e 69 | 6e 67 20 77 69 74 68 20 |Xbeginni|ng with |
|000026b0| 22 2f 2a 22 29 20 69 73 | 20 61 6c 73 6f 20 63 6f |"/*") is| also co|
|000026c0| 70 69 65 64 20 76 65 72 | 62 61 74 69 6d 20 74 6f |pied ver|batim to|
|000026d0| 20 74 68 65 20 6f 75 74 | 70 75 74 20 75 70 0a 58 | the out|put up.X|
|000026e0| 74 6f 20 74 68 65 20 6e | 65 78 74 20 22 2a 2f 22 |to the n|ext "*/"|
|000026f0| 2e 20 20 41 6c 73 6f 2c | 20 61 6e 79 20 6c 69 6e |. Also,| any lin|
|00002700| 65 20 69 6e 20 74 68 65 | 20 64 65 66 69 6e 69 74 |e in the| definit|
|00002710| 69 6f 6e 73 20 73 65 63 | 74 69 6f 6e 0a 58 62 65 |ions sec|tion.Xbe|
|00002720| 67 69 6e 6e 69 6e 67 20 | 77 69 74 68 20 27 23 27 |ginning |with '#'|
|00002730| 20 69 73 20 69 67 6e 6f | 72 65 64 2c 20 74 68 6f | is igno|red, tho|
|00002740| 75 67 68 20 74 68 69 73 | 20 73 74 79 6c 65 20 6f |ugh this| style o|
|00002750| 66 20 63 6f 6d 6d 65 6e | 74 20 69 73 0a 58 64 65 |f commen|t is.Xde|
|00002760| 70 72 65 63 61 74 65 64 | 20 61 6e 64 20 6d 61 79 |precated| and may|
|00002770| 20 67 6f 20 61 77 61 79 | 20 69 6e 20 74 68 65 20 | go away| in the |
|00002780| 66 75 74 75 72 65 2e 0a | 58 2e 53 48 20 50 41 54 |future..|X.SH PAT|
|00002790| 54 45 52 4e 53 0a 58 54 | 68 65 20 70 61 74 74 65 |TERNS.XT|he patte|
|000027a0| 72 6e 73 20 69 6e 20 74 | 68 65 20 69 6e 70 75 74 |rns in t|he input|
|000027b0| 20 61 72 65 20 77 72 69 | 74 74 65 6e 20 75 73 69 | are wri|tten usi|
|000027c0| 6e 67 20 61 6e 20 65 78 | 74 65 6e 64 65 64 20 73 |ng an ex|tended s|
|000027d0| 65 74 20 6f 66 20 72 65 | 67 75 6c 61 72 0a 58 65 |et of re|gular.Xe|
|000027e0| 78 70 72 65 73 73 69 6f | 6e 73 2e 20 20 54 68 65 |xpressio|ns. The|
|000027f0| 73 65 20 61 72 65 3a 0a | 58 2e 6e 66 0a 58 0a 58 |se are:.|X.nf.X.X|
|00002800| 20 20 20 20 78 20 20 20 | 20 20 20 20 20 20 20 6d | x | m|
|00002810| 61 74 63 68 20 74 68 65 | 20 63 68 61 72 61 63 74 |atch the| charact|
|00002820| 65 72 20 27 78 27 0a 58 | 20 20 20 20 2e 20 20 20 |er 'x'.X| . |
|00002830| 20 20 20 20 20 20 20 61 | 6e 79 20 63 68 61 72 61 | a|ny chara|
|00002840| 63 74 65 72 20 65 78 63 | 65 70 74 20 6e 65 77 6c |cter exc|ept newl|
|00002850| 69 6e 65 0a 58 20 20 20 | 20 5b 78 79 7a 5d 20 20 |ine.X | [xyz] |
|00002860| 20 20 20 20 61 20 22 63 | 68 61 72 61 63 74 65 72 | a "c|haracter|
|00002870| 20 63 6c 61 73 73 22 3b | 20 69 6e 20 74 68 69 73 | class";| in this|
|00002880| 20 63 61 73 65 2c 20 74 | 68 65 20 70 61 74 74 65 | case, t|he patte|
|00002890| 72 6e 0a 58 20 20 20 20 | 20 20 20 20 20 20 20 20 |rn.X | |
|000028a0| 20 20 20 20 20 6d 61 74 | 63 68 65 73 20 65 69 74 | mat|ches eit|
|000028b0| 68 65 72 20 61 6e 20 27 | 78 27 2c 20 61 20 27 79 |her an '|x', a 'y|
|000028c0| 27 2c 20 6f 72 20 61 20 | 27 7a 27 0a 58 20 20 20 |', or a |'z'.X |
|000028d0| 20 5b 61 62 6a 2d 6f 5a | 5d 20 20 20 61 20 22 63 | [abj-oZ|] a "c|
|000028e0| 68 61 72 61 63 74 65 72 | 20 63 6c 61 73 73 22 20 |haracter| class" |
|000028f0| 77 69 74 68 20 61 20 72 | 61 6e 67 65 20 69 6e 20 |with a r|ange in |
|00002900| 69 74 3b 20 6d 61 74 63 | 68 65 73 0a 58 20 20 20 |it; matc|hes.X |
|00002910| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 61 6e | | an|
|00002920| 20 27 61 27 2c 20 61 20 | 27 62 27 2c 20 61 6e 79 | 'a', a |'b', any|
|00002930| 20 6c 65 74 74 65 72 20 | 66 72 6f 6d 20 27 6a 27 | letter |from 'j'|
|00002940| 20 74 68 72 6f 75 67 68 | 20 27 6f 27 2c 0a 58 20 | through| 'o',.X |
|00002950| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002960| 6f 72 20 61 20 27 5a 27 | 0a 58 20 20 20 20 5b 5e |or a 'Z'|.X [^|
|00002970| 41 2d 5a 5d 20 20 20 20 | 20 61 20 22 6e 65 67 61 |A-Z] | a "nega|
|00002980| 74 65 64 20 63 68 61 72 | 61 63 74 65 72 20 63 6c |ted char|acter cl|
|00002990| 61 73 73 22 2c 20 69 2e | 65 2e 2c 20 61 6e 79 20 |ass", i.|e., any |
|000029a0| 63 68 61 72 61 63 74 65 | 72 0a 58 20 20 20 20 20 |characte|r.X |
|000029b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 62 75 74 20 | | but |
|000029c0| 74 68 6f 73 65 20 69 6e | 20 74 68 65 20 63 6c 61 |those in| the cla|
|000029d0| 73 73 2e 20 20 49 6e 20 | 74 68 69 73 20 63 61 73 |ss. In |this cas|
|000029e0| 65 2c 20 61 6e 79 0a 58 | 20 20 20 20 20 20 20 20 |e, any.X| |
|000029f0| 20 20 20 20 20 20 20 20 | 20 63 68 61 72 61 63 74 | | charact|
|00002a00| 65 72 20 45 58 43 45 50 | 54 20 61 6e 20 75 70 70 |er EXCEP|T an upp|
|00002a10| 65 72 63 61 73 65 20 6c | 65 74 74 65 72 2e 0a 58 |ercase l|etter..X|
|00002a20| 20 20 20 20 5b 5e 41 2d | 5a 5c 5c 6e 5d 20 20 20 | [^A-|Z\\n] |
|00002a30| 61 6e 79 20 63 68 61 72 | 61 63 74 65 72 20 45 58 |any char|acter EX|
|00002a40| 43 45 50 54 20 61 6e 20 | 75 70 70 65 72 63 61 73 |CEPT an |uppercas|
|00002a50| 65 20 6c 65 74 74 65 72 | 20 6f 72 0a 58 20 20 20 |e letter| or.X |
|00002a60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 61 20 | | a |
|00002a70| 6e 65 77 6c 69 6e 65 0a | 58 20 20 20 20 72 2a 20 |newline.|X r* |
|00002a80| 20 20 20 20 20 20 20 20 | 7a 65 72 6f 20 6f 72 20 | |zero or |
|00002a90| 6d 6f 72 65 20 72 27 73 | 2c 20 77 68 65 72 65 20 |more r's|, where |
|00002aa0| 72 20 69 73 20 61 6e 79 | 20 72 65 67 75 6c 61 72 |r is any| regular|
|00002ab0| 20 65 78 70 72 65 73 73 | 69 6f 6e 0a 58 20 20 20 | express|ion.X |
|00002ac0| 20 72 2b 20 20 20 20 20 | 20 20 20 20 6f 6e 65 20 | r+ | one |
|00002ad0| 6f 72 20 6d 6f 72 65 20 | 72 27 73 0a 58 20 20 20 |or more |r's.X |
|00002ae0| 20 72 3f 20 20 20 20 20 | 20 20 20 20 7a 65 72 6f | r? | zero|
|00002af0| 20 6f 72 20 6f 6e 65 20 | 72 27 73 20 28 74 68 61 | or one |r's (tha|
|00002b00| 74 20 69 73 2c 20 22 61 | 6e 20 6f 70 74 69 6f 6e |t is, "a|n option|
|00002b10| 61 6c 20 72 22 29 0a 58 | 20 20 20 20 72 7b 32 2c |al r").X| r{2,|
|00002b20| 35 7d 20 20 20 20 20 61 | 6e 79 77 68 65 72 65 20 |5} a|nywhere |
|00002b30| 66 72 6f 6d 20 74 77 6f | 20 74 6f 20 66 69 76 65 |from two| to five|
|00002b40| 20 72 27 73 0a 58 20 20 | 20 20 72 7b 32 2c 7d 20 | r's.X | r{2,} |
|00002b50| 20 20 20 20 20 74 77 6f | 20 6f 72 20 6d 6f 72 65 | two| or more|
|00002b60| 20 72 27 73 0a 58 20 20 | 20 20 72 7b 34 7d 20 20 | r's.X | r{4} |
|00002b70| 20 20 20 20 20 65 78 61 | 63 74 6c 79 20 34 20 72 | exa|ctly 4 r|
|00002b80| 27 73 0a 58 20 20 20 20 | 7b 6e 61 6d 65 7d 20 20 |'s.X |{name} |
|00002b90| 20 20 20 74 68 65 20 65 | 78 70 61 6e 73 69 6f 6e | the e|xpansion|
|00002ba0| 20 6f 66 20 74 68 65 20 | 22 6e 61 6d 65 22 20 64 | of the |"name" d|
|00002bb0| 65 66 69 6e 69 74 69 6f | 6e 0a 58 20 20 20 20 20 |efinitio|n.X |
|00002bc0| 20 20 20 20 20 20 20 20 | 20 20 28 73 65 65 20 61 | | (see a|
|00002bd0| 62 6f 76 65 29 0a 58 20 | 20 20 20 22 5b 78 79 7a |bove).X | "[xyz|
|00002be0| 5d 5c 5c 22 66 6f 6f 22 | 0a 58 20 20 20 20 20 20 |]\\"foo"|.X |
|00002bf0| 20 20 20 20 20 20 20 20 | 20 74 68 65 20 6c 69 74 | | the lit|
|00002c00| 65 72 61 6c 20 73 74 72 | 69 6e 67 3a 20 5b 78 79 |eral str|ing: [xy|
|00002c10| 7a 5d 22 66 6f 6f 0a 58 | 20 20 20 20 5c 5c 58 20 |z]"foo.X| \\X |
|00002c20| 20 20 20 20 20 20 20 20 | 69 66 20 58 20 69 73 20 | |if X is |
|00002c30| 61 6e 20 27 61 27 2c 20 | 27 62 27 2c 20 27 66 27 |an 'a', |'b', 'f'|
|00002c40| 2c 20 27 6e 27 2c 20 27 | 72 27 2c 20 27 74 27 2c |, 'n', '|r', 't',|
|00002c50| 20 6f 72 20 27 76 27 2c | 0a 58 20 20 20 20 20 20 | or 'v',|.X |
|00002c60| 20 20 20 20 20 20 20 20 | 20 20 20 74 68 65 6e 20 | | then |
|00002c70| 74 68 65 20 41 4e 53 49 | 2d 43 20 69 6e 74 65 72 |the ANSI|-C inter|
|00002c80| 70 72 65 74 61 74 69 6f | 6e 20 6f 66 20 5c 5c 78 |pretatio|n of \\x|
|00002c90| 2e 0a 58 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |..X | |
|00002ca0| 20 20 20 20 4f 74 68 65 | 72 77 69 73 65 2c 20 61 | Othe|rwise, a|
|00002cb0| 20 6c 69 74 65 72 61 6c | 20 27 58 27 20 28 75 73 | literal| 'X' (us|
|00002cc0| 65 64 20 74 6f 20 65 73 | 63 61 70 65 0a 58 20 20 |ed to es|cape.X |
|00002cd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 6f | | o|
|00002ce0| 70 65 72 61 74 6f 72 73 | 20 73 75 63 68 20 61 73 |perators| such as|
|00002cf0| 20 27 2a 27 29 0a 58 20 | 20 20 20 5c 5c 31 32 33 | '*').X | \\123|
|00002d00| 20 20 20 20 20 20 20 74 | 68 65 20 63 68 61 72 61 | t|he chara|
|00002d10| 63 74 65 72 20 77 69 74 | 68 20 6f 63 74 61 6c 20 |cter wit|h octal |
|00002d20| 76 61 6c 75 65 20 31 32 | 33 0a 58 20 20 20 20 5c |value 12|3.X \|
|00002d30| 5c 78 32 61 20 20 20 20 | 20 20 20 74 68 65 20 63 |\x2a | the c|
|00002d40| 68 61 72 61 63 74 65 72 | 20 77 69 74 68 20 68 65 |haracter| with he|
|00002d50| 78 61 64 65 63 69 6d 61 | 6c 20 76 61 6c 75 65 20 |xadecima|l value |
|00002d60| 32 61 0a 58 20 20 20 20 | 28 72 29 20 20 20 20 20 |2a.X |(r) |
|00002d70| 20 20 20 6d 61 74 63 68 | 20 61 6e 20 72 3b 20 70 | match| an r; p|
|00002d80| 61 72 65 6e 74 68 65 73 | 65 73 20 61 72 65 20 75 |arenthes|es are u|
|00002d90| 73 65 64 20 74 6f 20 6f | 76 65 72 72 69 64 65 0a |sed to o|verride.|
|00002da0| 58 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |X | |
|00002db0| 20 20 70 72 65 63 65 64 | 65 6e 63 65 20 28 73 65 | preced|ence (se|
|00002dc0| 65 20 62 65 6c 6f 77 29 | 0a 58 0a 58 0a 58 20 20 |e below)|.X.X.X |
|00002dd0| 20 20 72 73 20 20 20 20 | 20 20 20 20 20 74 68 65 | rs | the|
|00002de0| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00002df0| 69 6f 6e 20 72 20 66 6f | 6c 6c 6f 77 65 64 20 62 |ion r fo|llowed b|
|00002e00| 79 20 74 68 65 0a 58 20 | 20 20 20 20 20 20 20 20 |y the.X | |
|00002e10| 20 20 20 20 20 20 20 20 | 72 65 67 75 6c 61 72 20 | |regular |
|00002e20| 65 78 70 72 65 73 73 69 | 6f 6e 20 73 3b 20 63 61 |expressi|on s; ca|
|00002e30| 6c 6c 65 64 20 22 63 6f | 6e 63 61 74 65 6e 61 74 |lled "co|ncatenat|
|00002e40| 69 6f 6e 22 0a 58 0a 58 | 0a 58 20 20 20 20 72 7c |ion".X.X|.X r||
|00002e50| 73 20 20 20 20 20 20 20 | 20 65 69 74 68 65 72 20 |s | either |
|00002e60| 61 6e 20 72 20 6f 72 20 | 61 6e 20 73 0a 58 0a 58 |an r or |an s.X.X|
|00002e70| 0a 58 20 20 20 20 72 2f | 73 20 20 20 20 20 20 20 |.X r/|s |
|00002e80| 20 61 6e 20 72 20 62 75 | 74 20 6f 6e 6c 79 20 69 | an r bu|t only i|
|00002e90| 66 20 69 74 20 69 73 20 | 66 6f 6c 6c 6f 77 65 64 |f it is |followed|
|00002ea0| 20 62 79 20 61 6e 20 73 | 2e 20 20 54 68 65 0a 58 | by an s|. The.X|
|00002eb0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002ec0| 20 73 20 69 73 20 6e 6f | 74 20 70 61 72 74 20 6f | s is no|t part o|
|00002ed0| 66 20 74 68 65 20 6d 61 | 74 63 68 65 64 20 74 65 |f the ma|tched te|
|00002ee0| 78 74 2e 20 20 54 68 69 | 73 20 74 79 70 65 0a 58 |xt. Thi|s type.X|
|00002ef0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00002f00| 20 6f 66 20 70 61 74 74 | 65 72 6e 20 69 73 20 63 | of patt|ern is c|
|00002f10| 61 6c 6c 65 64 20 61 73 | 20 22 74 72 61 69 6c 69 |alled as| "traili|
|00002f20| 6e 67 20 63 6f 6e 74 65 | 78 74 22 2e 0a 58 20 20 |ng conte|xt"..X |
|00002f30| 20 20 5e 72 20 20 20 20 | 20 20 20 20 20 61 6e 20 | ^r | an |
|00002f40| 72 2c 20 62 75 74 20 6f | 6e 6c 79 20 61 74 20 74 |r, but o|nly at t|
|00002f50| 68 65 20 62 65 67 69 6e | 6e 69 6e 67 20 6f 66 20 |he begin|ning of |
|00002f60| 61 20 6c 69 6e 65 0a 58 | 20 20 20 20 72 24 20 20 |a line.X| r$ |
|00002f70| 20 20 20 20 20 20 20 61 | 6e 20 72 2c 20 62 75 74 | a|n r, but|
|00002f80| 20 6f 6e 6c 79 20 61 74 | 20 74 68 65 20 65 6e 64 | only at| the end|
|00002f90| 20 6f 66 20 61 20 6c 69 | 6e 65 2e 20 20 45 71 75 | of a li|ne. Equ|
|00002fa0| 69 76 61 6c 65 6e 74 0a | 58 20 20 20 20 20 20 20 |ivalent.|X |
|00002fb0| 20 20 20 20 20 20 20 20 | 20 20 74 6f 20 22 72 2f | | to "r/|
|00002fc0| 5c 5c 6e 22 2e 0a 58 0a | 58 0a 58 20 20 20 20 3c |\\n"..X.|X.X <|
|00002fd0| 73 3e 72 20 20 20 20 20 | 20 20 61 6e 20 72 2c 20 |s>r | an r, |
|00002fe0| 62 75 74 20 6f 6e 6c 79 | 20 69 6e 20 73 74 61 72 |but only| in star|
|00002ff0| 74 20 63 6f 6e 64 69 74 | 69 6f 6e 20 73 20 28 73 |t condit|ion s (s|
|00003000| 65 65 0a 58 20 20 20 20 | 20 20 20 20 20 20 20 20 |ee.X | |
|00003010| 20 20 20 62 65 6c 6f 77 | 20 66 6f 72 20 64 69 73 | below| for dis|
|00003020| 63 75 73 73 69 6f 6e 20 | 6f 66 20 73 74 61 72 74 |cussion |of start|
|00003030| 20 63 6f 6e 64 69 74 69 | 6f 6e 73 29 0a 58 20 20 | conditi|ons).X |
|00003040| 20 20 3c 73 31 2c 73 32 | 2c 73 33 3e 72 0a 58 20 | <s1,s2|,s3>r.X |
|00003050| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 73 61 | | sa|
|00003060| 6d 65 2c 20 62 75 74 20 | 69 6e 20 61 6e 79 20 6f |me, but |in any o|
|00003070| 66 20 73 74 61 72 74 20 | 63 6f 6e 64 69 74 69 6f |f start |conditio|
|00003080| 6e 73 20 73 31 2c 0a 58 | 20 20 20 20 20 20 20 20 |ns s1,.X| |
|00003090| 20 20 20 20 20 20 20 73 | 32 2c 20 6f 72 20 73 33 | s|2, or s3|
|000030a0| 0a 58 0a 58 0a 58 20 20 | 20 20 3c 3c 45 4f 46 3e |.X.X.X | <<EOF>|
|000030b0| 3e 20 20 20 20 61 6e 20 | 65 6e 64 2d 6f 66 2d 66 |> an |end-of-f|
|000030c0| 69 6c 65 0a 58 20 20 20 | 20 3c 73 31 2c 73 32 3e |ile.X | <s1,s2>|
|000030d0| 3c 3c 45 4f 46 3e 3e 0a | 58 20 20 20 20 20 20 20 |<<EOF>>.|X |
|000030e0| 20 20 20 20 20 20 20 20 | 61 6e 20 65 6e 64 2d 6f | |an end-o|
|000030f0| 66 2d 66 69 6c 65 20 77 | 68 65 6e 20 69 6e 20 73 |f-file w|hen in s|
|00003100| 74 61 72 74 20 63 6f 6e | 64 69 74 69 6f 6e 20 73 |tart con|dition s|
|00003110| 31 20 6f 72 20 73 32 0a | 58 0a 58 2e 66 69 0a 58 |1 or s2.|X.X.fi.X|
|00003120| 54 68 65 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |The regu|lar expr|
|00003130| 65 73 73 69 6f 6e 73 20 | 6c 69 73 74 65 64 20 61 |essions |listed a|
|00003140| 62 6f 76 65 20 61 72 65 | 20 67 72 6f 75 70 65 64 |bove are| grouped|
|00003150| 20 61 63 63 6f 72 64 69 | 6e 67 20 74 6f 0a 58 70 | accordi|ng to.Xp|
|00003160| 72 65 63 65 64 65 6e 63 | 65 2c 20 66 72 6f 6d 20 |recedenc|e, from |
|00003170| 68 69 67 68 65 73 74 20 | 70 72 65 63 65 64 65 6e |highest |preceden|
|00003180| 63 65 20 61 74 20 74 68 | 65 20 74 6f 70 20 74 6f |ce at th|e top to|
|00003190| 20 6c 6f 77 65 73 74 20 | 61 74 20 74 68 65 20 62 | lowest |at the b|
|000031a0| 6f 74 74 6f 6d 2e 0a 58 | 54 68 6f 73 65 20 67 72 |ottom..X|Those gr|
|000031b0| 6f 75 70 65 64 20 74 6f | 67 65 74 68 65 72 20 68 |ouped to|gether h|
|000031c0| 61 76 65 20 65 71 75 61 | 6c 20 70 72 65 63 65 64 |ave equa|l preced|
|000031d0| 65 6e 63 65 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |ence. F|or examp|
|000031e0| 6c 65 2c 0a 58 2e 6e 66 | 0a 58 0a 58 20 20 20 20 |le,.X.nf|.X.X |
|000031f0| 66 6f 6f 7c 62 61 72 2a | 0a 58 0a 58 2e 66 69 0a |foo|bar*|.X.X.fi.|
|00003200| 58 69 73 20 74 68 65 20 | 73 61 6d 65 20 61 73 0a |Xis the |same as.|
|00003210| 58 2e 6e 66 0a 58 0a 58 | 20 20 20 20 28 66 6f 6f |X.nf.X.X| (foo|
|00003220| 29 7c 28 62 61 28 72 2a | 29 29 0a 58 0a 58 2e 66 |)|(ba(r*|)).X.X.f|
|00003230| 69 0a 58 73 69 6e 63 65 | 20 74 68 65 20 27 2a 27 |i.Xsince| the '*'|
|00003240| 20 6f 70 65 72 61 74 6f | 72 20 68 61 73 20 68 69 | operato|r has hi|
|00003250| 67 68 65 72 20 70 72 65 | 63 65 64 65 6e 63 65 20 |gher pre|cedence |
|00003260| 74 68 61 6e 20 63 6f 6e | 63 61 74 65 6e 61 74 69 |than con|catenati|
|00003270| 6f 6e 2c 0a 58 61 6e 64 | 20 63 6f 6e 63 61 74 65 |on,.Xand| concate|
|00003280| 6e 61 74 69 6f 6e 20 68 | 69 67 68 65 72 20 74 68 |nation h|igher th|
|00003290| 61 6e 20 61 6c 74 65 72 | 6e 61 74 69 6f 6e 20 28 |an alter|nation (|
|000032a0| 27 7c 27 29 2e 20 20 54 | 68 69 73 20 70 61 74 74 |'|'). T|his patt|
|000032b0| 65 72 6e 0a 58 74 68 65 | 72 65 66 6f 72 65 20 6d |ern.Xthe|refore m|
|000032c0| 61 74 63 68 65 73 0a 58 | 2e 49 20 65 69 74 68 65 |atches.X|.I eithe|
|000032d0| 72 0a 58 74 68 65 20 73 | 74 72 69 6e 67 20 22 66 |r.Xthe s|tring "f|
|000032e0| 6f 6f 22 0a 58 2e 49 20 | 6f 72 0a 58 74 68 65 20 |oo".X.I |or.Xthe |
|000032f0| 73 74 72 69 6e 67 20 22 | 62 61 22 20 66 6f 6c 6c |string "|ba" foll|
|00003300| 6f 77 65 64 20 62 79 20 | 7a 65 72 6f 2d 6f 72 2d |owed by |zero-or-|
|00003310| 6d 6f 72 65 20 72 27 73 | 2e 0a 58 54 6f 20 6d 61 |more r's|..XTo ma|
|00003320| 74 63 68 20 22 66 6f 6f | 22 20 6f 72 20 7a 65 72 |tch "foo|" or zer|
|00003330| 6f 2d 6f 72 2d 6d 6f 72 | 65 20 22 62 61 72 22 27 |o-or-mor|e "bar"'|
|00003340| 73 2c 20 75 73 65 3a 0a | 58 2e 6e 66 0a 58 0a 58 |s, use:.|X.nf.X.X|
|00003350| 20 20 20 20 66 6f 6f 7c | 28 62 61 72 29 2a 0a 58 | foo||(bar)*.X|
|00003360| 0a 58 2e 66 69 0a 58 61 | 6e 64 20 74 6f 20 6d 61 |.X.fi.Xa|nd to ma|
|00003370| 74 63 68 20 7a 65 72 6f | 2d 6f 72 2d 6d 6f 72 65 |tch zero|-or-more|
|00003380| 20 22 66 6f 6f 22 27 73 | 2d 6f 72 2d 22 62 61 72 | "foo"'s|-or-"bar|
|00003390| 22 27 73 3a 0a 58 2e 6e | 66 0a 58 0a 58 20 20 20 |"'s:.X.n|f.X.X |
|000033a0| 20 28 66 6f 6f 7c 62 61 | 72 29 2a 0a 58 0a 58 2e | (foo|ba|r)*.X.X.|
|000033b0| 66 69 0a 58 2e 4c 50 0a | 58 53 6f 6d 65 20 6e 6f |fi.X.LP.|XSome no|
|000033c0| 74 65 73 20 6f 6e 20 70 | 61 74 74 65 72 6e 73 3a |tes on p|atterns:|
|000033d0| 0a 58 2e 49 50 20 2d 0a | 58 41 20 6e 65 67 61 74 |.X.IP -.|XA negat|
|000033e0| 65 64 20 63 68 61 72 61 | 63 74 65 72 20 63 6c 61 |ed chara|cter cla|
|000033f0| 73 73 20 73 75 63 68 20 | 61 73 20 74 68 65 20 65 |ss such |as the e|
|00003400| 78 61 6d 70 6c 65 20 22 | 5b 5e 41 2d 5a 5d 22 0a |xample "|[^A-Z]".|
|00003410| 58 61 62 6f 76 65 0a 58 | 2e 49 20 77 69 6c 6c 20 |Xabove.X|.I will |
|00003420| 6d 61 74 63 68 20 61 20 | 6e 65 77 6c 69 6e 65 0a |match a |newline.|
|00003430| 58 75 6e 6c 65 73 73 20 | 22 5c 5c 6e 22 20 28 6f |Xunless |"\\n" (o|
|00003440| 72 20 61 6e 20 65 71 75 | 69 76 61 6c 65 6e 74 20 |r an equ|ivalent |
|00003450| 65 73 63 61 70 65 20 73 | 65 71 75 65 6e 63 65 29 |escape s|equence)|
|00003460| 20 69 73 20 6f 6e 65 20 | 6f 66 20 74 68 65 0a 58 | is one |of the.X|
|00003470| 63 68 61 72 61 63 74 65 | 72 73 20 65 78 70 6c 69 |characte|rs expli|
|00003480| 63 69 74 6c 79 20 70 72 | 65 73 65 6e 74 20 69 6e |citly pr|esent in|
|00003490| 20 74 68 65 20 6e 65 67 | 61 74 65 64 20 63 68 61 | the neg|ated cha|
|000034a0| 72 61 63 74 65 72 20 63 | 6c 61 73 73 0a 58 28 65 |racter c|lass.X(e|
|000034b0| 2e 67 2e 2c 20 22 5b 5e | 41 2d 5a 5c 5c 6e 5d 22 |.g., "[^|A-Z\\n]"|
|000034c0| 29 2e 20 20 54 68 69 73 | 20 69 73 20 75 6e 6c 69 |). This| is unli|
|000034d0| 6b 65 20 68 6f 77 20 6d | 61 6e 79 20 6f 74 68 65 |ke how m|any othe|
|000034e0| 72 20 72 65 67 75 6c 61 | 72 0a 58 65 78 70 72 65 |r regula|r.Xexpre|
|000034f0| 73 73 69 6f 6e 20 74 6f | 6f 6c 73 20 74 72 65 61 |ssion to|ols trea|
|00003500| 74 20 6e 65 67 61 74 65 | 64 20 63 68 61 72 61 63 |t negate|d charac|
|00003510| 74 65 72 20 63 6c 61 73 | 73 65 73 2c 20 62 75 74 |ter clas|ses, but|
|00003520| 20 75 6e 66 6f 72 74 75 | 6e 61 74 65 6c 79 0a 58 | unfortu|nately.X|
|00003530| 74 68 65 20 69 6e 63 6f | 6e 73 69 73 74 65 6e 63 |the inco|nsistenc|
|00003540| 79 20 69 73 20 68 69 73 | 74 6f 72 69 63 61 6c 6c |y is his|toricall|
|00003550| 79 20 65 6e 74 72 65 6e | 63 68 65 64 2e 0a 58 4d |y entren|ched..XM|
|00003560| 61 74 63 68 69 6e 67 20 | 6e 65 77 6c 69 6e 65 73 |atching |newlines|
|00003570| 20 6d 65 61 6e 73 20 74 | 68 61 74 20 61 20 70 61 | means t|hat a pa|
|00003580| 74 74 65 72 6e 20 6c 69 | 6b 65 20 5b 5e 22 5d 2a |ttern li|ke [^"]*|
|00003590| 20 63 61 6e 20 6d 61 74 | 63 68 20 61 6e 20 65 6e | can mat|ch an en|
|000035a0| 74 69 72 65 0a 58 69 6e | 70 75 74 20 28 6f 76 65 |tire.Xin|put (ove|
|000035b0| 72 66 6c 6f 77 69 6e 67 | 20 74 68 65 20 73 63 61 |rflowing| the sca|
|000035c0| 6e 6e 65 72 27 73 20 69 | 6e 70 75 74 20 62 75 66 |nner's i|nput buf|
|000035d0| 66 65 72 29 20 75 6e 6c | 65 73 73 20 74 68 65 72 |fer) unl|ess ther|
|000035e0| 65 27 73 20 61 6e 6f 74 | 68 65 72 0a 58 71 75 6f |e's anot|her.Xquo|
|000035f0| 74 65 20 69 6e 20 74 68 | 65 20 69 6e 70 75 74 2e |te in th|e input.|
|00003600| 0a 58 2e 49 50 20 2d 0a | 58 41 20 72 75 6c 65 20 |.X.IP -.|XA rule |
|00003610| 63 61 6e 20 68 61 76 65 | 20 61 74 20 6d 6f 73 74 |can have| at most|
|00003620| 20 6f 6e 65 20 69 6e 73 | 74 61 6e 63 65 20 6f 66 | one ins|tance of|
|00003630| 20 74 72 61 69 6c 69 6e | 67 20 63 6f 6e 74 65 78 | trailin|g contex|
|00003640| 74 20 28 74 68 65 20 27 | 2f 27 20 6f 70 65 72 61 |t (the '|/' opera|
|00003650| 74 6f 72 0a 58 6f 72 20 | 74 68 65 20 27 24 27 20 |tor.Xor |the '$' |
|00003660| 6f 70 65 72 61 74 6f 72 | 29 2e 20 20 54 68 65 20 |operator|). The |
|00003670| 73 74 61 72 74 20 63 6f | 6e 64 69 74 69 6f 6e 2c |start co|ndition,|
|00003680| 20 27 5e 27 2c 20 61 6e | 64 20 22 3c 3c 45 4f 46 | '^', an|d "<<EOF|
|00003690| 3e 3e 22 20 70 61 74 74 | 65 72 6e 73 0a 58 63 61 |>>" patt|erns.Xca|
|000036a0| 6e 20 6f 6e 6c 79 20 6f | 63 63 75 72 20 61 74 20 |n only o|ccur at |
|000036b0| 74 68 65 20 62 65 67 69 | 6e 6e 69 6e 67 20 6f 66 |the begi|nning of|
|000036c0| 20 61 20 70 61 74 74 65 | 72 6e 2c 20 61 6e 64 2c | a patte|rn, and,|
|000036d0| 20 61 73 20 77 65 6c 6c | 20 61 73 20 77 69 74 68 | as well| as with|
|000036e0| 20 27 2f 27 20 61 6e 64 | 20 27 24 27 2c 0a 58 63 | '/' and| '$',.Xc|
|000036f0| 61 6e 6e 6f 74 20 62 65 | 20 67 72 6f 75 70 65 64 |annot be| grouped|
|00003700| 20 69 6e 73 69 64 65 20 | 70 61 72 65 6e 74 68 65 | inside |parenthe|
|00003710| 73 65 73 2e 20 20 41 20 | 27 5e 27 20 77 68 69 63 |ses. A |'^' whic|
|00003720| 68 20 64 6f 65 73 20 6e | 6f 74 20 6f 63 63 75 72 |h does n|ot occur|
|00003730| 20 61 74 0a 58 74 68 65 | 20 62 65 67 69 6e 6e 69 | at.Xthe| beginni|
|00003740| 6e 67 20 6f 66 20 61 20 | 72 75 6c 65 20 6f 72 20 |ng of a |rule or |
|00003750| 61 20 27 24 27 20 77 68 | 69 63 68 20 64 6f 65 73 |a '$' wh|ich does|
|00003760| 20 6e 6f 74 20 6f 63 63 | 75 72 20 61 74 20 74 68 | not occ|ur at th|
|00003770| 65 20 65 6e 64 20 6f 66 | 0a 58 61 20 72 75 6c 65 |e end of|.Xa rule|
|00003780| 20 6c 6f 73 65 73 20 69 | 74 73 20 73 70 65 63 69 | loses i|ts speci|
|00003790| 61 6c 20 70 72 6f 70 65 | 72 74 69 65 73 20 61 6e |al prope|rties an|
|000037a0| 64 20 69 73 20 74 72 65 | 61 74 65 64 20 61 73 20 |d is tre|ated as |
|000037b0| 61 20 6e 6f 72 6d 61 6c | 20 63 68 61 72 61 63 74 |a normal| charact|
|000037c0| 65 72 2e 0a 58 2e 49 50 | 0a 58 54 68 65 20 66 6f |er..X.IP|.XThe fo|
|000037d0| 6c 6c 6f 77 69 6e 67 20 | 61 72 65 20 69 6c 6c 65 |llowing |are ille|
|000037e0| 67 61 6c 3a 0a 58 2e 6e | 66 0a 58 0a 58 20 20 20 |gal:.X.n|f.X.X |
|000037f0| 20 66 6f 6f 2f 62 61 72 | 24 0a 58 20 20 20 20 3c | foo/bar|$.X <|
|00003800| 73 63 31 3e 66 6f 6f 3c | 73 63 32 3e 62 61 72 0a |sc1>foo<|sc2>bar.|
|00003810| 58 0a 58 2e 66 69 0a 58 | 4e 6f 74 65 20 74 68 61 |X.X.fi.X|Note tha|
|00003820| 74 20 74 68 65 20 66 69 | 72 73 74 20 6f 66 20 74 |t the fi|rst of t|
|00003830| 68 65 73 65 2c 20 63 61 | 6e 20 62 65 20 77 72 69 |hese, ca|n be wri|
|00003840| 74 74 65 6e 20 22 66 6f | 6f 2f 62 61 72 5c 5c 6e |tten "fo|o/bar\\n|
|00003850| 22 2e 0a 58 2e 49 50 0a | 58 54 68 65 20 66 6f 6c |"..X.IP.|XThe fol|
|00003860| 6c 6f 77 69 6e 67 20 77 | 69 6c 6c 20 72 65 73 75 |lowing w|ill resu|
|00003870| 6c 74 20 69 6e 20 27 24 | 27 20 6f 72 20 27 5e 27 |lt in '$|' or '^'|
|00003880| 20 62 65 69 6e 67 20 74 | 72 65 61 74 65 64 20 61 | being t|reated a|
|00003890| 73 20 61 20 6e 6f 72 6d | 61 6c 20 63 68 61 72 61 |s a norm|al chara|
|000038a0| 63 74 65 72 3a 0a 58 2e | 6e 66 0a 58 0a 58 20 20 |cter:.X.|nf.X.X |
|000038b0| 20 20 66 6f 6f 7c 28 62 | 61 72 24 29 0a 58 20 20 | foo|(b|ar$).X |
|000038c0| 20 20 66 6f 6f 7c 5e 62 | 61 72 0a 58 0a 58 2e 66 | foo|^b|ar.X.X.f|
|000038d0| 69 0a 58 49 66 20 77 68 | 61 74 27 73 20 77 61 6e |i.XIf wh|at's wan|
|000038e0| 74 65 64 20 69 73 20 61 | 20 22 66 6f 6f 22 20 6f |ted is a| "foo" o|
|000038f0| 72 20 61 20 62 61 72 2d | 66 6f 6c 6c 6f 77 65 64 |r a bar-|followed|
|00003900| 2d 62 79 2d 61 2d 6e 65 | 77 6c 69 6e 65 2c 20 74 |-by-a-ne|wline, t|
|00003910| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 0a 58 63 6f |he follo|wing.Xco|
|00003920| 75 6c 64 20 62 65 20 75 | 73 65 64 20 28 74 68 65 |uld be u|sed (the|
|00003930| 20 73 70 65 63 69 61 6c | 20 27 7c 27 20 61 63 74 | special| '|' act|
|00003940| 69 6f 6e 20 69 73 20 65 | 78 70 6c 61 69 6e 65 64 |ion is e|xplained|
|00003950| 20 62 65 6c 6f 77 29 3a | 0a 58 2e 6e 66 0a 58 0a | below):|.X.nf.X.|
|00003960| 58 20 20 20 20 66 6f 6f | 20 20 20 20 20 20 7c 0a |X foo| |.|
|00003970| 58 20 20 20 20 62 61 72 | 24 20 20 20 20 20 2f 2a |X bar|$ /*|
|00003980| 20 61 63 74 69 6f 6e 20 | 67 6f 65 73 20 68 65 72 | action |goes her|
|00003990| 65 20 2a 2f 0a 58 0a 58 | 2e 66 69 0a 58 41 20 73 |e */.X.X|.fi.XA s|
|000039a0| 69 6d 69 6c 61 72 20 74 | 72 69 63 6b 20 77 69 6c |imilar t|rick wil|
|000039b0| 6c 20 77 6f 72 6b 20 66 | 6f 72 20 6d 61 74 63 68 |l work f|or match|
|000039c0| 69 6e 67 20 61 20 66 6f | 6f 20 6f 72 20 61 0a 58 |ing a fo|o or a.X|
|000039d0| 62 61 72 2d 61 74 2d 74 | 68 65 2d 62 65 67 69 6e |bar-at-t|he-begin|
|000039e0| 6e 69 6e 67 2d 6f 66 2d | 61 2d 6c 69 6e 65 2e 0a |ning-of-|a-line..|
|000039f0| 58 2e 53 48 20 48 4f 57 | 20 54 48 45 20 49 4e 50 |X.SH HOW| THE INP|
|00003a00| 55 54 20 49 53 20 4d 41 | 54 43 48 45 44 0a 58 57 |UT IS MA|TCHED.XW|
|00003a10| 68 65 6e 20 74 68 65 20 | 67 65 6e 65 72 61 74 65 |hen the |generate|
|00003a20| 64 20 73 63 61 6e 6e 65 | 72 20 69 73 20 72 75 6e |d scanne|r is run|
|00003a30| 2c 20 69 74 20 61 6e 61 | 6c 79 7a 65 73 20 69 74 |, it ana|lyzes it|
|00003a40| 73 20 69 6e 70 75 74 20 | 6c 6f 6f 6b 69 6e 67 0a |s input |looking.|
|00003a50| 58 66 6f 72 20 73 74 72 | 69 6e 67 73 20 77 68 69 |Xfor str|ings whi|
|00003a60| 63 68 20 6d 61 74 63 68 | 20 61 6e 79 20 6f 66 20 |ch match| any of |
|00003a70| 69 74 73 20 70 61 74 74 | 65 72 6e 73 2e 20 20 49 |its patt|erns. I|
|00003a80| 66 20 69 74 20 66 69 6e | 64 73 20 6d 6f 72 65 20 |f it fin|ds more |
|00003a90| 74 68 61 6e 0a 58 6f 6e | 65 20 6d 61 74 63 68 2c |than.Xon|e match,|
|00003aa0| 20 69 74 20 74 61 6b 65 | 73 20 74 68 65 20 6f 6e | it take|s the on|
|00003ab0| 65 20 6d 61 74 63 68 69 | 6e 67 20 74 68 65 20 6d |e matchi|ng the m|
|00003ac0| 6f 73 74 20 74 65 78 74 | 20 28 66 6f 72 20 74 72 |ost text| (for tr|
|00003ad0| 61 69 6c 69 6e 67 0a 58 | 63 6f 6e 74 65 78 74 20 |ailing.X|context |
|00003ae0| 72 75 6c 65 73 2c 20 74 | 68 69 73 20 69 6e 63 6c |rules, t|his incl|
|00003af0| 75 64 65 73 20 74 68 65 | 20 6c 65 6e 67 74 68 20 |udes the| length |
|00003b00| 6f 66 20 74 68 65 20 74 | 72 61 69 6c 69 6e 67 20 |of the t|railing |
|00003b10| 70 61 72 74 2c 20 65 76 | 65 6e 0a 58 74 68 6f 75 |part, ev|en.Xthou|
|00003b20| 67 68 20 69 74 20 77 69 | 6c 6c 20 74 68 65 6e 20 |gh it wi|ll then |
|00003b30| 62 65 20 72 65 74 75 72 | 6e 65 64 20 74 6f 20 74 |be retur|ned to t|
|00003b40| 68 65 20 69 6e 70 75 74 | 29 2e 20 20 49 66 20 69 |he input|). If i|
|00003b50| 74 20 66 69 6e 64 73 20 | 74 77 6f 0a 58 6f 72 20 |t finds |two.Xor |
|00003b60| 6d 6f 72 65 20 6d 61 74 | 63 68 65 73 20 6f 66 20 |more mat|ches of |
|00003b70| 74 68 65 20 73 61 6d 65 | 20 6c 65 6e 67 74 68 2c |the same| length,|
|00003b80| 20 74 68 65 0a 58 72 75 | 6c 65 20 6c 69 73 74 65 | the.Xru|le liste|
|00003b90| 64 20 66 69 72 73 74 20 | 69 6e 20 74 68 65 0a 58 |d first |in the.X|
|00003ba0| 2e 49 20 66 6c 65 78 0a | 58 69 6e 70 75 74 20 66 |.I flex.|Xinput f|
|00003bb0| 69 6c 65 20 69 73 20 63 | 68 6f 73 65 6e 2e 0a 58 |ile is c|hosen..X|
|00003bc0| 2e 4c 50 0a 58 4f 6e 63 | 65 20 74 68 65 20 6d 61 |.LP.XOnc|e the ma|
|00003bd0| 74 63 68 20 69 73 20 64 | 65 74 65 72 6d 69 6e 65 |tch is d|etermine|
|00003be0| 64 2c 20 74 68 65 20 74 | 65 78 74 20 63 6f 72 72 |d, the t|ext corr|
|00003bf0| 65 73 70 6f 6e 64 69 6e | 67 20 74 6f 20 74 68 65 |espondin|g to the|
|00003c00| 20 6d 61 74 63 68 0a 58 | 28 63 61 6c 6c 65 64 20 | match.X|(called |
|00003c10| 74 68 65 0a 58 2e 49 20 | 74 6f 6b 65 6e 29 0a 58 |the.X.I |token).X|
|00003c20| 69 73 20 6d 61 64 65 20 | 61 76 61 69 6c 61 62 6c |is made |availabl|
|00003c30| 65 20 69 6e 20 74 68 65 | 20 67 6c 6f 62 61 6c 20 |e in the| global |
|00003c40| 63 68 61 72 61 63 74 65 | 72 20 70 6f 69 6e 74 65 |characte|r pointe|
|00003c50| 72 0a 58 2e 42 20 79 79 | 74 65 78 74 2c 0a 58 61 |r.X.B yy|text,.Xa|
|00003c60| 6e 64 20 69 74 73 20 6c | 65 6e 67 74 68 20 69 6e |nd its l|ength in|
|00003c70| 20 74 68 65 20 67 6c 6f | 62 61 6c 20 69 6e 74 65 | the glo|bal inte|
|00003c80| 67 65 72 0a 58 2e 42 20 | 79 79 6c 65 6e 67 2e 0a |ger.X.B |yyleng..|
|00003c90| 58 54 68 65 0a 58 2e 49 | 20 61 63 74 69 6f 6e 0a |XThe.X.I| action.|
|00003ca0| 58 63 6f 72 72 65 73 70 | 6f 6e 64 69 6e 67 20 74 |Xcorresp|onding t|
|00003cb0| 6f 20 74 68 65 20 6d 61 | 74 63 68 65 64 20 70 61 |o the ma|tched pa|
|00003cc0| 74 74 65 72 6e 20 69 73 | 20 74 68 65 6e 20 65 78 |ttern is| then ex|
|00003cd0| 65 63 75 74 65 64 20 28 | 61 20 6d 6f 72 65 0a 58 |ecuted (|a more.X|
|00003ce0| 64 65 74 61 69 6c 65 64 | 20 64 65 73 63 72 69 70 |detailed| descrip|
|00003cf0| 74 69 6f 6e 20 6f 66 20 | 61 63 74 69 6f 6e 73 20 |tion of |actions |
|00003d00| 66 6f 6c 6c 6f 77 73 29 | 2c 20 61 6e 64 20 74 68 |follows)|, and th|
|00003d10| 65 6e 20 74 68 65 20 72 | 65 6d 61 69 6e 69 6e 67 |en the r|emaining|
|00003d20| 0a 58 69 6e 70 75 74 20 | 69 73 20 73 63 61 6e 6e |.Xinput |is scann|
|00003d30| 65 64 20 66 6f 72 20 61 | 6e 6f 74 68 65 72 20 6d |ed for a|nother m|
|00003d40| 61 74 63 68 2e 0a 58 2e | 4c 50 0a 58 49 66 20 6e |atch..X.|LP.XIf n|
|00003d50| 6f 20 6d 61 74 63 68 20 | 69 73 20 66 6f 75 6e 64 |o match |is found|
|00003d60| 2c 20 74 68 65 6e 20 74 | 68 65 0a 58 2e 49 20 64 |, then t|he.X.I d|
|00003d70| 65 66 61 75 6c 74 20 72 | 75 6c 65 0a 58 69 73 20 |efault r|ule.Xis |
|00003d80| 65 78 65 63 75 74 65 64 | 3a 20 74 68 65 20 6e 65 |executed|: the ne|
|00003d90| 78 74 20 63 68 61 72 61 | 63 74 65 72 20 69 6e 20 |xt chara|cter in |
|00003da0| 74 68 65 20 69 6e 70 75 | 74 20 69 73 20 63 6f 6e |the inpu|t is con|
|00003db0| 73 69 64 65 72 65 64 20 | 6d 61 74 63 68 65 64 20 |sidered |matched |
|00003dc0| 61 6e 64 0a 58 63 6f 70 | 69 65 64 20 74 6f 20 74 |and.Xcop|ied to t|
|00003dd0| 68 65 20 73 74 61 6e 64 | 61 72 64 20 6f 75 74 70 |he stand|ard outp|
|00003de0| 75 74 2e 20 20 54 68 75 | 73 2c 20 74 68 65 20 73 |ut. Thu|s, the s|
|00003df0| 69 6d 70 6c 65 73 74 20 | 6c 65 67 61 6c 0a 58 2e |implest |legal.X.|
|00003e00| 49 20 66 6c 65 78 0a 58 | 69 6e 70 75 74 20 69 73 |I flex.X|input is|
|00003e10| 3a 0a 58 2e 6e 66 0a 58 | 0a 58 20 20 20 20 25 25 |:.X.nf.X|.X %%|
|00003e20| 0a 58 0a 58 2e 66 69 0a | 58 77 68 69 63 68 20 67 |.X.X.fi.|Xwhich g|
|00003e30| 65 6e 65 72 61 74 65 73 | 20 61 20 73 63 61 6e 6e |enerates| a scann|
|00003e40| 65 72 20 74 68 61 74 20 | 73 69 6d 70 6c 79 20 63 |er that |simply c|
|00003e50| 6f 70 69 65 73 20 69 74 | 73 20 69 6e 70 75 74 20 |opies it|s input |
|00003e60| 28 6f 6e 65 20 63 68 61 | 72 61 63 74 65 72 0a 58 |(one cha|racter.X|
|00003e70| 61 74 20 61 20 74 69 6d | 65 29 20 74 6f 20 69 74 |at a tim|e) to it|
|00003e80| 73 20 6f 75 74 70 75 74 | 2e 0a 58 2e 53 48 20 41 |s output|..X.SH A|
|00003e90| 43 54 49 4f 4e 53 0a 58 | 45 61 63 68 20 70 61 74 |CTIONS.X|Each pat|
|00003ea0| 74 65 72 6e 20 69 6e 20 | 61 20 72 75 6c 65 20 68 |tern in |a rule h|
|00003eb0| 61 73 20 61 20 63 6f 72 | 72 65 73 70 6f 6e 64 69 |as a cor|respondi|
|00003ec0| 6e 67 20 61 63 74 69 6f | 6e 2c 20 77 68 69 63 68 |ng actio|n, which|
|00003ed0| 20 63 61 6e 20 62 65 20 | 61 6e 79 0a 58 61 72 62 | can be |any.Xarb|
|00003ee0| 69 74 72 61 72 79 20 43 | 20 73 74 61 74 65 6d 65 |itrary C| stateme|
|00003ef0| 6e 74 2e 20 20 54 68 65 | 20 70 61 74 74 65 72 6e |nt. The| pattern|
|00003f00| 20 65 6e 64 73 20 61 74 | 20 74 68 65 20 66 69 72 | ends at| the fir|
|00003f10| 73 74 20 6e 6f 6e 2d 65 | 73 63 61 70 65 64 0a 58 |st non-e|scaped.X|
|00003f20| 77 68 69 74 65 73 70 61 | 63 65 20 63 68 61 72 61 |whitespa|ce chara|
|00003f30| 63 74 65 72 3b 20 74 68 | 65 20 72 65 6d 61 69 6e |cter; th|e remain|
|00003f40| 64 65 72 20 6f 66 20 74 | 68 65 20 6c 69 6e 65 20 |der of t|he line |
|00003f50| 69 73 20 69 74 73 20 61 | 63 74 69 6f 6e 2e 20 20 |is its a|ction. |
|00003f60| 49 66 20 74 68 65 0a 58 | 61 63 74 69 6f 6e 20 69 |If the.X|action i|
|00003f70| 73 20 65 6d 70 74 79 2c | 20 74 68 65 6e 20 77 68 |s empty,| then wh|
|00003f80| 65 6e 20 74 68 65 20 70 | 61 74 74 65 72 6e 20 69 |en the p|attern i|
|00003f90| 73 20 6d 61 74 63 68 65 | 64 20 74 68 65 20 69 6e |s matche|d the in|
|00003fa0| 70 75 74 20 74 6f 6b 65 | 6e 0a 58 69 73 20 73 69 |put toke|n.Xis si|
|00003fb0| 6d 70 6c 79 20 64 69 73 | 63 61 72 64 65 64 2e 20 |mply dis|carded. |
|00003fc0| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 2c 20 68 65 | For exa|mple, he|
|00003fd0| 72 65 20 69 73 20 74 68 | 65 20 73 70 65 63 69 66 |re is th|e specif|
|00003fe0| 69 63 61 74 69 6f 6e 20 | 66 6f 72 20 61 20 70 72 |ication |for a pr|
|00003ff0| 6f 67 72 61 6d 0a 58 77 | 68 69 63 68 20 64 65 6c |ogram.Xw|hich del|
|00004000| 65 74 65 73 20 61 6c 6c | 20 6f 63 63 75 72 72 65 |etes all| occurre|
|00004010| 6e 63 65 73 20 6f 66 20 | 22 7a 61 70 20 6d 65 22 |nces of |"zap me"|
|00004020| 20 66 72 6f 6d 20 69 74 | 73 20 69 6e 70 75 74 3a | from it|s input:|
|00004030| 0a 58 2e 6e 66 0a 58 0a | 58 20 20 20 20 25 25 0a |.X.nf.X.|X %%.|
|00004040| 58 20 20 20 20 22 7a 61 | 70 20 6d 65 22 0a 58 0a |X "za|p me".X.|
|00004050| 58 2e 66 69 0a 58 28 49 | 74 20 77 69 6c 6c 20 63 |X.fi.X(I|t will c|
|00004060| 6f 70 79 20 61 6c 6c 20 | 6f 74 68 65 72 20 63 68 |opy all |other ch|
|00004070| 61 72 61 63 74 65 72 73 | 20 69 6e 20 74 68 65 20 |aracters| in the |
|00004080| 69 6e 70 75 74 20 74 6f | 20 74 68 65 20 6f 75 74 |input to| the out|
|00004090| 70 75 74 20 73 69 6e 63 | 65 0a 58 74 68 65 79 20 |put sinc|e.Xthey |
|000040a0| 77 69 6c 6c 20 62 65 20 | 6d 61 74 63 68 65 64 20 |will be |matched |
|000040b0| 62 79 20 74 68 65 20 64 | 65 66 61 75 6c 74 20 72 |by the d|efault r|
|000040c0| 75 6c 65 2e 29 0a 58 2e | 4c 50 0a 58 48 65 72 65 |ule.).X.|LP.XHere|
|000040d0| 20 69 73 20 61 20 70 72 | 6f 67 72 61 6d 20 77 68 | is a pr|ogram wh|
|000040e0| 69 63 68 20 63 6f 6d 70 | 72 65 73 73 65 73 20 6d |ich comp|resses m|
|000040f0| 75 6c 74 69 70 6c 65 20 | 62 6c 61 6e 6b 73 20 61 |ultiple |blanks a|
|00004100| 6e 64 20 74 61 62 73 20 | 64 6f 77 6e 20 74 6f 0a |nd tabs |down to.|
|00004110| 58 61 20 73 69 6e 67 6c | 65 20 62 6c 61 6e 6b 2c |Xa singl|e blank,|
|00004120| 20 61 6e 64 20 74 68 72 | 6f 77 73 20 61 77 61 79 | and thr|ows away|
|00004130| 20 77 68 69 74 65 73 70 | 61 63 65 20 66 6f 75 6e | whitesp|ace foun|
|00004140| 64 20 61 74 20 74 68 65 | 20 65 6e 64 20 6f 66 20 |d at the| end of |
|00004150| 61 20 6c 69 6e 65 3a 0a | 58 2e 6e 66 0a 58 0a 58 |a line:.|X.nf.X.X|
|00004160| 20 20 20 20 25 25 0a 58 | 20 20 20 20 5b 20 5c 5c | %%.X| [ \\|
|00004170| 74 5d 2b 20 20 20 20 20 | 20 20 20 70 75 74 63 68 |t]+ | putch|
|00004180| 61 72 28 20 27 20 27 20 | 29 3b 0a 58 20 20 20 20 |ar( ' ' |);.X |
|00004190| 5b 20 5c 5c 74 5d 2b 24 | 20 20 20 20 20 20 20 2f |[ \\t]+$| /|
|000041a0| 2a 20 69 67 6e 6f 72 65 | 20 74 68 69 73 20 74 6f |* ignore| this to|
|000041b0| 6b 65 6e 20 2a 2f 0a 58 | 0a 58 2e 66 69 0a 58 2e |ken */.X|.X.fi.X.|
|000041c0| 4c 50 0a 58 49 66 20 74 | 68 65 20 61 63 74 69 6f |LP.XIf t|he actio|
|000041d0| 6e 20 63 6f 6e 74 61 69 | 6e 73 20 61 20 27 7b 27 |n contai|ns a '{'|
|000041e0| 2c 20 74 68 65 6e 20 74 | 68 65 20 61 63 74 69 6f |, then t|he actio|
|000041f0| 6e 20 73 70 61 6e 73 20 | 74 69 6c 6c 20 74 68 65 |n spans |till the|
|00004200| 20 62 61 6c 61 6e 63 69 | 6e 67 20 27 7d 27 0a 58 | balanci|ng '}'.X|
|00004210| 69 73 20 66 6f 75 6e 64 | 2c 20 61 6e 64 20 74 68 |is found|, and th|
|00004220| 65 20 61 63 74 69 6f 6e | 20 6d 61 79 20 63 72 6f |e action| may cro|
|00004230| 73 73 20 6d 75 6c 74 69 | 70 6c 65 20 6c 69 6e 65 |ss multi|ple line|
|00004240| 73 2e 0a 58 2e 49 20 66 | 6c 65 78 20 0a 58 6b 6e |s..X.I f|lex .Xkn|
|00004250| 6f 77 73 20 61 62 6f 75 | 74 20 43 20 73 74 72 69 |ows abou|t C stri|
|00004260| 6e 67 73 20 61 6e 64 20 | 63 6f 6d 6d 65 6e 74 73 |ngs and |comments|
|00004270| 20 61 6e 64 20 77 6f 6e | 27 74 20 62 65 20 66 6f | and won|'t be fo|
|00004280| 6f 6c 65 64 20 62 79 20 | 62 72 61 63 65 73 20 66 |oled by |braces f|
|00004290| 6f 75 6e 64 0a 58 77 69 | 74 68 69 6e 20 74 68 65 |ound.Xwi|thin the|
|000042a0| 6d 2c 20 62 75 74 20 61 | 6c 73 6f 20 61 6c 6c 6f |m, but a|lso allo|
|000042b0| 77 73 20 61 63 74 69 6f | 6e 73 20 74 6f 20 62 65 |ws actio|ns to be|
|000042c0| 67 69 6e 20 77 69 74 68 | 0a 58 2e 42 20 25 7b 0a |gin with|.X.B %{.|
|000042d0| 58 61 6e 64 20 77 69 6c | 6c 20 63 6f 6e 73 69 64 |Xand wil|l consid|
|000042e0| 65 72 20 74 68 65 20 61 | 63 74 69 6f 6e 20 74 6f |er the a|ction to|
|000042f0| 20 62 65 20 61 6c 6c 20 | 74 68 65 20 74 65 78 74 | be all |the text|
|00004300| 20 75 70 20 74 6f 20 74 | 68 65 20 6e 65 78 74 0a | up to t|he next.|
|00004310| 58 2e 42 20 25 7d 0a 58 | 28 72 65 67 61 72 64 6c |X.B %}.X|(regardl|
|00004320| 65 73 73 20 6f 66 20 6f | 72 64 69 6e 61 72 79 20 |ess of o|rdinary |
|00004330| 62 72 61 63 65 73 20 69 | 6e 73 69 64 65 20 74 68 |braces i|nside th|
|00004340| 65 20 61 63 74 69 6f 6e | 29 2e 0a 58 2e 4c 50 0a |e action|)..X.LP.|
|00004350| 58 41 6e 20 61 63 74 69 | 6f 6e 20 63 6f 6e 73 69 |XAn acti|on consi|
|00004360| 73 74 69 6e 67 20 73 6f | 6c 65 6c 79 20 6f 66 20 |sting so|lely of |
|00004370| 61 20 76 65 72 74 69 63 | 61 6c 20 62 61 72 20 28 |a vertic|al bar (|
|00004380| 27 7c 27 29 20 6d 65 61 | 6e 73 20 22 73 61 6d 65 |'|') mea|ns "same|
|00004390| 20 61 73 0a 58 74 68 65 | 20 61 63 74 69 6f 6e 20 | as.Xthe| action |
|000043a0| 66 6f 72 20 74 68 65 20 | 6e 65 78 74 20 72 75 6c |for the |next rul|
|000043b0| 65 2e 22 20 20 53 65 65 | 20 62 65 6c 6f 77 20 66 |e." See| below f|
|000043c0| 6f 72 20 61 6e 20 69 6c | 6c 75 73 74 72 61 74 69 |or an il|lustrati|
|000043d0| 6f 6e 2e 0a 58 2e 4c 50 | 0a 58 41 63 74 69 6f 6e |on..X.LP|.XAction|
|000043e0| 73 20 63 61 6e 20 69 6e | 63 6c 75 64 65 20 61 72 |s can in|clude ar|
|000043f0| 62 69 74 72 61 72 79 20 | 43 20 63 6f 64 65 2c 20 |bitrary |C code, |
|00004400| 69 6e 63 6c 75 64 69 6e | 67 0a 58 2e 42 20 72 65 |includin|g.X.B re|
|00004410| 74 75 72 6e 0a 58 73 74 | 61 74 65 6d 65 6e 74 73 |turn.Xst|atements|
|00004420| 20 74 6f 20 72 65 74 75 | 72 6e 20 61 20 76 61 6c | to retu|rn a val|
|00004430| 75 65 20 74 6f 20 77 68 | 61 74 65 76 65 72 20 72 |ue to wh|atever r|
|00004440| 6f 75 74 69 6e 65 20 63 | 61 6c 6c 65 64 0a 58 2e |outine c|alled.X.|
|00004450| 42 20 79 79 6c 65 78 28 | 29 2e 0a 58 45 61 63 68 |B yylex(|)..XEach|
|00004460| 20 74 69 6d 65 0a 58 2e | 42 20 79 79 6c 65 78 28 | time.X.|B yylex(|
|00004470| 29 0a 58 69 73 20 63 61 | 6c 6c 65 64 20 69 74 20 |).Xis ca|lled it |
|00004480| 63 6f 6e 74 69 6e 75 65 | 73 20 70 72 6f 63 65 73 |continue|s proces|
|00004490| 73 69 6e 67 20 74 6f 6b | 65 6e 73 20 66 72 6f 6d |sing tok|ens from|
|000044a0| 20 77 68 65 72 65 20 69 | 74 20 6c 61 73 74 20 6c | where i|t last l|
|000044b0| 65 66 74 0a 58 6f 66 66 | 20 75 6e 74 69 6c 20 69 |eft.Xoff| until i|
|000044c0| 74 20 65 69 74 68 65 72 | 20 72 65 61 63 68 65 73 |t either| reaches|
|000044d0| 0a 58 74 68 65 20 65 6e | 64 20 6f 66 20 74 68 65 |.Xthe en|d of the|
|000044e0| 20 66 69 6c 65 20 6f 72 | 20 65 78 65 63 75 74 65 | file or| execute|
|000044f0| 73 20 61 20 72 65 74 75 | 72 6e 2e 20 20 4f 6e 63 |s a retu|rn. Onc|
|00004500| 65 20 69 74 20 72 65 61 | 63 68 65 73 20 61 6e 20 |e it rea|ches an |
|00004510| 65 6e 64 2d 6f 66 2d 66 | 69 6c 65 2c 0a 58 68 6f |end-of-f|ile,.Xho|
|00004520| 77 65 76 65 72 2c 20 74 | 68 65 6e 20 61 6e 79 20 |wever, t|hen any |
|00004530| 73 75 62 73 65 71 75 65 | 6e 74 20 63 61 6c 6c 20 |subseque|nt call |
|00004540| 74 6f 0a 58 2e 42 20 79 | 79 6c 65 78 28 29 0a 58 |to.X.B y|ylex().X|
|00004550| 77 69 6c 6c 20 73 69 6d | 70 6c 79 20 69 6d 6d 65 |will sim|ply imme|
|00004560| 64 69 61 74 65 6c 79 20 | 72 65 74 75 72 6e 2c 20 |diately |return, |
|00004570| 75 6e 6c 65 73 73 0a 58 | 2e 42 20 79 79 72 65 73 |unless.X|.B yyres|
|00004580| 74 61 72 74 28 29 0a 58 | 69 73 20 66 69 72 73 74 |tart().X|is first|
|00004590| 20 63 61 6c 6c 65 64 20 | 28 73 65 65 20 62 65 6c | called |(see bel|
|000045a0| 6f 77 29 2e 0a 58 2e 4c | 50 0a 58 41 63 74 69 6f |ow)..X.L|P.XActio|
|000045b0| 6e 73 20 61 72 65 20 6e | 6f 74 20 61 6c 6c 6f 77 |ns are n|ot allow|
|000045c0| 65 64 20 74 6f 20 6d 6f | 64 69 66 79 20 79 79 74 |ed to mo|dify yyt|
|000045d0| 65 78 74 20 6f 72 20 79 | 79 6c 65 6e 67 2e 0a 58 |ext or y|yleng..X|
|000045e0| 2e 4c 50 0a 58 54 68 65 | 72 65 20 61 72 65 20 61 |.LP.XThe|re are a|
|000045f0| 20 6e 75 6d 62 65 72 20 | 6f 66 20 73 70 65 63 69 | number |of speci|
|00004600| 61 6c 20 64 69 72 65 63 | 74 69 76 65 73 20 77 68 |al direc|tives wh|
|00004610| 69 63 68 20 63 61 6e 20 | 62 65 20 69 6e 63 6c 75 |ich can |be inclu|
|00004620| 64 65 64 20 77 69 74 68 | 69 6e 0a 58 61 6e 20 61 |ded with|in.Xan a|
|00004630| 63 74 69 6f 6e 3a 0a 58 | 2e 49 50 20 2d 0a 58 2e |ction:.X|.IP -.X.|
|00004640| 42 20 45 43 48 4f 0a 58 | 63 6f 70 69 65 73 20 79 |B ECHO.X|copies y|
|00004650| 79 74 65 78 74 20 74 6f | 20 74 68 65 20 73 63 61 |ytext to| the sca|
|00004660| 6e 6e 65 72 27 73 20 6f | 75 74 70 75 74 2e 0a 58 |nner's o|utput..X|
|00004670| 2e 49 50 20 2d 0a 58 2e | 42 20 42 45 47 49 4e 0a |.IP -.X.|B BEGIN.|
|00004680| 58 66 6f 6c 6c 6f 77 65 | 64 20 62 79 20 74 68 65 |Xfollowe|d by the|
|00004690| 20 6e 61 6d 65 20 6f 66 | 20 61 20 73 74 61 72 74 | name of| a start|
|000046a0| 20 63 6f 6e 64 69 74 69 | 6f 6e 20 70 6c 61 63 65 | conditi|on place|
|000046b0| 73 20 74 68 65 20 73 63 | 61 6e 6e 65 72 20 69 6e |s the sc|anner in|
|000046c0| 20 74 68 65 0a 58 63 6f | 72 72 65 73 70 6f 6e 64 | the.Xco|rrespond|
|000046d0| 69 6e 67 20 73 74 61 72 | 74 20 63 6f 6e 64 69 74 |ing star|t condit|
|000046e0| 69 6f 6e 20 28 73 65 65 | 20 62 65 6c 6f 77 29 2e |ion (see| below).|
|000046f0| 0a 58 2e 49 50 20 2d 0a | 58 2e 42 20 52 45 4a 45 |.X.IP -.|X.B REJE|
|00004700| 43 54 0a 58 64 69 72 65 | 63 74 73 20 74 68 65 20 |CT.Xdire|cts the |
|00004710| 73 63 61 6e 6e 65 72 20 | 74 6f 20 70 72 6f 63 65 |scanner |to proce|
|00004720| 65 64 20 6f 6e 20 74 6f | 20 74 68 65 20 22 73 65 |ed on to| the "se|
|00004730| 63 6f 6e 64 20 62 65 73 | 74 22 20 72 75 6c 65 20 |cond bes|t" rule |
|00004740| 77 68 69 63 68 20 6d 61 | 74 63 68 65 64 20 74 68 |which ma|tched th|
|00004750| 65 0a 58 69 6e 70 75 74 | 20 28 6f 72 20 61 20 70 |e.Xinput| (or a p|
|00004760| 72 65 66 69 78 20 6f 66 | 20 74 68 65 20 69 6e 70 |refix of| the inp|
|00004770| 75 74 29 2e 20 20 54 68 | 65 20 72 75 6c 65 20 69 |ut). Th|e rule i|
|00004780| 73 20 63 68 6f 73 65 6e | 20 61 73 20 64 65 73 63 |s chosen| as desc|
|00004790| 72 69 62 65 64 0a 58 61 | 62 6f 76 65 20 69 6e 20 |ribed.Xa|bove in |
|000047a0| 22 48 6f 77 20 74 68 65 | 20 49 6e 70 75 74 20 69 |"How the| Input i|
|000047b0| 73 20 4d 61 74 63 68 65 | 64 22 2c 20 61 6e 64 0a |s Matche|d", and.|
|000047c0| 58 2e 42 20 79 79 74 65 | 78 74 0a 58 61 6e 64 0a |X.B yyte|xt.Xand.|
|000047d0| 58 2e 42 20 79 79 6c 65 | 6e 67 0a 58 73 65 74 20 |X.B yyle|ng.Xset |
|000047e0| 75 70 20 61 70 70 72 6f | 70 72 69 61 74 65 6c 79 |up appro|priately|
|000047f0| 2e 0a 58 49 74 20 6d 61 | 79 20 65 69 74 68 65 72 |..XIt ma|y either|
|00004800| 20 62 65 20 6f 6e 65 20 | 77 68 69 63 68 20 6d 61 | be one |which ma|
|00004810| 74 63 68 65 64 20 61 73 | 20 6d 75 63 68 20 74 65 |tched as| much te|
|00004820| 78 74 0a 58 61 73 20 74 | 68 65 20 6f 72 69 67 69 |xt.Xas t|he origi|
|00004830| 6e 61 6c 6c 79 20 63 68 | 6f 73 65 6e 20 72 75 6c |nally ch|osen rul|
|00004840| 65 20 62 75 74 20 63 61 | 6d 65 20 6c 61 74 65 72 |e but ca|me later|
|00004850| 20 69 6e 20 74 68 65 0a | 58 2e 49 20 66 6c 65 78 | in the.|X.I flex|
|00004860| 0a 58 69 6e 70 75 74 20 | 66 69 6c 65 2c 20 6f 72 |.Xinput |file, or|
|00004870| 20 6f 6e 65 20 77 68 69 | 63 68 20 6d 61 74 63 68 | one whi|ch match|
|00004880| 65 64 20 6c 65 73 73 20 | 74 65 78 74 2e 0a 58 46 |ed less |text..XF|
|00004890| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 74 68 65 20 |or examp|le, the |
|000048a0| 66 6f 6c 6c 6f 77 69 6e | 67 20 77 69 6c 6c 20 62 |followin|g will b|
|000048b0| 6f 74 68 20 63 6f 75 6e | 74 20 74 68 65 0a 58 77 |oth coun|t the.Xw|
|000048c0| 6f 72 64 73 20 69 6e 20 | 74 68 65 20 69 6e 70 75 |ords in |the inpu|
|000048d0| 74 20 61 6e 64 20 63 61 | 6c 6c 20 74 68 65 20 72 |t and ca|ll the r|
|000048e0| 6f 75 74 69 6e 65 20 73 | 70 65 63 69 61 6c 28 29 |outine s|pecial()|
|000048f0| 20 77 68 65 6e 65 76 65 | 72 20 22 66 72 6f 62 22 | wheneve|r "frob"|
|00004900| 20 69 73 20 73 65 65 6e | 3a 0a 58 2e 6e 66 0a 58 | is seen|:.X.nf.X|
|00004910| 0a 58 20 20 20 20 20 20 | 20 20 20 20 20 20 69 6e |.X | in|
|00004920| 74 20 77 6f 72 64 5f 63 | 6f 75 6e 74 20 3d 20 30 |t word_c|ount = 0|
|00004930| 3b 0a 58 20 20 20 20 25 | 25 0a 58 0a 58 20 20 20 |;.X %|%.X.X |
|00004940| 20 66 72 6f 62 20 20 20 | 20 20 20 20 20 73 70 65 | frob | spe|
|00004950| 63 69 61 6c 28 29 3b 20 | 52 45 4a 45 43 54 3b 0a |cial(); |REJECT;.|
|00004960| 58 20 20 20 20 5b 5e 20 | 5c 5c 74 5c 5c 6e 5d 2b |X [^ |\\t\\n]+|
|00004970| 20 20 20 2b 2b 77 6f 72 | 64 5f 63 6f 75 6e 74 3b | ++wor|d_count;|
|00004980| 0a 58 0a 58 2e 66 69 0a | 58 57 69 74 68 6f 75 74 |.X.X.fi.|XWithout|
|00004990| 20 74 68 65 0a 58 2e 42 | 20 52 45 4a 45 43 54 2c | the.X.B| REJECT,|
|000049a0| 0a 58 61 6e 79 20 22 66 | 72 6f 62 22 27 73 20 69 |.Xany "f|rob"'s i|
|000049b0| 6e 20 74 68 65 20 69 6e | 70 75 74 20 77 6f 75 6c |n the in|put woul|
|000049c0| 64 20 6e 6f 74 20 62 65 | 20 63 6f 75 6e 74 65 64 |d not be| counted|
|000049d0| 20 61 73 20 77 6f 72 64 | 73 2c 20 73 69 6e 63 65 | as word|s, since|
|000049e0| 20 74 68 65 0a 58 73 63 | 61 6e 6e 65 72 20 6e 6f | the.Xsc|anner no|
|000049f0| 72 6d 61 6c 6c 79 20 65 | 78 65 63 75 74 65 73 20 |rmally e|xecutes |
|00004a00| 6f 6e 6c 79 20 6f 6e 65 | 20 61 63 74 69 6f 6e 20 |only one| action |
|00004a10| 70 65 72 20 74 6f 6b 65 | 6e 2e 0a 58 4d 75 6c 74 |per toke|n..XMult|
|00004a20| 69 70 6c 65 0a 58 2e 42 | 20 52 45 4a 45 43 54 27 |iple.X.B| REJECT'|
|00004a30| 73 0a 58 61 72 65 20 61 | 6c 6c 6f 77 65 64 2c 20 |s.Xare a|llowed, |
|00004a40| 65 61 63 68 20 6f 6e 65 | 20 66 69 6e 64 69 6e 67 |each one| finding|
|00004a50| 20 74 68 65 20 6e 65 78 | 74 20 62 65 73 74 20 63 | the nex|t best c|
|00004a60| 68 6f 69 63 65 20 74 6f | 20 74 68 65 20 63 75 72 |hoice to| the cur|
|00004a70| 72 65 6e 74 6c 79 0a 58 | 61 63 74 69 76 65 20 72 |rently.X|active r|
|00004a80| 75 6c 65 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |ule. Fo|r exampl|
|00004a90| 65 2c 20 77 68 65 6e 20 | 74 68 65 20 66 6f 6c 6c |e, when |the foll|
|00004aa0| 6f 77 69 6e 67 20 73 63 | 61 6e 6e 65 72 20 73 63 |owing sc|anner sc|
|00004ab0| 61 6e 73 20 74 68 65 20 | 74 6f 6b 65 6e 0a 58 22 |ans the |token.X"|
|00004ac0| 61 62 63 64 22 2c 20 69 | 74 20 77 69 6c 6c 20 77 |abcd", i|t will w|
|00004ad0| 72 69 74 65 20 22 61 62 | 63 64 61 62 63 61 62 61 |rite "ab|cdabcaba|
|00004ae0| 22 20 74 6f 20 74 68 65 | 20 6f 75 74 70 75 74 3a |" to the| output:|
|00004af0| 0a 58 2e 6e 66 0a 58 0a | 58 20 20 20 20 25 25 0a |.X.nf.X.|X %%.|
|00004b00| 58 20 20 20 20 61 20 20 | 20 20 20 20 20 20 7c 0a |X a | |.|
|00004b10| 58 20 20 20 20 61 62 20 | 20 20 20 20 20 20 7c 0a |X ab | |.|
|00004b20| 58 20 20 20 20 61 62 63 | 20 20 20 20 20 20 7c 0a |X abc| |.|
|00004b30| 58 20 20 20 20 61 62 63 | 64 20 20 20 20 20 45 43 |X abc|d EC|
|00004b40| 48 4f 3b 20 52 45 4a 45 | 43 54 3b 0a 58 20 20 20 |HO; REJE|CT;.X |
|00004b50| 20 2e 7c 5c 5c 6e 20 20 | 20 20 20 2f 2a 20 65 61 | .|\\n | /* ea|
|00004b60| 74 20 75 70 20 61 6e 79 | 20 75 6e 6d 61 74 63 68 |t up any| unmatch|
|00004b70| 65 64 20 63 68 61 72 61 | 63 74 65 72 20 2a 2f 0a |ed chara|cter */.|
|00004b80| 58 0a 58 2e 66 69 0a 58 | 28 54 68 65 20 66 69 72 |X.X.fi.X|(The fir|
|00004b90| 73 74 20 74 68 72 65 65 | 20 72 75 6c 65 73 20 73 |st three| rules s|
|00004ba0| 68 61 72 65 20 74 68 65 | 20 66 6f 75 72 74 68 27 |hare the| fourth'|
|00004bb0| 73 20 61 63 74 69 6f 6e | 20 73 69 6e 63 65 20 74 |s action| since t|
|00004bc0| 68 65 79 20 75 73 65 0a | 58 74 68 65 20 73 70 65 |hey use.|Xthe spe|
|00004bd0| 63 69 61 6c 20 27 7c 27 | 20 61 63 74 69 6f 6e 2e |cial '|'| action.|
|00004be0| 29 0a 58 2e 42 20 52 45 | 4a 45 43 54 0a 58 69 73 |).X.B RE|JECT.Xis|
|00004bf0| 20 61 20 70 61 72 74 69 | 63 75 6c 61 72 6c 79 20 | a parti|cularly |
|00004c00| 65 78 70 65 6e 73 69 76 | 65 20 66 65 61 74 75 72 |expensiv|e featur|
|00004c10| 65 20 69 6e 20 74 65 72 | 6d 73 20 73 63 61 6e 6e |e in ter|ms scann|
|00004c20| 65 72 20 70 65 72 66 6f | 72 6d 61 6e 63 65 3b 0a |er perfo|rmance;.|
|00004c30| 58 69 66 20 69 74 20 69 | 73 20 75 73 65 64 20 69 |Xif it i|s used i|
|00004c40| 6e 0a 58 2e 49 20 61 6e | 79 0a 58 6f 66 20 74 68 |n.X.I an|y.Xof th|
|00004c50| 65 20 73 63 61 6e 6e 65 | 72 27 73 20 61 63 74 69 |e scanne|r's acti|
|00004c60| 6f 6e 73 20 69 74 20 77 | 69 6c 6c 20 73 6c 6f 77 |ons it w|ill slow|
|00004c70| 20 64 6f 77 6e 0a 58 2e | 49 20 61 6c 6c 0a 58 6f | down.X.|I all.Xo|
|00004c80| 66 20 74 68 65 20 73 63 | 61 6e 6e 65 72 27 73 20 |f the sc|anner's |
|00004c90| 6d 61 74 63 68 69 6e 67 | 2e 20 20 46 75 72 74 68 |matching|. Furth|
|00004ca0| 65 72 6d 6f 72 65 2c 0a | 58 2e 42 20 52 45 4a 45 |ermore,.|X.B REJE|
|00004cb0| 43 54 0a 58 63 61 6e 6e | 6f 74 20 62 65 20 75 73 |CT.Xcann|ot be us|
|00004cc0| 65 64 20 77 69 74 68 20 | 74 68 65 0a 58 2e 49 20 |ed with |the.X.I |
|00004cd0| 2d 66 0a 58 6f 72 0a 58 | 2e 49 20 2d 46 0a 58 6f |-f.Xor.X|.I -F.Xo|
|00004ce0| 70 74 69 6f 6e 73 20 28 | 73 65 65 20 62 65 6c 6f |ptions (|see belo|
|00004cf0| 77 29 2e 0a 58 2e 49 50 | 0a 58 4e 6f 74 65 20 61 |w)..X.IP|.XNote a|
|00004d00| 6c 73 6f 20 74 68 61 74 | 20 75 6e 6c 69 6b 65 20 |lso that| unlike |
|00004d10| 74 68 65 20 6f 74 68 65 | 72 20 73 70 65 63 69 61 |the othe|r specia|
|00004d20| 6c 20 61 63 74 69 6f 6e | 73 2c 0a 58 2e 42 20 52 |l action|s,.X.B R|
|00004d30| 45 4a 45 43 54 0a 58 69 | 73 20 61 0a 58 2e 49 20 |EJECT.Xi|s a.X.I |
|00004d40| 62 72 61 6e 63 68 3b 0a | 58 63 6f 64 65 20 69 6d |branch;.|Xcode im|
|00004d50| 6d 65 64 69 61 74 65 6c | 79 20 66 6f 6c 6c 6f 77 |mediatel|y follow|
|00004d60| 69 6e 67 20 69 74 20 69 | 6e 20 74 68 65 20 61 63 |ing it i|n the ac|
|00004d70| 74 69 6f 6e 20 77 69 6c | 6c 0a 58 2e 49 20 6e 6f |tion wil|l.X.I no|
|00004d80| 74 0a 58 62 65 20 65 78 | 65 63 75 74 65 64 2e 0a |t.Xbe ex|ecuted..|
|00004d90| 58 2e 49 50 20 2d 0a 58 | 2e 42 20 79 79 6d 6f 72 |X.IP -.X|.B yymor|
|00004da0| 65 28 29 0a 58 74 65 6c | 6c 73 20 74 68 65 20 73 |e().Xtel|ls the s|
|00004db0| 63 61 6e 6e 65 72 20 74 | 68 61 74 20 74 68 65 20 |canner t|hat the |
|00004dc0| 6e 65 78 74 20 74 69 6d | 65 20 69 74 20 6d 61 74 |next tim|e it mat|
|00004dd0| 63 68 65 73 20 61 20 72 | 75 6c 65 2c 20 74 68 65 |ches a r|ule, the|
|00004de0| 20 63 6f 72 72 65 73 70 | 6f 6e 64 69 6e 67 0a 58 | corresp|onding.X|
|00004df0| 74 6f 6b 65 6e 20 73 68 | 6f 75 6c 64 20 62 65 0a |token sh|ould be.|
|00004e00| 58 2e 49 20 61 70 70 65 | 6e 64 65 64 0a 58 6f 6e |X.I appe|nded.Xon|
|00004e10| 74 6f 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 76 |to the c|urrent v|
|00004e20| 61 6c 75 65 20 6f 66 0a | 58 2e 42 20 79 79 74 65 |alue of.|X.B yyte|
|00004e30| 78 74 0a 58 72 61 74 68 | 65 72 20 74 68 61 6e 20 |xt.Xrath|er than |
|00004e40| 72 65 70 6c 61 63 69 6e | 67 20 69 74 2e 20 20 46 |replacin|g it. F|
|00004e50| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 67 69 76 65 |or examp|le, give|
|00004e60| 6e 20 74 68 65 20 69 6e | 70 75 74 20 22 6d 65 67 |n the in|put "meg|
|00004e70| 61 2d 6b 6c 75 64 67 65 | 22 0a 58 74 68 65 20 66 |a-kludge|".Xthe f|
|00004e80| 6f 6c 6c 6f 77 69 6e 67 | 20 77 69 6c 6c 20 77 72 |ollowing| will wr|
|00004e90| 69 74 65 20 22 6d 65 67 | 61 2d 6d 65 67 61 2d 6b |ite "meg|a-mega-k|
|00004ea0| 6c 75 64 67 65 22 20 74 | 6f 20 74 68 65 20 6f 75 |ludge" t|o the ou|
|00004eb0| 74 70 75 74 3a 0a 58 2e | 6e 66 0a 58 0a 58 20 20 |tput:.X.|nf.X.X |
|00004ec0| 20 20 25 25 0a 58 20 20 | 20 20 6d 65 67 61 2d 20 | %%.X | mega- |
|00004ed0| 20 20 20 45 43 48 4f 3b | 20 79 79 6d 6f 72 65 28 | ECHO;| yymore(|
|00004ee0| 29 3b 0a 58 20 20 20 20 | 6b 6c 75 64 67 65 20 20 |);.X |kludge |
|00004ef0| 20 45 43 48 4f 3b 0a 58 | 0a 58 2e 66 69 0a 58 46 | ECHO;.X|.X.fi.XF|
|00004f00| 69 72 73 74 20 22 6d 65 | 67 61 2d 22 20 69 73 20 |irst "me|ga-" is |
|00004f10| 6d 61 74 63 68 65 64 20 | 61 6e 64 20 65 63 68 6f |matched |and echo|
|00004f20| 65 64 20 74 6f 20 74 68 | 65 20 6f 75 74 70 75 74 |ed to th|e output|
|00004f30| 2e 20 20 54 68 65 6e 20 | 22 6b 6c 75 64 67 65 22 |. Then |"kludge"|
|00004f40| 0a 58 69 73 20 6d 61 74 | 63 68 65 64 2c 20 62 75 |.Xis mat|ched, bu|
|00004f50| 74 20 74 68 65 20 70 72 | 65 76 69 6f 75 73 20 22 |t the pr|evious "|
|00004f60| 6d 65 67 61 2d 22 20 69 | 73 20 73 74 69 6c 6c 20 |mega-" i|s still |
|00004f70| 68 61 6e 67 69 6e 67 20 | 61 72 6f 75 6e 64 20 61 |hanging |around a|
|00004f80| 74 20 74 68 65 0a 58 62 | 65 67 69 6e 6e 69 6e 67 |t the.Xb|eginning|
|00004f90| 20 6f 66 0a 58 2e 42 20 | 79 79 74 65 78 74 0a 58 | of.X.B |yytext.X|
|00004fa0| 73 6f 20 74 68 65 0a 58 | 2e 42 20 45 43 48 4f 0a |so the.X|.B ECHO.|
|00004fb0| 58 66 6f 72 20 74 68 65 | 20 22 6b 6c 75 64 67 65 |Xfor the| "kludge|
|00004fc0| 22 20 72 75 6c 65 20 77 | 69 6c 6c 20 61 63 74 75 |" rule w|ill actu|
|00004fd0| 61 6c 6c 79 20 77 72 69 | 74 65 20 22 6d 65 67 61 |ally wri|te "mega|
|00004fe0| 2d 6b 6c 75 64 67 65 22 | 2e 0a 58 54 68 65 20 70 |-kludge"|..XThe p|
|00004ff0| 72 65 73 65 6e 63 65 20 | 6f 66 0a 58 2e 42 20 79 |resence |of.X.B y|
|00005000| 79 6d 6f 72 65 28 29 0a | 58 69 6e 20 74 68 65 20 |ymore().|Xin the |
|00005010| 73 63 61 6e 6e 65 72 27 | 73 20 61 63 74 69 6f 6e |scanner'|s action|
|00005020| 20 65 6e 74 61 69 6c 73 | 20 61 20 6d 69 6e 6f 72 | entails| a minor|
|00005030| 20 70 65 72 66 6f 72 6d | 61 6e 63 65 20 70 65 6e | perform|ance pen|
|00005040| 61 6c 74 79 20 69 6e 20 | 74 68 65 0a 58 73 63 61 |alty in |the.Xsca|
|00005050| 6e 6e 65 72 27 73 20 6d | 61 74 63 68 69 6e 67 20 |nner's m|atching |
|00005060| 73 70 65 65 64 2e 0a 58 | 2e 49 50 20 2d 0a 58 2e |speed..X|.IP -.X.|
|00005070| 42 20 79 79 6c 65 73 73 | 28 6e 29 0a 58 72 65 74 |B yyless|(n).Xret|
|00005080| 75 72 6e 73 20 61 6c 6c | 20 62 75 74 20 74 68 65 |urns all| but the|
|00005090| 20 66 69 72 73 74 0a 58 | 2e 49 20 6e 0a 58 63 68 | first.X|.I n.Xch|
|000050a0| 61 72 61 63 74 65 72 73 | 20 6f 66 20 74 68 65 20 |aracters| of the |
|000050b0| 63 75 72 72 65 6e 74 20 | 74 6f 6b 65 6e 20 62 61 |current |token ba|
|000050c0| 63 6b 20 74 6f 20 74 68 | 65 20 69 6e 70 75 74 20 |ck to th|e input |
|000050d0| 73 74 72 65 61 6d 2c 20 | 77 68 65 72 65 20 74 68 |stream, |where th|
|000050e0| 65 79 0a 58 77 69 6c 6c | 20 62 65 20 72 65 73 63 |ey.Xwill| be resc|
|000050f0| 61 6e 6e 65 64 20 77 68 | 65 6e 20 74 68 65 20 73 |anned wh|en the s|
|00005100| 63 61 6e 6e 65 72 20 6c | 6f 6f 6b 73 20 66 6f 72 |canner l|ooks for|
|00005110| 20 74 68 65 20 6e 65 78 | 74 20 6d 61 74 63 68 2e | the nex|t match.|
|00005120| 0a 58 2e 42 20 79 79 74 | 65 78 74 0a 58 61 6e 64 |.X.B yyt|ext.Xand|
|00005130| 0a 58 2e 42 20 79 79 6c | 65 6e 67 0a 58 61 72 65 |.X.B yyl|eng.Xare|
|00005140| 20 61 64 6a 75 73 74 65 | 64 20 61 70 70 72 6f 70 | adjuste|d approp|
|00005150| 72 69 61 74 65 6c 79 20 | 28 65 2e 67 2e 2c 0a 58 |riately |(e.g.,.X|
|00005160| 2e 42 20 79 79 6c 65 6e | 67 0a 58 77 69 6c 6c 20 |.B yylen|g.Xwill |
|00005170| 6e 6f 77 20 62 65 20 65 | 71 75 61 6c 20 74 6f 0a |now be e|qual to.|
|00005180| 58 2e 49 20 6e 0a 58 29 | 2e 20 20 46 6f 72 20 65 |X.I n.X)|. For e|
|00005190| 78 61 6d 70 6c 65 2c 20 | 6f 6e 20 74 68 65 20 69 |xample, |on the i|
|000051a0| 6e 70 75 74 20 22 66 6f | 6f 62 61 72 22 20 74 68 |nput "fo|obar" th|
|000051b0| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 77 69 6c 6c |e follow|ing will|
|000051c0| 20 77 72 69 74 65 20 6f | 75 74 0a 58 22 66 6f 6f | write o|ut.X"foo|
|000051d0| 62 61 72 62 61 72 22 3a | 0a 58 2e 6e 66 0a 58 0a |barbar":|.X.nf.X.|
|000051e0| 58 20 20 20 20 25 25 0a | 58 20 20 20 20 66 6f 6f |X %%.|X foo|
|000051f0| 62 61 72 20 20 20 20 45 | 43 48 4f 3b 20 79 79 6c |bar E|CHO; yyl|
|00005200| 65 73 73 28 33 29 3b 0a | 58 20 20 20 20 5b 61 2d |ess(3);.|X [a-|
|00005210| 7a 5d 2b 20 20 20 20 45 | 43 48 4f 3b 0a 58 0a 58 |z]+ E|CHO;.X.X|
|00005220| 2e 66 69 0a 58 41 6e 20 | 61 72 67 75 6d 65 6e 74 |.fi.XAn |argument|
|00005230| 20 6f 66 20 30 20 74 6f | 0a 58 2e 42 20 79 79 6c | of 0 to|.X.B yyl|
|00005240| 65 73 73 0a 58 77 69 6c | 6c 20 63 61 75 73 65 20 |ess.Xwil|l cause |
|00005250| 74 68 65 20 65 6e 74 69 | 72 65 20 63 75 72 72 65 |the enti|re curre|
|00005260| 6e 74 20 69 6e 70 75 74 | 20 73 74 72 69 6e 67 20 |nt input| string |
|00005270| 74 6f 20 62 65 20 73 63 | 61 6e 6e 65 64 20 61 67 |to be sc|anned ag|
|00005280| 61 69 6e 2e 20 20 55 6e | 6c 65 73 73 20 79 6f 75 |ain. Un|less you|
|00005290| 27 76 65 0a 58 63 68 61 | 6e 67 65 64 20 68 6f 77 |'ve.Xcha|nged how|
|000052a0| 20 74 68 65 20 73 63 61 | 6e 6e 65 72 20 77 69 6c | the sca|nner wil|
|000052b0| 6c 20 73 75 62 73 65 71 | 75 65 6e 74 6c 79 20 70 |l subseq|uently p|
|000052c0| 72 6f 63 65 73 73 20 69 | 74 73 20 69 6e 70 75 74 |rocess i|ts input|
|000052d0| 20 28 75 73 69 6e 67 0a | 58 2e 42 20 42 45 47 49 | (using.|X.B BEGI|
|000052e0| 4e 2c 0a 58 66 6f 72 20 | 65 78 61 6d 70 6c 65 29 |N,.Xfor |example)|
|000052f0| 2c 20 74 68 69 73 20 77 | 69 6c 6c 20 72 65 73 75 |, this w|ill resu|
|00005300| 6c 74 20 69 6e 20 61 6e | 20 65 6e 64 6c 65 73 73 |lt in an| endless|
|00005310| 20 6c 6f 6f 70 2e 0a 58 | 2e 49 50 20 2d 0a 58 2e | loop..X|.IP -.X.|
|00005320| 42 20 75 6e 70 75 74 28 | 63 29 0a 58 70 75 74 73 |B unput(|c).Xputs|
|00005330| 20 74 68 65 20 63 68 61 | 72 61 63 74 65 72 0a 58 | the cha|racter.X|
|00005340| 2e 49 20 63 0a 58 62 61 | 63 6b 20 6f 6e 74 6f 20 |.I c.Xba|ck onto |
|00005350| 74 68 65 20 69 6e 70 75 | 74 20 73 74 72 65 61 6d |the inpu|t stream|
|00005360| 2e 20 20 49 74 20 77 69 | 6c 6c 20 62 65 20 74 68 |. It wi|ll be th|
|00005370| 65 20 6e 65 78 74 20 63 | 68 61 72 61 63 74 65 72 |e next c|haracter|
|00005380| 20 73 63 61 6e 6e 65 64 | 2e 0a 58 54 68 65 20 66 | scanned|..XThe f|
|00005390| 6f 6c 6c 6f 77 69 6e 67 | 20 61 63 74 69 6f 6e 20 |ollowing| action |
|000053a0| 77 69 6c 6c 20 74 61 6b | 65 20 74 68 65 20 63 75 |will tak|e the cu|
|000053b0| 72 72 65 6e 74 20 74 6f | 6b 65 6e 20 61 6e 64 20 |rrent to|ken and |
|000053c0| 63 61 75 73 65 20 69 74 | 0a 58 74 6f 20 62 65 20 |cause it|.Xto be |
|000053d0| 72 65 73 63 61 6e 6e 65 | 64 20 65 6e 63 6c 6f 73 |rescanne|d enclos|
|000053e0| 65 64 20 69 6e 20 70 61 | 72 65 6e 74 68 65 73 65 |ed in pa|renthese|
|000053f0| 73 2e 0a 58 2e 6e 66 0a | 58 0a 58 20 20 20 20 7b |s..X.nf.|X.X {|
|00005400| 0a 58 20 20 20 20 69 6e | 74 20 69 3b 0a 58 20 20 |.X in|t i;.X |
|00005410| 20 20 75 6e 70 75 74 28 | 20 27 29 27 20 29 3b 0a | unput(| ')' );.|
|00005420| 58 20 20 20 20 66 6f 72 | 20 28 20 69 20 3d 20 79 |X for| ( i = y|
|00005430| 79 6c 65 6e 67 20 2d 20 | 31 3b 20 69 20 3e 3d 20 |yleng - |1; i >= |
|00005440| 30 3b 20 2d 2d 69 20 29 | 0a 58 20 20 20 20 20 20 |0; --i )|.X |
|00005450| 20 20 75 6e 70 75 74 28 | 20 79 79 74 65 78 74 5b | unput(| yytext[|
|00005460| 69 5d 20 29 3b 0a 58 20 | 20 20 20 75 6e 70 75 74 |i] );.X | unput|
|00005470| 28 20 27 28 27 20 29 3b | 0a 58 20 20 20 20 7d 0a |( '(' );|.X }.|
|00005480| 58 0a 58 2e 66 69 0a 58 | 4e 6f 74 65 20 74 68 61 |X.X.fi.X|Note tha|
|00005490| 74 20 73 69 6e 63 65 20 | 65 61 63 68 0a 58 2e 42 |t since |each.X.B|
|000054a0| 20 75 6e 70 75 74 28 29 | 0a 58 70 75 74 73 20 74 | unput()|.Xputs t|
|000054b0| 68 65 20 67 69 76 65 6e | 20 63 68 61 72 61 63 74 |he given| charact|
|000054c0| 65 72 20 62 61 63 6b 20 | 61 74 20 74 68 65 0a 58 |er back |at the.X|
|000054d0| 2e 49 20 62 65 67 69 6e | 6e 69 6e 67 0a 58 6f 66 |.I begin|ning.Xof|
|000054e0| 20 74 68 65 20 69 6e 70 | 75 74 20 73 74 72 65 61 | the inp|ut strea|
|000054f0| 6d 2c 20 70 75 73 68 69 | 6e 67 20 62 61 63 6b 20 |m, pushi|ng back |
|00005500| 73 74 72 69 6e 67 73 20 | 6d 75 73 74 20 62 65 20 |strings |must be |
|00005510| 64 6f 6e 65 20 62 61 63 | 6b 2d 74 6f 2d 66 72 6f |done bac|k-to-fro|
|00005520| 6e 74 2e 0a 58 2e 49 50 | 20 2d 0a 58 2e 42 20 69 |nt..X.IP| -.X.B i|
|00005530| 6e 70 75 74 28 29 0a 58 | 72 65 61 64 73 20 74 68 |nput().X|reads th|
|00005540| 65 20 6e 65 78 74 20 63 | 68 61 72 61 63 74 65 72 |e next c|haracter|
|00005550| 20 66 72 6f 6d 20 74 68 | 65 20 69 6e 70 75 74 20 | from th|e input |
|00005560| 73 74 72 65 61 6d 2e 20 | 20 46 6f 72 20 65 78 61 |stream. | For exa|
|00005570| 6d 70 6c 65 2c 0a 58 74 | 68 65 20 66 6f 6c 6c 6f |mple,.Xt|he follo|
|00005580| 77 69 6e 67 20 69 73 20 | 6f 6e 65 20 77 61 79 20 |wing is |one way |
|00005590| 74 6f 20 65 61 74 20 75 | 70 20 43 20 63 6f 6d 6d |to eat u|p C comm|
|000055a0| 65 6e 74 73 3a 0a 58 2e | 6e 66 0a 58 0a 58 20 20 |ents:.X.|nf.X.X |
|000055b0| 20 20 25 25 0a 58 20 20 | 20 20 22 2f 2a 22 20 20 | %%.X | "/*" |
|000055c0| 20 20 20 20 20 20 7b 0a | 58 20 20 20 20 20 20 20 | {.|X |
|000055d0| 20 20 20 20 20 20 20 20 | 20 72 65 67 69 73 74 65 | | registe|
|000055e0| 72 20 69 6e 74 20 63 3b | 0a 58 0a 58 20 20 20 20 |r int c;|.X.X |
|000055f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 66 6f 72 20 | | for |
|00005600| 28 20 3b 20 3b 20 29 0a | 58 20 20 20 20 20 20 20 |( ; ; ).|X |
|00005610| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 7b 0a 58 | | {.X|
|00005620| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005630| 20 20 20 20 77 68 69 6c | 65 20 28 20 28 63 20 3d | whil|e ( (c =|
|00005640| 20 69 6e 70 75 74 28 29 | 29 20 21 3d 20 27 2a 27 | input()|) != '*'|
|00005650| 20 26 26 0a 58 20 20 20 | 20 20 20 20 20 20 20 20 | &&.X | |
|00005660| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005670| 20 63 20 21 3d 20 45 4f | 46 20 29 0a 58 20 20 20 | c != EO|F ).X |
|00005680| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005690| 20 20 20 20 20 3b 20 20 | 20 20 2f 2a 20 65 61 74 | ; | /* eat|
|000056a0| 20 75 70 20 74 65 78 74 | 20 6f 66 20 63 6f 6d 6d | up text| of comm|
|000056b0| 65 6e 74 20 2a 2f 0a 58 | 0a 58 20 20 20 20 20 20 |ent */.X|.X |
|000056c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 69 66 | | if|
|000056d0| 20 28 20 63 20 3d 3d 20 | 27 2a 27 20 29 0a 58 20 | ( c == |'*' ).X |
|000056e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000056f0| 20 20 20 20 20 20 20 7b | 0a 58 20 20 20 20 20 20 | {|.X |
|00005700| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005710| 20 20 77 68 69 6c 65 20 | 28 20 28 63 20 3d 20 69 | while |( (c = i|
|00005720| 6e 70 75 74 28 29 29 20 | 3d 3d 20 27 2a 27 20 29 |nput()) |== '*' )|
|00005730| 0a 58 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.X | |
|00005740| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 3b 0a | | ;.|
|00005750| 58 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |X | |
|00005760| 20 20 20 20 20 20 20 20 | 20 69 66 20 28 20 63 20 | | if ( c |
|00005770| 3d 3d 20 27 2f 27 20 29 | 0a 58 20 20 20 20 20 20 |== '/' )|.X |
|00005780| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005790| 20 20 20 20 20 20 62 72 | 65 61 6b 3b 20 20 20 20 | br|eak; |
|000057a0| 2f 2a 20 66 6f 75 6e 64 | 20 74 68 65 20 65 6e 64 |/* found| the end|
|000057b0| 20 2a 2f 0a 58 20 20 20 | 20 20 20 20 20 20 20 20 | */.X | |
|000057c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 7d 0a 58 | | }.X|
|000057d0| 0a 58 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.X | |
|000057e0| 20 20 20 20 20 20 69 66 | 20 28 20 63 20 3d 3d 20 | if| ( c == |
|000057f0| 45 4f 46 20 29 0a 58 20 | 20 20 20 20 20 20 20 20 |EOF ).X | |
|00005800| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 7b | | {|
|00005810| 0a 58 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.X | |
|00005820| 20 20 20 20 20 20 20 20 | 20 20 65 72 72 6f 72 28 | | error(|
|00005830| 20 22 45 4f 46 20 69 6e | 20 63 6f 6d 6d 65 6e 74 | "EOF in| comment|
|00005840| 22 20 29 3b 0a 58 20 20 | 20 20 20 20 20 20 20 20 |" );.X | |
|00005850| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 62 72 | | br|
|00005860| 65 61 6b 3b 0a 58 20 20 | 20 20 20 20 20 20 20 20 |eak;.X | |
|00005870| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 7d 0a | | }.|
|00005880| 58 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |X | |
|00005890| 20 20 20 20 20 7d 0a 58 | 20 20 20 20 20 20 20 20 | }.X| |
|000058a0| 20 20 20 20 20 20 20 20 | 7d 0a 58 0a 58 2e 66 69 | |}.X.X.fi|
|000058b0| 0a 58 28 4e 6f 74 65 20 | 74 68 61 74 20 69 66 20 |.X(Note |that if |
|000058c0| 74 68 65 20 73 63 61 6e | 6e 65 72 20 69 73 20 63 |the scan|ner is c|
|000058d0| 6f 6d 70 69 6c 65 64 20 | 75 73 69 6e 67 0a 58 2e |ompiled |using.X.|
|000058e0| 42 20 43 2b 2b 2c 0a 58 | 74 68 65 6e 0a 58 2e 42 |B C++,.X|then.X.B|
|000058f0| 20 69 6e 70 75 74 28 29 | 0a 58 69 73 20 69 6e 73 | input()|.Xis ins|
|00005900| 74 65 61 64 20 72 65 66 | 65 72 72 65 64 20 74 6f |tead ref|erred to|
|00005910| 20 61 73 0a 58 2e 42 20 | 79 79 69 6e 70 75 74 28 | as.X.B |yyinput(|
|00005920| 29 2c 0a 58 69 6e 20 6f | 72 64 65 72 20 74 6f 20 |),.Xin o|rder to |
|00005930| 61 76 6f 69 64 20 61 20 | 6e 61 6d 65 20 63 6c 61 |avoid a |name cla|
|00005940| 73 68 20 77 69 74 68 20 | 74 68 65 0a 58 2e 42 20 |sh with |the.X.B |
|00005950| 43 2b 2b 0a 58 73 74 72 | 65 61 6d 20 62 79 20 74 |C++.Xstr|eam by t|
|00005960| 68 65 20 6e 61 6d 65 20 | 6f 66 0a 58 2e 49 20 69 |he name |of.X.I i|
|00005970| 6e 70 75 74 2e 29 0a 58 | 2e 49 50 20 2d 0a 58 2e |nput.).X|.IP -.X.|
|00005980| 42 20 79 79 74 65 72 6d | 69 6e 61 74 65 28 29 0a |B yyterm|inate().|
|00005990| 58 63 61 6e 20 62 65 20 | 75 73 65 64 20 69 6e 20 |Xcan be |used in |
|000059a0| 6c 69 65 75 20 6f 66 20 | 61 20 72 65 74 75 72 6e |lieu of |a return|
|000059b0| 20 73 74 61 74 65 6d 65 | 6e 74 20 69 6e 20 61 6e | stateme|nt in an|
|000059c0| 20 61 63 74 69 6f 6e 2e | 20 20 49 74 20 74 65 72 | action.| It ter|
|000059d0| 6d 69 6e 61 74 65 73 0a | 58 74 68 65 20 73 63 61 |minates.|Xthe sca|
|000059e0| 6e 6e 65 72 20 61 6e 64 | 20 72 65 74 75 72 6e 73 |nner and| returns|
|000059f0| 20 61 20 30 20 74 6f 20 | 74 68 65 20 73 63 61 6e | a 0 to |the scan|
|00005a00| 6e 65 72 27 73 20 63 61 | 6c 6c 65 72 2c 20 69 6e |ner's ca|ller, in|
|00005a10| 64 69 63 61 74 69 6e 67 | 20 22 61 6c 6c 20 64 6f |dicating| "all do|
|00005a20| 6e 65 22 2e 0a 58 53 75 | 62 73 65 71 75 65 6e 74 |ne"..XSu|bsequent|
|00005a30| 20 63 61 6c 6c 73 20 74 | 6f 20 74 68 65 20 73 63 | calls t|o the sc|
|00005a40| 61 6e 6e 65 72 20 77 69 | 6c 6c 20 69 6d 6d 65 64 |anner wi|ll immed|
|00005a50| 69 61 74 65 6c 79 20 72 | 65 74 75 72 6e 20 75 6e |iately r|eturn un|
|00005a60| 6c 65 73 73 20 70 72 65 | 63 65 64 65 64 0a 58 62 |less pre|ceded.Xb|
|00005a70| 79 20 61 20 63 61 6c 6c | 20 74 6f 0a 58 2e 42 20 |y a call| to.X.B |
|00005a80| 79 79 72 65 73 74 61 72 | 74 28 29 0a 58 28 73 65 |yyrestar|t().X(se|
|00005a90| 65 20 62 65 6c 6f 77 29 | 2e 0a 58 42 79 20 64 65 |e below)|..XBy de|
|00005aa0| 66 61 75 6c 74 2c 0a 58 | 2e 42 20 79 79 74 65 72 |fault,.X|.B yyter|
|00005ab0| 6d 69 6e 61 74 65 28 29 | 0a 58 69 73 20 61 6c 73 |minate()|.Xis als|
|00005ac0| 6f 20 63 61 6c 6c 65 64 | 20 77 68 65 6e 20 61 6e |o called| when an|
|00005ad0| 20 65 6e 64 2d 6f 66 2d | 66 69 6c 65 20 69 73 20 | end-of-|file is |
|00005ae0| 65 6e 63 6f 75 6e 74 65 | 72 65 64 2e 20 20 49 74 |encounte|red. It|
|00005af0| 20 69 73 20 61 20 6d 61 | 63 72 6f 20 61 6e 64 0a | is a ma|cro and.|
|00005b00| 58 6d 61 79 20 62 65 20 | 72 65 64 65 66 69 6e 65 |Xmay be |redefine|
|00005b10| 64 2e 0a 58 2e 53 48 20 | 54 48 45 20 47 45 4e 45 |d..X.SH |THE GENE|
|00005b20| 52 41 54 45 44 20 53 43 | 41 4e 4e 45 52 0a 58 54 |RATED SC|ANNER.XT|
|00005b30| 68 65 20 6f 75 74 70 75 | 74 20 6f 66 0a 58 2e 49 |he outpu|t of.X.I|
|00005b40| 20 66 6c 65 78 0a 58 69 | 73 20 74 68 65 20 66 69 | flex.Xi|s the fi|
|00005b50| 6c 65 0a 58 2e 42 20 6c | 65 78 2e 79 79 2e 63 2c |le.X.B l|ex.yy.c,|
|00005b60| 0a 58 77 68 69 63 68 20 | 63 6f 6e 74 61 69 6e 73 |.Xwhich |contains|
|00005b70| 20 74 68 65 20 73 63 61 | 6e 6e 69 6e 67 20 72 6f | the sca|nning ro|
|00005b80| 75 74 69 6e 65 0a 58 2e | 42 20 79 79 6c 65 78 28 |utine.X.|B yylex(|
|00005b90| 29 2c 0a 58 61 20 6e 75 | 6d 62 65 72 20 6f 66 20 |),.Xa nu|mber of |
|00005ba0| 74 61 62 6c 65 73 20 75 | 73 65 64 20 62 79 20 69 |tables u|sed by i|
|00005bb0| 74 20 66 6f 72 20 6d 61 | 74 63 68 69 6e 67 20 74 |t for ma|tching t|
|00005bc0| 6f 6b 65 6e 73 2c 20 61 | 6e 64 20 61 20 6e 75 6d |okens, a|nd a num|
|00005bd0| 62 65 72 0a 58 6f 66 20 | 61 75 78 69 6c 69 61 72 |ber.Xof |auxiliar|
|00005be0| 79 20 72 6f 75 74 69 6e | 65 73 20 61 6e 64 20 6d |y routin|es and m|
|00005bf0| 61 63 72 6f 73 2e 20 20 | 42 79 20 64 65 66 61 75 |acros. |By defau|
|00005c00| 6c 74 2c 0a 58 2e 42 20 | 79 79 6c 65 78 28 29 0a |lt,.X.B |yylex().|
|00005c10| 58 69 73 20 64 65 63 6c | 61 72 65 64 20 61 73 20 |Xis decl|ared as |
|00005c20| 66 6f 6c 6c 6f 77 73 3a | 0a 58 2e 6e 66 0a 58 0a |follows:|.X.nf.X.|
|00005c30| 58 20 20 20 20 69 6e 74 | 20 79 79 6c 65 78 28 29 |X int| yylex()|
|00005c40| 0a 58 20 20 20 20 20 20 | 20 20 7b 0a 58 20 20 20 |.X | {.X |
|00005c50| 20 20 20 20 20 2e 2e 2e | 20 76 61 72 69 6f 75 73 | ...| various|
|00005c60| 20 64 65 66 69 6e 69 74 | 69 6f 6e 73 20 61 6e 64 | definit|ions and|
|00005c70| 20 74 68 65 20 61 63 74 | 69 6f 6e 73 20 69 6e 20 | the act|ions in |
|00005c80| 68 65 72 65 20 2e 2e 2e | 0a 58 20 20 20 20 20 20 |here ...|.X |
|00005c90| 20 20 7d 0a 58 0a 58 2e | 66 69 0a 58 28 49 66 20 | }.X.X.|fi.X(If |
|00005ca0| 79 6f 75 72 20 65 6e 76 | 69 72 6f 6e 6d 65 6e 74 |your env|ironment|
|00005cb0| 20 73 75 70 70 6f 72 74 | 73 20 66 75 6e 63 74 69 | support|s functi|
|00005cc0| 6f 6e 20 70 72 6f 74 6f | 74 79 70 65 73 2c 20 74 |on proto|types, t|
|00005cd0| 68 65 6e 20 69 74 20 77 | 69 6c 6c 0a 58 62 65 20 |hen it w|ill.Xbe |
|00005ce0| 22 69 6e 74 20 79 79 6c | 65 78 28 20 76 6f 69 64 |"int yyl|ex( void|
|00005cf0| 20 29 22 2e 29 20 20 54 | 68 69 73 20 64 65 66 69 | )".) T|his defi|
|00005d00| 6e 69 74 69 6f 6e 20 6d | 61 79 20 62 65 20 63 68 |nition m|ay be ch|
|00005d10| 61 6e 67 65 64 20 62 79 | 20 72 65 64 65 66 69 6e |anged by| redefin|
|00005d20| 69 6e 67 0a 58 74 68 65 | 20 22 59 59 5f 44 45 43 |ing.Xthe| "YY_DEC|
|00005d30| 4c 22 20 6d 61 63 72 6f | 2e 20 20 46 6f 72 20 65 |L" macro|. For e|
|00005d40| 78 61 6d 70 6c 65 2c 20 | 79 6f 75 20 63 6f 75 6c |xample, |you coul|
|00005d50| 64 20 75 73 65 3a 0a 58 | 2e 6e 66 0a 58 0a 58 20 |d use:.X|.nf.X.X |
|00005d60| 20 20 20 23 75 6e 64 65 | 66 20 59 59 5f 44 45 43 | #unde|f YY_DEC|
|00005d70| 4c 0a 58 20 20 20 20 23 | 64 65 66 69 6e 65 20 59 |L.X #|define Y|
|00005d80| 59 5f 44 45 43 4c 20 66 | 6c 6f 61 74 20 6c 65 78 |Y_DECL f|loat lex|
|00005d90| 73 63 61 6e 28 20 61 2c | 20 62 20 29 20 66 6c 6f |scan( a,| b ) flo|
|00005da0| 61 74 20 61 2c 20 62 3b | 0a 58 0a 58 2e 66 69 0a |at a, b;|.X.X.fi.|
|00005db0| 58 74 6f 20 67 69 76 65 | 20 74 68 65 20 73 63 61 |Xto give| the sca|
|00005dc0| 6e 6e 69 6e 67 20 72 6f | 75 74 69 6e 65 20 74 68 |nning ro|utine th|
|00005dd0| 65 20 6e 61 6d 65 0a 58 | 2e 49 20 6c 65 78 73 63 |e name.X|.I lexsc|
|00005de0| 61 6e 2c 0a 58 72 65 74 | 75 72 6e 69 6e 67 20 61 |an,.Xret|urning a|
|00005df0| 20 66 6c 6f 61 74 2c 20 | 61 6e 64 20 74 61 6b 69 | float, |and taki|
|00005e00| 6e 67 20 74 77 6f 20 66 | 6c 6f 61 74 73 20 61 73 |ng two f|loats as|
|00005e10| 20 61 72 67 75 6d 65 6e | 74 73 2e 20 20 4e 6f 74 | argumen|ts. Not|
|00005e20| 65 20 74 68 61 74 0a 58 | 69 66 20 79 6f 75 20 67 |e that.X|if you g|
|00005e30| 69 76 65 20 61 72 67 75 | 6d 65 6e 74 73 20 74 6f |ive argu|ments to|
|00005e40| 20 74 68 65 20 73 63 61 | 6e 6e 69 6e 67 20 72 6f | the sca|nning ro|
|00005e50| 75 74 69 6e 65 20 75 73 | 69 6e 67 20 61 0a 58 4b |utine us|ing a.XK|
|00005e60| 26 52 2d 73 74 79 6c 65 | 2f 6e 6f 6e 2d 70 72 6f |&R-style|/non-pro|
|00005e70| 74 6f 74 79 70 65 64 20 | 66 75 6e 63 74 69 6f 6e |totyped |function|
|00005e80| 20 64 65 63 6c 61 72 61 | 74 69 6f 6e 2c 20 79 6f | declara|tion, yo|
|00005e90| 75 20 6d 75 73 74 20 74 | 65 72 6d 69 6e 61 74 65 |u must t|erminate|
|00005ea0| 0a 58 74 68 65 20 64 65 | 66 69 6e 69 74 69 6f 6e |.Xthe de|finition|
|00005eb0| 20 77 69 74 68 20 61 20 | 73 65 6d 69 2d 63 6f 6c | with a |semi-col|
|00005ec0| 6f 6e 20 28 3b 29 2e 0a | 58 2e 4c 50 0a 58 57 68 |on (;)..|X.LP.XWh|
|00005ed0| 65 6e 65 76 65 72 0a 58 | 2e 42 20 79 79 6c 65 78 |enever.X|.B yylex|
|00005ee0| 28 29 0a 58 69 73 20 63 | 61 6c 6c 65 64 2c 20 69 |().Xis c|alled, i|
|00005ef0| 74 20 73 63 61 6e 73 20 | 74 6f 6b 65 6e 73 20 66 |t scans |tokens f|
|00005f00| 72 6f 6d 20 74 68 65 20 | 67 6c 6f 62 61 6c 20 69 |rom the |global i|
|00005f10| 6e 70 75 74 20 66 69 6c | 65 0a 58 2e 49 20 79 79 |nput fil|e.X.I yy|
|00005f20| 69 6e 0a 58 28 77 68 69 | 63 68 20 64 65 66 61 75 |in.X(whi|ch defau|
|00005f30| 6c 74 73 20 74 6f 20 73 | 74 64 69 6e 29 2e 20 20 |lts to s|tdin). |
|00005f40| 49 74 20 63 6f 6e 74 69 | 6e 75 65 73 20 75 6e 74 |It conti|nues unt|
|00005f50| 69 6c 20 69 74 20 65 69 | 74 68 65 72 20 72 65 61 |il it ei|ther rea|
|00005f60| 63 68 65 73 0a 58 61 6e | 20 65 6e 64 2d 6f 66 2d |ches.Xan| end-of-|
|00005f70| 66 69 6c 65 20 28 61 74 | 20 77 68 69 63 68 20 70 |file (at| which p|
|00005f80| 6f 69 6e 74 20 69 74 20 | 72 65 74 75 72 6e 73 20 |oint it |returns |
|00005f90| 74 68 65 20 76 61 6c 75 | 65 20 30 29 20 6f 72 0a |the valu|e 0) or.|
|00005fa0| 58 6f 6e 65 20 6f 66 20 | 69 74 73 20 61 63 74 69 |Xone of |its acti|
|00005fb0| 6f 6e 73 20 65 78 65 63 | 75 74 65 73 20 61 0a 58 |ons exec|utes a.X|
|00005fc0| 2e 49 20 72 65 74 75 72 | 6e 0a 58 73 74 61 74 65 |.I retur|n.Xstate|
|00005fd0| 6d 65 6e 74 2e 0a 58 49 | 6e 20 74 68 65 20 66 6f |ment..XI|n the fo|
|00005fe0| 72 6d 65 72 20 63 61 73 | 65 2c 20 77 68 65 6e 20 |rmer cas|e, when |
|00005ff0| 63 61 6c 6c 65 64 20 61 | 67 61 69 6e 20 74 68 65 |called a|gain the|
|00006000| 20 73 63 61 6e 6e 65 72 | 20 77 69 6c 6c 20 69 6d | scanner| will im|
|00006010| 6d 65 64 69 61 74 65 6c | 79 0a 58 72 65 74 75 72 |mediatel|y.Xretur|
|00006020| 6e 20 75 6e 6c 65 73 73 | 0a 58 2e 42 20 79 79 72 |n unless|.X.B yyr|
|00006030| 65 73 74 61 72 74 28 29 | 0a 58 69 73 20 63 61 6c |estart()|.Xis cal|
|00006040| 6c 65 64 20 74 6f 20 70 | 6f 69 6e 74 0a 58 2e 49 |led to p|oint.X.I|
|00006050| 20 79 79 69 6e 0a 58 61 | 74 20 74 68 65 20 6e 65 | yyin.Xa|t the ne|
|00006060| 77 20 69 6e 70 75 74 20 | 66 69 6c 65 2e 20 20 28 |w input |file. (|
|00006070| 0a 58 2e 42 20 79 79 72 | 65 73 74 61 72 74 28 29 |.X.B yyr|estart()|
|00006080| 0a 58 74 61 6b 65 73 20 | 6f 6e 65 20 61 72 67 75 |.Xtakes |one argu|
|00006090| 6d 65 6e 74 2c 20 61 0a | 58 2e 42 20 46 49 4c 45 |ment, a.|X.B FILE|
|000060a0| 20 2a 0a 58 70 6f 69 6e | 74 65 72 2e 29 0a 58 49 | *.Xpoin|ter.).XI|
|000060b0| 6e 20 74 68 65 20 6c 61 | 74 74 65 72 20 63 61 73 |n the la|tter cas|
|000060c0| 65 20 28 69 2e 65 2e 2c | 20 77 68 65 6e 20 61 6e |e (i.e.,| when an|
|000060d0| 20 61 63 74 69 6f 6e 0a | 58 65 78 65 63 75 74 65 | action.|Xexecute|
|000060e0| 73 20 61 20 72 65 74 75 | 72 6e 29 2c 20 74 68 65 |s a retu|rn), the|
|000060f0| 20 73 63 61 6e 6e 65 72 | 20 6d 61 79 20 74 68 65 | scanner| may the|
|00006100| 6e 20 62 65 20 63 61 6c | 6c 65 64 20 61 67 61 69 |n be cal|led agai|
|00006110| 6e 20 61 6e 64 20 69 74 | 0a 58 77 69 6c 6c 20 72 |n and it|.Xwill r|
|00006120| 65 73 75 6d 65 20 73 63 | 61 6e 6e 69 6e 67 20 77 |esume sc|anning w|
|00006130| 68 65 72 65 20 69 74 20 | 6c 65 66 74 20 6f 66 66 |here it |left off|
|00006140| 2e 0a 58 2e 4c 50 0a 58 | 42 79 20 64 65 66 61 75 |..X.LP.X|By defau|
|00006150| 6c 74 20 28 61 6e 64 20 | 66 6f 72 20 70 75 72 70 |lt (and |for purp|
|00006160| 6f 73 65 73 20 6f 66 20 | 65 66 66 69 63 69 65 6e |oses of |efficien|
|00006170| 63 79 29 2c 20 74 68 65 | 20 73 63 61 6e 6e 65 72 |cy), the| scanner|
|00006180| 20 75 73 65 73 0a 58 62 | 6c 6f 63 6b 2d 72 65 61 | uses.Xb|lock-rea|
|00006190| 64 73 20 72 61 74 68 65 | 72 20 74 68 61 6e 20 73 |ds rathe|r than s|
|000061a0| 69 6d 70 6c 65 0a 58 2e | 49 20 67 65 74 63 28 29 |imple.X.|I getc()|
|000061b0| 0a 58 63 61 6c 6c 73 20 | 74 6f 20 72 65 61 64 20 |.Xcalls |to read |
|000061c0| 63 68 61 72 61 63 74 65 | 72 73 20 66 72 6f 6d 0a |characte|rs from.|
|000061d0| 58 2e 49 20 79 79 69 6e | 2e 0a 58 54 68 65 20 6e |X.I yyin|..XThe n|
|000061e0| 61 74 75 72 65 20 6f 66 | 20 68 6f 77 20 69 74 20 |ature of| how it |
|000061f0| 67 65 74 73 20 69 74 73 | 20 69 6e 70 75 74 20 63 |gets its| input c|
|00006200| 61 6e 20 62 65 20 63 6f | 6e 74 72 6f 6c 6c 65 64 |an be co|ntrolled|
|00006210| 20 62 79 20 72 65 64 65 | 66 69 6e 69 6e 67 20 74 | by rede|fining t|
|00006220| 68 65 0a 58 2e 42 20 59 | 59 5f 49 4e 50 55 54 0a |he.X.B Y|Y_INPUT.|
|00006230| 58 6d 61 63 72 6f 2e 0a | 58 59 59 5f 49 4e 50 55 |Xmacro..|XYY_INPU|
|00006240| 54 27 73 20 63 61 6c 6c | 69 6e 67 20 73 65 71 75 |T's call|ing sequ|
|00006250| 65 6e 63 65 20 69 73 20 | 22 59 59 5f 49 4e 50 55 |ence is |"YY_INPU|
|00006260| 54 28 62 75 66 2c 72 65 | 73 75 6c 74 2c 6d 61 78 |T(buf,re|sult,max|
|00006270| 5f 73 69 7a 65 29 22 2e | 20 20 49 74 73 0a 58 61 |_size)".| Its.Xa|
|00006280| 63 74 69 6f 6e 20 69 73 | 20 74 6f 20 70 6c 61 63 |ction is| to plac|
|00006290| 65 20 75 70 20 74 6f 0a | 58 2e 49 20 6d 61 78 5f |e up to.|X.I max_|
|000062a0| 73 69 7a 65 0a 58 63 68 | 61 72 61 63 74 65 72 73 |size.Xch|aracters|
|000062b0| 20 69 6e 20 74 68 65 20 | 63 68 61 72 61 63 74 65 | in the |characte|
|000062c0| 72 20 61 72 72 61 79 0a | 58 2e 49 20 62 75 66 0a |r array.|X.I buf.|
|000062d0| 58 61 6e 64 20 72 65 74 | 75 72 6e 20 69 6e 20 74 |Xand ret|urn in t|
|000062e0| 68 65 20 69 6e 74 65 67 | 65 72 20 76 61 72 69 61 |he integ|er varia|
|000062f0| 62 6c 65 0a 58 2e 49 20 | 72 65 73 75 6c 74 0a 58 |ble.X.I |result.X|
|00006300| 65 69 74 68 65 72 20 74 | 68 65 0a 58 6e 75 6d 62 |either t|he.Xnumb|
|00006310| 65 72 20 6f 66 20 63 68 | 61 72 61 63 74 65 72 73 |er of ch|aracters|
|00006320| 20 72 65 61 64 20 6f 72 | 20 74 68 65 20 63 6f 6e | read or| the con|
|00006330| 73 74 61 6e 74 20 59 59 | 5f 4e 55 4c 4c 20 28 30 |stant YY|_NULL (0|
|00006340| 20 6f 6e 20 55 6e 69 78 | 20 73 79 73 74 65 6d 73 | on Unix| systems|
|00006350| 29 0a 58 74 6f 20 69 6e | 64 69 63 61 74 65 20 45 |).Xto in|dicate E|
|00006360| 4f 46 2e 20 20 54 68 65 | 20 64 65 66 61 75 6c 74 |OF. The| default|
|00006370| 20 59 59 5f 49 4e 50 55 | 54 20 72 65 61 64 73 20 | YY_INPU|T reads |
|00006380| 66 72 6f 6d 20 74 68 65 | 0a 58 67 6c 6f 62 61 6c |from the|.Xglobal|
|00006390| 20 66 69 6c 65 2d 70 6f | 69 6e 74 65 72 20 22 79 | file-po|inter "y|
|000063a0| 79 69 6e 22 2e 0a 58 2e | 4c 50 0a 58 41 20 73 61 |yin"..X.|LP.XA sa|
|000063b0| 6d 70 6c 65 20 72 65 64 | 65 66 69 6e 69 74 69 6f |mple red|efinitio|
|000063c0| 6e 20 6f 66 20 59 59 5f | 49 4e 50 55 54 20 28 69 |n of YY_|INPUT (i|
|000063d0| 6e 20 74 68 65 20 64 65 | 66 69 6e 69 74 69 6f 6e |n the de|finition|
|000063e0| 73 0a 58 73 65 63 74 69 | 6f 6e 20 6f 66 20 74 68 |s.Xsecti|on of th|
|000063f0| 65 20 69 6e 70 75 74 20 | 66 69 6c 65 29 3a 0a 58 |e input |file):.X|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.