home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / flex2 / part04 < prev    next >
Text File  |  1989-06-21  |  46KB  |  1,381 lines

  1. Subject:  v19i058:  Flex, a fast LEX replacement, Part04/07
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Vern Paxson <vern@csam.lbl.gov>
  7. Posting-number: Volume 19, Issue 58
  8. Archive-name: flex2/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 4 (of 7)."
  17. # Contents:  flex/flex.1 flex/flexdef.h
  18. # Wrapped by rsalz@prune.bbn.com on Thu Jun 22 19:01:47 1989
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'flex/flex.1' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'flex/flex.1'\"
  22. else
  23. echo shar: Extracting \"'flex/flex.1'\" \(20602 characters\)
  24. sed "s/^X//" >'flex/flex.1' <<'END_OF_FILE'
  25. X.TH FLEX 1 "20 June 1989" "Version 2.1"
  26. X.SH NAME
  27. Xflex - fast lexical analyzer generator
  28. X.SH SYNOPSIS
  29. X.B flex
  30. X[
  31. X.B -bdfipstvFILT -c[efmF] -Sskeleton_file
  32. X] [ 
  33. X.I filename
  34. X]
  35. X.SH DESCRIPTION
  36. X.I flex
  37. Xis a rewrite of
  38. X.I lex
  39. Xintended to right some of that tool's deficiencies: in particular,
  40. X.I flex
  41. Xgenerates lexical analyzers much faster, and the analyzers use
  42. Xsmaller tables and run faster.
  43. X.SH OPTIONS
  44. XIn addition to lex's
  45. X.B -t
  46. Xflag, flex has the following options:
  47. X.TP
  48. X.B -b
  49. XGenerate backtracking information to
  50. X.I lex.backtrack.
  51. XThis is a list of scanner states which require backtracking
  52. Xand the input characters on which they do so.  By adding rules one
  53. Xcan remove backtracking states.  If all backtracking states
  54. Xare eliminated and
  55. X.B -f
  56. Xor
  57. X.B -F
  58. Xis used, the generated scanner will run faster (see the
  59. X.B -p
  60. Xflag).  Only users who wish to squeeze every last cycle out of their
  61. Xscanners need worry about this option.
  62. X.TP
  63. X.B -d
  64. Xmakes the generated scanner run in
  65. X.I debug
  66. Xmode.  Whenever a pattern is recognized the scanner will
  67. Xwrite to
  68. X.I stderr
  69. Xa line of the form:
  70. X.nf
  71. X
  72. X    --accepting rule #n
  73. X
  74. X.fi
  75. XRules are numbered sequentially with the first one being 1.  Rule #0
  76. Xis executed when the scanner backtracks; Rule #(n+1) (where
  77. X.I n
  78. Xis the number of rules) indicates the default action; Rule #(n+2) indicates
  79. Xthat the input buffer is empty and needs to be refilled and then the scan
  80. Xrestarted.  Rules beyond (n+2) are end-of-file actions.
  81. X.TP
  82. X.B -f
  83. Xhas the same effect as lex's -f flag (do not compress the scanner
  84. Xtables); the mnemonic changes from
  85. X.I fast compilation
  86. Xto (take your pick)
  87. X.I full table
  88. Xor
  89. X.I fast scanner.
  90. XThe actual compilation takes
  91. X.I longer,
  92. Xsince flex is I/O bound writing out the big table.
  93. X.IP
  94. XThis option is equivalent to
  95. X.B -cf
  96. X(see below).
  97. X.TP
  98. X.B -i
  99. Xinstructs flex to generate a
  100. X.I case-insensitive
  101. Xscanner.  The case of letters given in the flex input patterns will
  102. Xbe ignored, and the rules will be matched regardless of case.  The
  103. Xmatched text given in
  104. X.I yytext
  105. Xwill have the preserved case (i.e., it will not be folded).
  106. X.TP
  107. X.B -p
  108. Xgenerates a performance report to stderr.  The report
  109. Xconsists of comments regarding features of the flex input file
  110. Xwhich will cause a loss of performance in the resulting scanner.
  111. XNote that the use of
  112. X.I REJECT
  113. Xand variable trailing context (see
  114. X.B BUGS)
  115. Xentails a substantial performance penalty; use of
  116. X.I yymore(),
  117. Xthe
  118. X.B ^
  119. Xoperator,
  120. Xand the
  121. X.B -I
  122. Xflag entail minor performance penalties.
  123. X.TP
  124. X.B -s
  125. Xcauses the
  126. X.I default rule
  127. X(that unmatched scanner input is echoed to
  128. X.I stdout)
  129. Xto be suppressed.  If the scanner encounters input that does not
  130. Xmatch any of its rules, it aborts with an error.  This option is
  131. Xuseful for finding holes in a scanner's rule set.
  132. X.TP
  133. X.B -v
  134. Xhas the same meaning as for lex (print to
  135. X.I stderr
  136. Xa summary of statistics of the generated scanner).  Many more statistics
  137. Xare printed, though, and the summary spans several lines.  Most
  138. Xof the statistics are meaningless to the casual flex user, but the
  139. Xfirst line identifies the version of flex, which is useful for figuring
  140. Xout where you stand with respect to patches and new releases.
  141. X.TP
  142. X.B -F
  143. Xspecifies that the
  144. X.ul
  145. Xfast
  146. Xscanner table representation should be used.  This representation is
  147. Xabout as fast as the full table representation
  148. X.ul
  149. X(-f),
  150. Xand for some sets of patterns will be considerably smaller (and for
  151. Xothers, larger).  In general, if the pattern set contains both "keywords"
  152. Xand a catch-all, "identifier" rule, such as in the set:
  153. X.nf
  154. X
  155. X    "case"    return ( TOK_CASE );
  156. X    "switch"  return ( TOK_SWITCH );
  157. X    ...
  158. X    "default" return ( TOK_DEFAULT );
  159. X    [a-z]+    return ( TOK_ID );
  160. X
  161. X.fi
  162. Xthen you're better off using the full table representation.  If only
  163. Xthe "identifier" rule is present and you then use a hash table or some such
  164. Xto detect the keywords, you're better off using
  165. X.ul
  166. X-F.
  167. X.IP
  168. XThis option is equivalent to
  169. X.B -cF
  170. X(see below).
  171. X.TP
  172. X.B -I
  173. Xinstructs flex to generate an
  174. X.I interactive
  175. Xscanner.  Normally, scanners generated by flex always look ahead one
  176. Xcharacter before deciding that a rule has been matched.  At the cost of
  177. Xsome scanning overhead, flex will generate a scanner which only looks ahead
  178. Xwhen needed.  Such scanners are called
  179. X.I interactive
  180. Xbecause if you want to write a scanner for an interactive system such as a
  181. Xcommand shell, you will probably want the user's input to be terminated
  182. Xwith a newline, and without
  183. X.B -I
  184. Xthe user will have to type a character in addition to the newline in order
  185. Xto have the newline recognized.  This leads to dreadful interactive
  186. Xperformance.
  187. X.IP
  188. XIf all this seems to confusing, here's the general rule: if a human will
  189. Xbe typing in input to your scanner, use
  190. X.B -I,
  191. Xotherwise don't; if you don't care about how fast your scanners run and
  192. Xdon't want to make any assumptions about the input to your scanner,
  193. Xalways use
  194. X.B -I.
  195. X.IP
  196. XNote,
  197. X.B -I
  198. Xcannot be used in conjunction with
  199. X.I full
  200. Xor
  201. X.I fast tables,
  202. Xi.e., the
  203. X.B -f, -F, -cf,
  204. Xor
  205. X.B -cF
  206. Xflags.
  207. X.TP
  208. X.B -L
  209. Xinstructs flex to not generate
  210. X.B #line
  211. Xdirectives (see below).
  212. X.TP
  213. X.B -T
  214. Xmakes flex run in
  215. X.I trace
  216. Xmode.  It will generate a lot of messages to stdout concerning
  217. Xthe form of the input and the resultant non-deterministic and deterministic
  218. Xfinite automatons.  This option is mostly for use in maintaining flex.
  219. X.TP 
  220. X.B -c[efmF]
  221. Xcontrols the degree of table compression.
  222. X.B -ce
  223. Xdirects flex to construct
  224. X.I equivalence classes,
  225. Xi.e., sets of characters
  226. Xwhich have identical lexical properties (for example, if the only
  227. Xappearance of digits in the flex input is in the character class
  228. X"[0-9]" then the digits '0', '1', ..., '9' will all be put
  229. Xin the same equivalence class).
  230. X.B -cf
  231. Xspecifies that the
  232. X.I full
  233. Xscanner tables should be generated - flex should not compress the
  234. Xtables by taking advantages of similar transition functions for
  235. Xdifferent states.
  236. X.B -cF
  237. Xspecifies that the alternate fast scanner representation (described
  238. Xabove under the
  239. X.B -F
  240. Xflag)
  241. Xshould be used.
  242. X.B -cm
  243. Xdirects flex to construct
  244. X.I meta-equivalence classes,
  245. Xwhich are sets of equivalence classes (or characters, if equivalence
  246. Xclasses are not being used) that are commonly used together.
  247. XA lone
  248. X.B -c
  249. Xspecifies that the scanner tables should be compressed but neither
  250. Xequivalence classes nor meta-equivalence classes should be used.
  251. X.IP
  252. XThe options
  253. X.B -cf
  254. Xor
  255. X.B -cF
  256. Xand
  257. X.B -cm
  258. Xdo not make sense together - there is no opportunity for meta-equivalence
  259. Xclasses if the table is not being compressed.  Otherwise the options
  260. Xmay be freely mixed.
  261. X.IP
  262. XThe default setting is
  263. X.B -cem
  264. Xwhich specifies that flex should generate equivalence classes
  265. Xand meta-equivalence classes.  This setting provides the highest
  266. Xdegree of table compression.  You can trade off
  267. Xfaster-executing scanners at the cost of larger tables with
  268. Xthe following generally being true:
  269. X.nf
  270. X
  271. X    slowest            smallest
  272. X               -cem
  273. X               -ce
  274. X               -cm
  275. X               -c
  276. X               -c{f,F}e
  277. X               -c{f,F}
  278. X    fastest            largest
  279. X
  280. X.fi
  281. XNote that scanners with the smallest tables compile the quickest, so
  282. Xduring development you will usually want to use the default, maximal
  283. Xcompression.
  284. X.TP
  285. X.B -Sskeleton_file
  286. Xoverrides the default skeleton file from which flex constructs
  287. Xits scanners.  You'll never need this option unless you are doing
  288. Xflex maintenance or development.
  289. X.SH INCOMPATIBILITIES WITH LEX
  290. X.I flex
  291. Xis fully compatible with
  292. X.I lex
  293. Xwith the following exceptions:
  294. X.IP -
  295. XThere is no run-time library to link with.  You needn't
  296. Xspecify
  297. X.I -ll
  298. Xwhen linking, and you must supply a main program.  (Hacker's note: since
  299. Xthe lex library contains a main() which simply calls yylex(), you actually
  300. X.I can
  301. Xbe lazy and not supply your own main program and link with
  302. X.I -ll.)
  303. X.IP -
  304. Xlex's
  305. X.B %r
  306. X(Ratfor scanners) and
  307. X.B %t
  308. X(translation table) options
  309. Xare not supported.
  310. X.IP -
  311. XThe do-nothing
  312. X.ul
  313. X-n
  314. Xflag is not supported.
  315. X.IP -
  316. XWhen definitions are expanded, flex encloses them in parentheses.
  317. XWith lex, the following
  318. X.nf
  319. X
  320. X    NAME    [A-Z][A-Z0-9]*
  321. X    %%
  322. X    foo{NAME}?      printf( "Found it\\n" );
  323. X    %%
  324. X
  325. X.fi
  326. Xwill not match the string "foo" because when the macro
  327. Xis expanded the rule is equivalent to "foo[A-Z][A-Z0-9]*?"
  328. Xand the precedence is such that the '?' is associated with
  329. X"[A-Z0-9]*".  With flex, the rule will be expanded to
  330. X"foo([A-z][A-Z0-9]*)?" and so the string "foo" will match.
  331. XNote that because of this, the
  332. X.B ^, $, <s>,
  333. Xand
  334. X.B /
  335. Xoperators cannot be used in a definition.
  336. X.IP -
  337. XThe undocumented lex-scanner internal variable
  338. X.B yylineno
  339. Xis not supported.
  340. X.IP -
  341. XThe
  342. X.B input()
  343. Xroutine is not redefinable, though may be called to read characters
  344. Xfollowing whatever has been matched by a rule.  If
  345. X.B input()
  346. Xencounters an end-of-file the normal
  347. X.B yywrap()
  348. Xprocessing is done.  A ``real'' end-of-file is returned as
  349. X.I EOF.
  350. X.IP
  351. XInput can be controlled by redefining the
  352. X.B YY_INPUT
  353. Xmacro.
  354. XYY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)".  Its
  355. Xaction is to place up to max_size characters in the character buffer "buf"
  356. Xand return in the integer variable "result" either the
  357. Xnumber of characters read or the constant YY_NULL (0 on Unix systems)
  358. Xsystems) to indicate EOF.  The default YY_INPUT reads from the
  359. Xfile-pointer "yyin" (which is by default
  360. X.I stdin),
  361. Xso if you
  362. Xjust want to change the input file, you needn't redefine
  363. XYY_INPUT - just point yyin at the input file.
  364. X.IP
  365. XA sample redefinition of YY_INPUT (in the first section of the input
  366. Xfile):
  367. X.nf
  368. X
  369. X    %{
  370. X    #undef YY_INPUT
  371. X    #define YY_INPUT(buf,result,max_size) \\
  372. X        result = (buf[0] = getchar()) == EOF ? YY_NULL : 1;
  373. X    %}
  374. X
  375. X.fi
  376. XYou also can add in things like counting keeping track of the
  377. Xinput line number this way; but don't expect your scanner to
  378. Xgo very fast.
  379. X.IP -
  380. X.B output()
  381. Xis not supported.
  382. XOutput from the ECHO macro is done to the file-pointer
  383. X"yyout" (default
  384. X.I stdout).
  385. X.IP -
  386. XIf you are providing your own yywrap() routine, you must "#undef yywrap"
  387. Xfirst.
  388. X.IP -
  389. XTo refer to yytext outside of your scanner source file, use
  390. X"extern char *yytext;" rather than "extern char yytext[];".
  391. X.IP -
  392. X.B yyleng
  393. Xis a macro and not a variable, and hence cannot be accessed outside
  394. Xof the scanner source file.
  395. X.IP -
  396. Xflex reads only one input file, while lex's input is made
  397. Xup of the concatenation of its input files.
  398. X.IP -
  399. XThe name
  400. X.bd
  401. XFLEX_SCANNER
  402. Xis #define'd so scanners may be written for use with either
  403. Xflex or lex.
  404. X.IP -
  405. XThe macro
  406. X.bd
  407. XYY_USER_ACTION
  408. Xcan be redefined to provide an action
  409. Xwhich is always executed prior to the matched rule's action.  For example,
  410. Xit could be #define'd to call a routine to convert yytext to lower-case,
  411. Xor to copy yyleng to a global variable to make it accessible outside of
  412. Xthe scanner source file.
  413. X.IP -
  414. XIn the generated scanner, rules are separated using
  415. X.bd
  416. XYY_BREAK
  417. Xinstead of simple "break"'s.  This allows, for example, C++ users to
  418. X#define YY_BREAK to do nothing (while being very careful that every
  419. Xrule ends with a "break" or a "return"!) to avoid suffering from
  420. Xunreachable statement warnings where a rule's action ends with "return".
  421. X.SH ENHANCEMENTS
  422. X.IP -
  423. X.I Exclusive start-conditions
  424. Xcan be declared by using
  425. X.B %x
  426. Xinstead of
  427. X.B %s.
  428. XThese start-conditions have the property that when they are active,
  429. X.I no other rules are active.
  430. XThus a set of rules governed by the same exclusive start condition
  431. Xdescribe a scanner which is independent of any of the other rules in
  432. Xthe flex input.  This feature makes it easy to specify "mini-scanners"
  433. Xwhich scan portions of the input that are syntactically different
  434. Xfrom the rest (e.g., comments).
  435. X.IP -
  436. X.I yyterminate()
  437. Xcan be used in lieu of a return statement in an action.  It terminates
  438. Xthe scanner and returns a 0 to the scanner's caller, indicating "all done".
  439. X.IP -
  440. X.I End-of-file rules.
  441. XThe special rule "<<EOF>>" indicates
  442. Xactions which are to be taken when an end-of-file is
  443. Xencountered and yywrap() returns non-zero (i.e., indicates
  444. Xno further files to process).  The action can either
  445. Xpoint yyin at a new file to process, in which case the
  446. Xaction should finish with
  447. X.I YY_NEW_FILE
  448. X(this is a branch, so subsequent code in the action won't
  449. Xbe executed), or it should finish with a
  450. X.I return
  451. Xstatement.  <<EOF>> rules may not be used with other
  452. Xpatterns; they may only be qualified with a list of start
  453. Xconditions.  If an unqualified <<EOF>> rule is given, it
  454. Xapplies only to the INITIAL start condition, and
  455. X.I not
  456. Xto
  457. X.B %s
  458. Xstart conditions.
  459. XThese rules are useful for catching things like unclosed comments.
  460. XAn example:
  461. X.nf
  462. X
  463. X    %x quote
  464. X    %%
  465. X    ...
  466. X    <quote><<EOF>>   {
  467. X         error( "unterminated quote" );
  468. X         yyterminate();
  469. X         }
  470. X    <<EOF>>          {
  471. X         yyin = fopen( next_file, "r" );
  472. X         YY_NEW_FILE;
  473. X         }
  474. X
  475. X.fi
  476. X.IP -
  477. Xflex dynamically resizes its internal tables, so directives like "%a 3000"
  478. Xare not needed when specifying large scanners.
  479. X.IP -
  480. XThe scanning routine generated by flex is declared using the macro
  481. X.B YY_DECL.
  482. XBy redefining this macro you can change the routine's name and
  483. Xits calling sequence.  For example, you could use:
  484. X.nf
  485. X
  486. X    #undef YY_DECL
  487. X    #define YY_DECL float lexscan( a, b ) float a, b;
  488. X
  489. X.fi
  490. Xto give it the name
  491. X.I lexscan,
  492. Xreturning a float, and taking two floats as arguments.  Note that
  493. Xif you give arguments to the scanning routine, you must terminate
  494. Xthe definition with a semi-colon (;).
  495. X.IP -
  496. Xflex generates
  497. X.B #line
  498. Xdirectives mapping lines in the output to
  499. Xtheir origin in the input file.
  500. X.IP -
  501. XYou can put multiple actions on the same line, separated with
  502. Xsemi-colons.  With lex, the following
  503. X.nf
  504. X
  505. X    foo    handle_foo(); return 1;
  506. X
  507. X.fi
  508. Xis truncated to
  509. X.nf
  510. X
  511. X    foo    handle_foo();
  512. X
  513. X.fi
  514. Xflex does not truncate the action.  Actions that are not enclosed in
  515. Xbraces are terminated at the end of the line.
  516. X.IP -
  517. XActions can be begun with
  518. X.B %{
  519. Xand terminated with
  520. X.B %}.
  521. XIn this case, flex does not count braces to figure out where the
  522. Xaction ends - actions are terminated by the closing
  523. X.B %}.
  524. XThis feature is useful when the enclosed action has extraneous
  525. Xbraces in it (usually in comments or inside inactive #ifdef's)
  526. Xthat throw off the brace-count.
  527. X.IP -
  528. XAll of the scanner actions (e.g.,
  529. X.B ECHO, yywrap ...)
  530. Xexcept the
  531. X.B unput()
  532. Xand
  533. X.B input()
  534. Xroutines,
  535. Xare written as macros, so they can be redefined if necessary
  536. Xwithout requiring a separate library to link to.
  537. X.IP -
  538. XWhen
  539. X.B yywrap()
  540. Xindicates that the scanner is done processing (it does this by returning
  541. Xnon-zero), on subsequent calls the scanner will always immediately return
  542. Xa value of 0.  To restart it on a new input file, the action
  543. X.B yyrestart()
  544. Xis used.  It takes one argument, the new input file.  It closes the
  545. Xprevious yyin (unless stdin) and sets up the scanners internal variables
  546. Xso that the next call to yylex() will start scanning the new file.  This
  547. Xfunctionality is useful for, e.g., programs which will process a file, do some
  548. Xwork, and then get a message to parse another file.
  549. X.IP -
  550. XFlex scans the code in section 1 (inside %{}'s) and the actions for
  551. Xoccurrences of
  552. X.I REJECT
  553. Xand
  554. X.I yymore().
  555. XIf it doesn't see any, it assumes the features are not used and generates
  556. Xhigher-performance scanners.  Flex tries to be correct in identifying
  557. Xuses but can be fooled (for example, if a reference is made in a macro from
  558. Xa #include file).  If this happens (a feature is used and flex didn't
  559. Xrealize it) you will get a compile-time error of the form
  560. X.nf
  561. X
  562. X    reject_used_but_not_detected undefined
  563. X
  564. X.fi
  565. XYou can tell flex that a feature is used even if it doesn't think so
  566. Xwith
  567. X.B %used
  568. Xfollowed by the name of the feature (for example, "%used REJECT");
  569. Xsimilarly, you can specify that a feature is
  570. X.I not
  571. Xused even though it thinks it is with
  572. X.B %unused.
  573. X.IP -
  574. XComments may be put in the first section of the input by preceding
  575. Xthem with '#'.
  576. X.SH FILES
  577. X.TP
  578. X.I flex.skel
  579. Xskeleton scanner
  580. X.TP
  581. X.I lex.yy.c
  582. Xgenerated scanner (called
  583. X.I lexyy.c
  584. Xon some systems).
  585. X.TP
  586. X.I lex.backtrack
  587. Xbacktracking information for
  588. X.B -b
  589. Xflag (called
  590. X.I lex.bck
  591. Xon some systems).
  592. X.SH "SEE ALSO"
  593. X.LP
  594. Xlex(1)
  595. X.LP
  596. XM. E. Lesk and E. Schmidt,
  597. X.I LEX - Lexical Analyzer Generator
  598. X.SH AUTHOR
  599. XVern Paxson, with the help of many ideas and much inspiration from
  600. XVan Jacobson.  Original version by Jef Poskanzer.  Fast table
  601. Xrepresentation is a partial implementation of a design done by Van
  602. XJacobson.  The implementation was done by Kevin Gong and Vern Paxson.
  603. X.LP
  604. XThanks to the many flex beta-testers and feedbackers, especially Casey
  605. XLeedom, Frederic Brehm, Nick Christopher, Chris Faylor, Eric Goldman, Eric
  606. XHughes, Greg Lee, Craig Leres, Mohamed el Lozy, Jim Meyering, Esmond Pitt,
  607. XJef Poskanzer, and Dave Tallman.  Thanks to Keith Bostic, John Gilmore, Bob
  608. XMulcahy, Rich Salz, and Richard Stallman for help with various distribution
  609. Xheadaches.
  610. X.LP
  611. XSend comments to:
  612. X.nf
  613. X
  614. X     Vern Paxson
  615. X     Real Time Systems
  616. X     Bldg. 46A
  617. X     Lawrence Berkeley Laboratory
  618. X     1 Cyclotron Rd.
  619. X     Berkeley, CA 94720
  620. X
  621. X     (415) 486-6411
  622. X
  623. X     vern@csam.lbl.gov
  624. X     vern@rtsg.ee.lbl.gov
  625. X     ucbvax!csam.lbl.gov!vern
  626. X
  627. X.fi
  628. XI will be gone from mid-July '89 through mid-August '89.  From August on,
  629. Xthe addresses are:
  630. X.nf
  631. X
  632. X     vern@cs.cornell.edu
  633. X
  634. X     Vern Paxson
  635. X     CS Department
  636. X     Grad Office
  637. X     4126 Upson
  638. X     Cornell University
  639. X     Ithaca, NY 14853-7501
  640. X
  641. X     <no phone number yet>
  642. X
  643. X.fi
  644. XEmail sent to the former addresses should continue to be forwarded for
  645. Xquite a while.  Also, it looks like my username will be "paxson" and
  646. Xnot "vern".  I'm planning on having a mail alias set up so "vern" will
  647. Xstill work, but if you encounter problems try "paxson".
  648. X.SH DIAGNOSTICS
  649. X.LP
  650. X.I flex scanner jammed -
  651. Xa scanner compiled with
  652. X.B -s
  653. Xhas encountered an input string which wasn't matched by
  654. Xany of its rules.
  655. X.LP
  656. X.I flex input buffer overflowed -
  657. Xa scanner rule matched a string long enough to overflow the
  658. Xscanner's internal input buffer (16K bytes - controlled by
  659. X.B YY_BUF_MAX
  660. Xin "flex.skel").
  661. X.LP
  662. X.I old-style lex command ignored -
  663. Xthe flex input contains a lex command (e.g., "%n 1000") which
  664. Xis being ignored.
  665. X.SH BUGS
  666. X.LP
  667. XSome trailing context
  668. Xpatterns cannot be properly matched and generate
  669. Xwarning messages ("Dangerous trailing context").  These are
  670. Xpatterns where the ending of the
  671. Xfirst part of the rule matches the beginning of the second
  672. Xpart, such as "zx*/xy*", where the 'x*' matches the 'x' at
  673. Xthe beginning of the trailing context.  (Lex doesn't get these
  674. Xpatterns right either.)
  675. XIf desperate, you can use
  676. X.B yyless()
  677. Xto effect arbitrary trailing context.
  678. X.LP
  679. X.I variable
  680. Xtrailing context (where both the leading and trailing parts do not have
  681. Xa fixed length) entails the same performance loss as
  682. X.I REJECT
  683. X(i.e., substantial).
  684. X.LP
  685. XFor some trailing context rules, parts which are actually fixed-length are
  686. Xnot recognized as such, leading to the abovementioned performance loss.
  687. XIn particular, parts using '|' or {n} are always considered variable-length.
  688. X.LP
  689. XUse of unput() or input() trashes the current yytext and yyleng.
  690. X.LP
  691. XUse of unput() to push back more text than was matched can
  692. Xresult in the pushed-back text matching a beginning-of-line ('^')
  693. Xrule even though it didn't come at the beginning of the line.
  694. X.LP
  695. Xyytext and yyleng cannot be modified within a flex action.
  696. X.LP
  697. XNulls are not allowed in flex inputs or in the inputs to
  698. Xscanners generated by flex.  Their presence generates fatal
  699. Xerrors.
  700. X.LP
  701. XFlex does not generate correct #line directives for code internal
  702. Xto the scanner; thus, bugs in
  703. X.I
  704. Xflex.skel
  705. Xyield bogus line numbers.
  706. X.LP
  707. XPushing back definitions enclosed in ()'s can result in nasty,
  708. Xdifficult-to-understand problems like:
  709. X.nf
  710. X
  711. X    {DIG}  [0-9] /* a digit */
  712. X
  713. X.fi
  714. XIn which the pushed-back text is "([0-9] /* a digit */)".
  715. X.LP
  716. XDue to both buffering of input and read-ahead, you cannot intermix
  717. Xcalls to stdio routines, such as, for example,
  718. X.B getchar()
  719. Xwith flex rules and expect it to work.  Call
  720. X.B input()
  721. Xinstead.
  722. X.LP
  723. XThe total table entries listed by the
  724. X.B -v
  725. Xflag excludes the number of table entries needed to determine
  726. Xwhat rule has been matched.  The number of entries is equal
  727. Xto the number of DFA states if the scanner does not use REJECT,
  728. Xand somewhat greater than the number of states if it does.
  729. X.LP
  730. XTo be consistent with ANSI C, the escape sequence \\xhh should
  731. Xbe recognized for hexadecimal escape sequences, such as '\\x41' for 'A'.
  732. X.LP
  733. XIt would be useful if flex wrote to lex.yy.c a summary of the flags used in
  734. Xits generation (such as which table compression options).
  735. X.LP
  736. XThe scanner run-time speeds still have not been optimized as much
  737. Xas they deserve.  Van Jacobson's work shows that the can go
  738. Xfaster still.
  739. X.LP
  740. XThe utility needs more complete documentation.
  741. END_OF_FILE
  742. if test 20602 -ne `wc -c <'flex/flex.1'`; then
  743.     echo shar: \"'flex/flex.1'\" unpacked with wrong size!
  744. fi
  745. # end of 'flex/flex.1'
  746. fi
  747. if test -f 'flex/flexdef.h' -a "${1}" != "-c" ; then 
  748.   echo shar: Will not clobber existing file \"'flex/flexdef.h'\"
  749. else
  750. echo shar: Extracting \"'flex/flexdef.h'\" \(21874 characters\)
  751. sed "s/^X//" >'flex/flexdef.h' <<'END_OF_FILE'
  752. X/* flexdef - definitions file for flex */
  753. X
  754. X/*
  755. X * Copyright (c) 1989 The Regents of the University of California.
  756. X * All rights reserved.
  757. X *
  758. X * This code is derived from software contributed to Berkeley by
  759. X * Vern Paxson.
  760. X * 
  761. X * The United States Government has rights in this work pursuant to
  762. X * contract no. DE-AC03-76SF00098 between the United States Department of
  763. X * Energy and the University of California.
  764. X *
  765. X * Redistribution and use in source and binary forms are permitted
  766. X * provided that the above copyright notice and this paragraph are
  767. X * duplicated in all such forms and that any documentation,
  768. X * advertising materials, and other materials related to such
  769. X * distribution and use acknowledge that the software was developed
  770. X * by the University of California, Berkeley.  The name of the
  771. X * University may not be used to endorse or promote products derived
  772. X * from this software without specific prior written permission.
  773. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  774. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  775. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  776. X */
  777. X
  778. X/* @(#) $Header: flexdef.h,v 2.0 89/06/20 15:49:50 vern Locked $ (LBL) */
  779. X
  780. X#ifndef FILE
  781. X#include <stdio.h>
  782. X#endif
  783. X
  784. X#ifdef SYS_V
  785. X#include <string.h>
  786. X
  787. X#ifdef AMIGA
  788. X#define bzero(s, n) setmem((char *)(s), (unsigned)(n), '\0')
  789. X#define abs(x) ((x) < 0 ? -(x) : (x))
  790. X#else
  791. X#define bzero(s, n) memset((char *)(s), '\0', (unsigned)(n))
  792. X#endif
  793. X
  794. X#ifndef VMS
  795. Xchar *memset();
  796. X#else
  797. X/* memset is needed for old versions of the VMS C runtime library */
  798. X#define memset(s, c, n) \
  799. X    { \
  800. X    register char *t = s; \
  801. X    register unsigned int m = n; \
  802. X    while ( m-- > 0 ) \
  803. X        *t++ = c; \
  804. X    }
  805. X#define unlink delete
  806. X#define SHORT_FILE_NAMES
  807. X#endif
  808. X#endif
  809. X
  810. X#ifndef SYS_V
  811. X#include <strings.h>
  812. X#ifdef lint
  813. Xchar *sprintf(); /* keep lint happy */
  814. X#endif
  815. X#endif
  816. X
  817. X
  818. X/* maximum line length we'll have to deal with */
  819. X#define MAXLINE BUFSIZ
  820. X
  821. X/* maximum size of file name */
  822. X#define FILENAMESIZE 1024
  823. X
  824. X#define min(x,y) ((x) < (y) ? (x) : (y))
  825. X#define max(x,y) ((x) > (y) ? (x) : (y))
  826. X
  827. X#ifdef MS_DOS
  828. X#define abs(x) ((x) < 0 ? -(x) : (x))
  829. X#define SHORT_FILE_NAMES
  830. X#endif
  831. X
  832. X#define true 1
  833. X#define false 0
  834. X
  835. X
  836. X#ifndef DEFAULT_SKELETON_FILE
  837. X#define DEFAULT_SKELETON_FILE "flex.skel"
  838. X#endif
  839. X
  840. X/* special chk[] values marking the slots taking by end-of-buffer and action
  841. X * numbers
  842. X */
  843. X#define EOB_POSITION -1
  844. X#define ACTION_POSITION -2
  845. X
  846. X/* number of data items per line for -f output */
  847. X#define NUMDATAITEMS 10
  848. X
  849. X/* number of lines of data in -f output before inserting a blank line for
  850. X * readability.
  851. X */
  852. X#define NUMDATALINES 10
  853. X
  854. X/* transition_struct_out() definitions */
  855. X#define TRANS_STRUCT_PRINT_LENGTH 15
  856. X
  857. X/* returns true if an nfa state has an epsilon out-transition slot
  858. X * that can be used.  This definition is currently not used.
  859. X */
  860. X#define FREE_EPSILON(state) \
  861. X    (transchar[state] == SYM_EPSILON && \
  862. X     trans2[state] == NO_TRANSITION && \
  863. X     finalst[state] != state)
  864. X
  865. X/* returns true if an nfa state has an epsilon out-transition character
  866. X * and both slots are free
  867. X */
  868. X#define SUPER_FREE_EPSILON(state) \
  869. X    (transchar[state] == SYM_EPSILON && \
  870. X     trans1[state] == NO_TRANSITION) \
  871. X
  872. X/* maximum number of NFA states that can comprise a DFA state.  It's real
  873. X * big because if there's a lot of rules, the initial state will have a
  874. X * huge epsilon closure.
  875. X */
  876. X#define INITIAL_MAX_DFA_SIZE 750
  877. X#define MAX_DFA_SIZE_INCREMENT 750
  878. X
  879. X/* array names to be used in generated machine.  They're short because
  880. X * we write out one data statement (which names the array) for each element
  881. X * in the array.
  882. X */
  883. X
  884. X/* points to list of rules accepted for a state */
  885. X#define ALIST "yy_accept"
  886. X#define ACCEPT "yy_acclist"    /* list of rules accepted for a state */
  887. X#define ECARRAY "yy_ec"    /* maps input characters to equivalence classes */
  888. X/* maps equivalence classes to meta-equivalence classes */
  889. X#define MATCHARRAY "yy_meta"
  890. X#define BASEARRAY "yy_base"    /* "base" array */
  891. X#define DEFARRAY "yy_def"    /* "default" array */
  892. X#define NEXTARRAY "yy_nxt"    /* "next" array */
  893. X#define CHECKARRAY "yy_chk"    /* "check" array */
  894. X
  895. X
  896. X/* a note on the following masks.  They are used to mark accepting numbers
  897. X * as being special.  As such, they implicitly limit the number of accepting
  898. X * numbers (i.e., rules) because if there are too many rules the rule numbers
  899. X * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
  900. X * 8192) so unlikely to actually cause any problems.  A check is made in
  901. X * new_rule() to ensure that this limit is not reached.
  902. X */
  903. X
  904. X/* mask to mark a trailing context accepting number */
  905. X#define YY_TRAILING_MASK 0x2000
  906. X
  907. X/* mask to mark the accepting number of the "head" of a trailing context rule */
  908. X#define YY_TRAILING_HEAD_MASK 0x4000
  909. X
  910. X/* maximum number of rules, as outlined in the above note */
  911. X#define MAX_RULE (YY_TRAILING_MASK - 1)
  912. X
  913. X
  914. X/* NIL must be 0.  If not, its special meaning when making equivalence classes
  915. X * (it marks the representative of a given e.c.) will be unidentifiable
  916. X */
  917. X#define NIL 0
  918. X
  919. X#define JAM -1    /* to mark a missing DFA transition */
  920. X#define NO_TRANSITION NIL
  921. X#define UNIQUE -1    /* marks a symbol as an e.c. representative */
  922. X#define INFINITY -1    /* for x{5,} constructions */
  923. X
  924. X/* size of input alphabet - should be size of ASCII set */
  925. X#define CSIZE 127
  926. X
  927. X#define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
  928. X#define MAX_CCLS_INCREMENT 100
  929. X
  930. X/* size of table holding members of character classes */
  931. X#define INITIAL_MAX_CCL_TBL_SIZE 500
  932. X#define MAX_CCL_TBL_SIZE_INCREMENT 250
  933. X
  934. X#define INITIAL_MAX_RULES 100    /* default maximum number of rules */
  935. X#define MAX_RULES_INCREMENT 100
  936. X
  937. X#define INITIAL_MNS 2000    /* default maximum number of nfa states */
  938. X#define MNS_INCREMENT 1000    /* amount to bump above by if it's not enough */
  939. X
  940. X#define INITIAL_MAX_DFAS 1000    /* default maximum number of dfa states */
  941. X#define MAX_DFAS_INCREMENT 1000
  942. X
  943. X#define JAMSTATE -32766    /* marks a reference to the state that always jams */
  944. X
  945. X/* enough so that if it's subtracted from an NFA state number, the result
  946. X * is guaranteed to be negative
  947. X */
  948. X#define MARKER_DIFFERENCE 32000
  949. X#define MAXIMUM_MNS 31999
  950. X
  951. X/* maximum number of nxt/chk pairs for non-templates */
  952. X#define INITIAL_MAX_XPAIRS 2000
  953. X#define MAX_XPAIRS_INCREMENT 2000
  954. X
  955. X/* maximum number of nxt/chk pairs needed for templates */
  956. X#define INITIAL_MAX_TEMPLATE_XPAIRS 2500
  957. X#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
  958. X
  959. X#define SYM_EPSILON 0    /* to mark transitions on the symbol epsilon */
  960. X
  961. X#define INITIAL_MAX_SCS 40    /* maximum number of start conditions */
  962. X#define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */
  963. X
  964. X#define ONE_STACK_SIZE 500    /* stack of states with only one out-transition */
  965. X#define SAME_TRANS -1    /* transition is the same as "default" entry for state */
  966. X
  967. X/* the following percentages are used to tune table compression:
  968. X
  969. X * the percentage the number of out-transitions a state must be of the
  970. X * number of equivalence classes in order to be considered for table
  971. X * compaction by using protos
  972. X */
  973. X#define PROTO_SIZE_PERCENTAGE 15
  974. X
  975. X/* the percentage the number of homogeneous out-transitions of a state
  976. X * must be of the number of total out-transitions of the state in order
  977. X * that the state's transition table is first compared with a potential 
  978. X * template of the most common out-transition instead of with the first
  979. X * proto in the proto queue
  980. X */
  981. X#define CHECK_COM_PERCENTAGE 50
  982. X
  983. X/* the percentage the number of differences between a state's transition
  984. X * table and the proto it was first compared with must be of the total
  985. X * number of out-transitions of the state in order to keep the first
  986. X * proto as a good match and not search any further
  987. X */
  988. X#define FIRST_MATCH_DIFF_PERCENTAGE 10
  989. X
  990. X/* the percentage the number of differences between a state's transition
  991. X * table and the most similar proto must be of the state's total number
  992. X * of out-transitions to use the proto as an acceptable close match
  993. X */
  994. X#define ACCEPTABLE_DIFF_PERCENTAGE 50
  995. X
  996. X/* the percentage the number of homogeneous out-transitions of a state
  997. X * must be of the number of total out-transitions of the state in order
  998. X * to consider making a template from the state
  999. X */
  1000. X#define TEMPLATE_SAME_PERCENTAGE 60
  1001. X
  1002. X/* the percentage the number of differences between a state's transition
  1003. X * table and the most similar proto must be of the state's total number
  1004. X * of out-transitions to create a new proto from the state
  1005. X */
  1006. X#define NEW_PROTO_DIFF_PERCENTAGE 20
  1007. X
  1008. X/* the percentage the total number of out-transitions of a state must be
  1009. X * of the number of equivalence classes in order to consider trying to
  1010. X * fit the transition table into "holes" inside the nxt/chk table.
  1011. X */
  1012. X#define INTERIOR_FIT_PERCENTAGE 15
  1013. X
  1014. X/* size of region set aside to cache the complete transition table of
  1015. X * protos on the proto queue to enable quick comparisons
  1016. X */
  1017. X#define PROT_SAVE_SIZE 2000
  1018. X
  1019. X#define MSP 50    /* maximum number of saved protos (protos on the proto queue) */
  1020. X
  1021. X/* maximum number of out-transitions a state can have that we'll rummage
  1022. X * around through the interior of the internal fast table looking for a
  1023. X * spot for it
  1024. X */
  1025. X#define MAX_XTIONS_FULL_INTERIOR_FIT 4
  1026. X
  1027. X/* maximum number of rules which will be reported as being associated
  1028. X * with a DFA state
  1029. X */
  1030. X#define MAX_ASSOC_RULES 100
  1031. X
  1032. X/* number that, if used to subscript an array, has a good chance of producing
  1033. X * an error; should be small enough to fit into a short
  1034. X */
  1035. X#define BAD_SUBSCRIPT -32767
  1036. X
  1037. X/* absolute value of largest number that can be stored in a short, with a
  1038. X * bit of slop thrown in for general paranoia.
  1039. X */
  1040. X#define MAX_SHORT 32766
  1041. X
  1042. X
  1043. X/* Declarations for global variables. */
  1044. X
  1045. X/* variables for symbol tables:
  1046. X * sctbl - start-condition symbol table
  1047. X * ndtbl - name-definition symbol table
  1048. X * ccltab - character class text symbol table
  1049. X */
  1050. X
  1051. Xstruct hash_entry
  1052. X    {
  1053. X    struct hash_entry *prev, *next;
  1054. X    char *name;
  1055. X    char *str_val;
  1056. X    int int_val;
  1057. X    } ;
  1058. X
  1059. Xtypedef struct hash_entry *hash_table[];
  1060. X
  1061. X#define NAME_TABLE_HASH_SIZE 101
  1062. X#define START_COND_HASH_SIZE 101
  1063. X#define CCL_HASH_SIZE 101
  1064. X
  1065. Xextern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; 
  1066. Xextern struct hash_entry *sctbl[START_COND_HASH_SIZE];
  1067. Xextern struct hash_entry *ccltab[CCL_HASH_SIZE];
  1068. X
  1069. X
  1070. X/* variables for flags:
  1071. X * printstats - if true (-v), dump statistics
  1072. X * syntaxerror - true if a syntax error has been found
  1073. X * eofseen - true if we've seen an eof in the input file
  1074. X * ddebug - if true (-d), make a "debug" scanner
  1075. X * trace - if true (-T), trace processing
  1076. X * spprdflt - if true (-s), suppress the default rule
  1077. X * interactive - if true (-I), generate an interactive scanner
  1078. X * caseins - if true (-i), generate a case-insensitive scanner
  1079. X * useecs - if true (-ce flag), use equivalence classes
  1080. X * fulltbl - if true (-cf flag), don't compress the DFA state table
  1081. X * usemecs - if true (-cm flag), use meta-equivalence classes
  1082. X * fullspd - if true (-F flag), use Jacobson method of table representation
  1083. X * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
  1084. X * performance_report - if true (i.e., -p flag), generate a report relating
  1085. X *   to scanner performance
  1086. X * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
  1087. X *   listing backtracking states
  1088. X * yymore_used - if true, yymore() is used in input rules
  1089. X * reject - if true, generate backtracking tables for REJECT macro
  1090. X * real_reject - if true, scanner really uses REJECT (as opposed to just
  1091. X *               having "reject" set for variable trailing context)
  1092. X * continued_action - true if this rule's action is to "fall through" to
  1093. X *                    the next rule's action (i.e., the '|' action)
  1094. X * yymore_really_used - has a REALLY_xxx value indicating whether a
  1095. X *                      %used or %notused was used with yymore()
  1096. X * reject_really_used - same for REJECT
  1097. X */
  1098. X
  1099. Xextern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
  1100. Xextern int interactive, caseins, useecs, fulltbl, usemecs;
  1101. Xextern int fullspd, gen_line_dirs, performance_report, backtrack_report;
  1102. Xextern int yymore_used, reject, real_reject, continued_action;
  1103. X
  1104. X#define REALLY_NOT_DETERMINED 0
  1105. X#define REALLY_USED 1
  1106. X#define REALLY_NOT_USED 2
  1107. Xextern int yymore_really_used, reject_really_used;
  1108. X
  1109. X
  1110. X/* variables used in the flex input routines:
  1111. X * datapos - characters on current output line
  1112. X * dataline - number of contiguous lines of data in current data
  1113. X *    statement.  Used to generate readable -f output
  1114. X * skelfile - the skeleton file
  1115. X * yyin - input file
  1116. X * temp_action_file - temporary file to hold actions
  1117. X * backtrack_file - file to summarize backtracking states to
  1118. X * action_file_name - name of the temporary file
  1119. X * infilename - name of input file
  1120. X * linenum - current input line number
  1121. X */
  1122. X
  1123. Xextern int datapos, dataline, linenum;
  1124. Xextern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
  1125. Xextern char *infilename;
  1126. Xextern char action_file_name[];
  1127. X
  1128. X
  1129. X/* variables for stack of states having only one out-transition:
  1130. X * onestate - state number
  1131. X * onesym - transition symbol
  1132. X * onenext - target state
  1133. X * onedef - default base entry
  1134. X * onesp - stack pointer
  1135. X */
  1136. X
  1137. Xextern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
  1138. Xextern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
  1139. X
  1140. X
  1141. X/* variables for nfa machine data:
  1142. X * current_mns - current maximum on number of NFA states
  1143. X * num_rules - number of the last accepting state; also is number of
  1144. X *             rules created so far
  1145. X * current_max_rules - current maximum number of rules
  1146. X * lastnfa - last nfa state number created
  1147. X * firstst - physically the first state of a fragment
  1148. X * lastst - last physical state of fragment
  1149. X * finalst - last logical state of fragment
  1150. X * transchar - transition character
  1151. X * trans1 - transition state
  1152. X * trans2 - 2nd transition state for epsilons
  1153. X * accptnum - accepting number
  1154. X * assoc_rule - rule associated with this NFA state (or 0 if none)
  1155. X * state_type - a STATE_xxx type identifying whether the state is part
  1156. X *              of a normal rule, the leading state in a trailing context
  1157. X *              rule (i.e., the state which marks the transition from
  1158. X *              recognizing the text-to-be-matched to the beginning of
  1159. X *              the trailing context), or a subsequent state in a trailing
  1160. X *              context rule
  1161. X * rule_type - a RULE_xxx type identifying whether this a a ho-hum
  1162. X *             normal rule or one which has variable head & trailing
  1163. X *             context
  1164. X * rule_linenum - line number associated with rule
  1165. X */
  1166. X
  1167. Xextern int current_mns, num_rules, current_max_rules, lastnfa;
  1168. Xextern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
  1169. Xextern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
  1170. X
  1171. X/* different types of states; values are useful as masks, as well, for
  1172. X * routines like check_trailing_context()
  1173. X */
  1174. X#define STATE_NORMAL 0x1
  1175. X#define STATE_TRAILING_CONTEXT 0x2
  1176. X
  1177. X/* global holding current type of state we're making */
  1178. X
  1179. Xextern int current_state_type;
  1180. X
  1181. X/* different types of rules */
  1182. X#define RULE_NORMAL 0
  1183. X#define RULE_VARIABLE 1
  1184. X
  1185. X/* true if the input rules include a rule with both variable-length head
  1186. X * and trailing context, false otherwise
  1187. X */
  1188. Xextern int variable_trailing_context_rules;
  1189. X
  1190. X
  1191. X/* variables for protos:
  1192. X * numtemps - number of templates created
  1193. X * numprots - number of protos created
  1194. X * protprev - backlink to a more-recently used proto
  1195. X * protnext - forward link to a less-recently used proto
  1196. X * prottbl - base/def table entry for proto
  1197. X * protcomst - common state of proto
  1198. X * firstprot - number of the most recently used proto
  1199. X * lastprot - number of the least recently used proto
  1200. X * protsave contains the entire state array for protos
  1201. X */
  1202. X
  1203. Xextern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
  1204. Xextern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
  1205. X
  1206. X
  1207. X/* variables for managing equivalence classes:
  1208. X * numecs - number of equivalence classes
  1209. X * nextecm - forward link of Equivalence Class members
  1210. X * ecgroup - class number or backward link of EC members
  1211. X * nummecs - number of meta-equivalence classes (used to compress
  1212. X *   templates)
  1213. X * tecfwd - forward link of meta-equivalence classes members
  1214. X * tecbck - backward link of MEC's
  1215. X */
  1216. X
  1217. Xextern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
  1218. Xextern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
  1219. X
  1220. X
  1221. X/* variables for start conditions:
  1222. X * lastsc - last start condition created
  1223. X * current_max_scs - current limit on number of start conditions
  1224. X * scset - set of rules active in start condition
  1225. X * scbol - set of rules active only at the beginning of line in a s.c.
  1226. X * scxclu - true if start condition is exclusive
  1227. X * sceof - true if start condition has EOF rule
  1228. X * scname - start condition name
  1229. X * actvsc - stack of active start conditions for the current rule
  1230. X */
  1231. X
  1232. Xextern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
  1233. Xextern char **scname;
  1234. X
  1235. X
  1236. X/* variables for dfa machine data:
  1237. X * current_max_dfa_size - current maximum number of NFA states in DFA
  1238. X * current_max_xpairs - current maximum number of non-template xtion pairs
  1239. X * current_max_template_xpairs - current maximum number of template pairs
  1240. X * current_max_dfas - current maximum number DFA states
  1241. X * lastdfa - last dfa state number created
  1242. X * nxt - state to enter upon reading character
  1243. X * chk - check value to see if "nxt" applies
  1244. X * tnxt - internal nxt table for templates
  1245. X * base - offset into "nxt" for given state
  1246. X * def - where to go if "chk" disallows "nxt" entry
  1247. X * tblend - last "nxt/chk" table entry being used
  1248. X * firstfree - first empty entry in "nxt/chk" table
  1249. X * dss - nfa state set for each dfa
  1250. X * dfasiz - size of nfa state set for each dfa
  1251. X * dfaacc - accepting set for each dfa state (or accepting number, if
  1252. X *    -r is not given)
  1253. X * accsiz - size of accepting set for each dfa state
  1254. X * dhash - dfa state hash value
  1255. X * numas - number of DFA accepting states created; note that this
  1256. X *    is not necessarily the same value as num_rules, which is the analogous
  1257. X *    value for the NFA
  1258. X * numsnpairs - number of state/nextstate transition pairs
  1259. X * jambase - position in base/def where the default jam table starts
  1260. X * jamstate - state number corresponding to "jam" state
  1261. X * end_of_buffer_state - end-of-buffer dfa state number
  1262. X */
  1263. X
  1264. Xextern int current_max_dfa_size, current_max_xpairs;
  1265. Xextern int current_max_template_xpairs, current_max_dfas;
  1266. Xextern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
  1267. Xextern int *base, *def, tblend, firstfree, **dss, *dfasiz;
  1268. Xextern union dfaacc_union
  1269. X    {
  1270. X    int *dfaacc_set;
  1271. X    int dfaacc_state;
  1272. X    } *dfaacc;
  1273. Xextern int *accsiz, *dhash, numas;
  1274. Xextern int numsnpairs, jambase, jamstate;
  1275. Xextern int end_of_buffer_state;
  1276. X
  1277. X/* variables for ccl information:
  1278. X * lastccl - ccl index of the last created ccl
  1279. X * current_maxccls - current limit on the maximum number of unique ccl's
  1280. X * cclmap - maps a ccl index to its set pointer
  1281. X * ccllen - gives the length of a ccl
  1282. X * cclng - true for a given ccl if the ccl is negated
  1283. X * cclreuse - counts how many times a ccl is re-used
  1284. X * current_max_ccl_tbl_size - current limit on number of characters needed
  1285. X *    to represent the unique ccl's
  1286. X * ccltbl - holds the characters in each ccl - indexed by cclmap
  1287. X */
  1288. X
  1289. Xextern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
  1290. Xextern int current_max_ccl_tbl_size;
  1291. Xextern char *ccltbl;
  1292. X
  1293. X
  1294. X/* variables for miscellaneous information:
  1295. X * starttime - real-time when we started
  1296. X * endtime - real-time when we ended
  1297. X * nmstr - last NAME scanned by the scanner
  1298. X * sectnum - section number currently being parsed
  1299. X * nummt - number of empty nxt/chk table entries
  1300. X * hshcol - number of hash collisions detected by snstods
  1301. X * dfaeql - number of times a newly created dfa was equal to an old one
  1302. X * numeps - number of epsilon NFA states created
  1303. X * eps2 - number of epsilon states which have 2 out-transitions
  1304. X * num_reallocs - number of times it was necessary to realloc() a group
  1305. X *          of arrays
  1306. X * tmpuses - number of DFA states that chain to templates
  1307. X * totnst - total number of NFA states used to make DFA states
  1308. X * peakpairs - peak number of transition pairs we had to store internally
  1309. X * numuniq - number of unique transitions
  1310. X * numdup - number of duplicate transitions
  1311. X * hshsave - number of hash collisions saved by checking number of states
  1312. X * num_backtracking - number of DFA states requiring back-tracking
  1313. X * bol_needed - whether scanner needs beginning-of-line recognition
  1314. X */
  1315. X
  1316. Xextern char *starttime, *endtime, nmstr[MAXLINE];
  1317. Xextern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
  1318. Xextern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
  1319. Xextern int num_backtracking, bol_needed;
  1320. X
  1321. Xchar *allocate_array(), *reallocate_array();
  1322. X
  1323. X#define allocate_integer_array(size) \
  1324. X    (int *) allocate_array( size, sizeof( int ) )
  1325. X
  1326. X#define reallocate_integer_array(array,size) \
  1327. X    (int *) reallocate_array( (char *) array, size, sizeof( int ) )
  1328. X
  1329. X#define allocate_int_ptr_array(size) \
  1330. X    (int **) allocate_array( size, sizeof( int * ) )
  1331. X
  1332. X#define allocate_char_ptr_array(size) \
  1333. X    (char **) allocate_array( size, sizeof( char * ) )
  1334. X
  1335. X#define allocate_dfaacc_union(size) \
  1336. X    (union dfaacc_union *) \
  1337. X        allocate_array( size, sizeof( union dfaacc_union ) )
  1338. X
  1339. X#define reallocate_int_ptr_array(array,size) \
  1340. X    (int **) reallocate_array( (char *) array, size, sizeof( int * ) )
  1341. X
  1342. X#define reallocate_char_ptr_array(array,size) \
  1343. X    (char **) reallocate_array( (char *) array, size, sizeof( char * ) )
  1344. X
  1345. X#define reallocate_dfaacc_union(array, size) \
  1346. X    (union dfaacc_union *)  reallocate_array( (char *) array, size, sizeof( union dfaacc_union ) )
  1347. X
  1348. X#define allocate_character_array(size) allocate_array( size, sizeof( char ) )
  1349. X
  1350. X#define reallocate_character_array(array,size) \
  1351. X    reallocate_array( array, size, sizeof( char ) )
  1352. X
  1353. X
  1354. X/* used to communicate between scanner and parser.  The type should really
  1355. X * be YYSTYPE, but we can't easily get our hands on it.
  1356. X */
  1357. Xextern int yylval;
  1358. END_OF_FILE
  1359. if test 21874 -ne `wc -c <'flex/flexdef.h'`; then
  1360.     echo shar: \"'flex/flexdef.h'\" unpacked with wrong size!
  1361. fi
  1362. # end of 'flex/flexdef.h'
  1363. fi
  1364. echo shar: End of archive 4 \(of 7\).
  1365. cp /dev/null ark4isdone
  1366. MISSING=""
  1367. for I in 1 2 3 4 5 6 7 ; do
  1368.     if test ! -f ark${I}isdone ; then
  1369.     MISSING="${MISSING} ${I}"
  1370.     fi
  1371. done
  1372. if test "${MISSING}" = "" ; then
  1373.     echo You have unpacked all 7 archives.
  1374.     rm -f ark[1-9]isdone
  1375. else
  1376.     echo You still need to unpack the following archives:
  1377.     echo "        " ${MISSING}
  1378. fi
  1379. ##  End of shell archive.
  1380. exit 0
  1381.