AT&T UNIX™PC Unix System V Users Manual - tenox
AT&T UNIX™PC Unix System V Users Manual - tenox AT&T UNIX™PC Unix System V Users Manual - tenox
LEX ( I ) LEX ( I ) NAME lex - generate programs for simple lexical tasks SYNOPSIS lex [ -rctvn ] [ file ] ... DESCRIPTION Lex generates programs to be used in simple lexical analysis of text. The input files (standard input default) contain strings and expressions to be searched for, and C text to be executed when strings are found. A file lex.yy.c is generated which, when loaded with the library, copies the input to the output except when a string specified in the file is found; then the corresponding program text is executed. The actual string matched is left in yytext, an external character array. Matching is done in order of the strings in the file. The strings may contain square brackets to indicate character classes, as in [a.bx-z] to indicate a., b, x, y, and z; and the operators *, +, and ? mean respectively any non-negative number of, any positive number of, and either zero or one occurrences of, the previous character or character class. The character • is the class of all ASCII characters except new-line. Parentheses for grouping and vertical bar for alternation are also supported. The notation r { d, e} in a rule indicates between d and e instances of regular expression r. It has higher precedence than I , but lower than *, ? , +, and concatenation. The character A at the beginning of an expression permits a successful match only immediately after a new-line, and the character $ at the end of an expression requires a trailing new-line. The character / in an expression indicates trailing context; only the part of the expression up to the slash is returned in yytext, but the remainder of the expression must follow in the input stream. An operator character may be used as an ordinary symbol if it is within " symbols or preceded by \. Thus [a.-zA-Z]+ matches a string of letters. Three subroutines defined as macros are expected: input() to read a character; unput( c ) to replace a character read; and output( c ) to place an output character. They are defined in terms of the standard streams, but you can override them. The program generated is named yylex(), and the library contains a main() which calls it. The action REJECT on the right side of the rule causes this match to be rejected and the next suitable match executed; the function yymore() accumulates additional characters into the same yytext; and the function yyless(p) pushes back the portion of the string matched beginning at p, which should be between yytext and yytext+yyleng . The macros input and output use files yyin and yyout to read from and write to, defaulted to stdin and stdout, respectively. Any line beginning with a blank is assumed to contain only C text and is copied; if it precedes %% it is copied into the external definition area of the lex.yy.c file. All rules should follow a%%, as in YACC. Lines preceding %% which begin with a non-blank - 1 -
- Page 346 and 347: · r1 . .... .. ._ _ . . r1 ' ·
- Page 348 and 349: HP(l) HP (1) is adjacent to an ASCl
- Page 351: ID ( 1 ) ID ( 1) NAME id - print us
- Page 355 and 356: IPCS ( 1) IPCS ( 1) NAME ipcs - rep
- Page 357 and 358: IPCS ( 1 ) OWNER GROUP CREATOR CGRO
- Page 359 and 360: JOIN ( 1 ) JOIN ( 1 ) NAME join - r
- Page 361: KILL (I) KILL(l) NAME kill - termin
- Page 364 and 365: KSH(l) KSH ( 1) A command is either
- Page 366 and 367: KSH ( 1) KSH ( 1) The following exp
- Page 368 and 369: KSH ( 1) KSH ( 1) ${parameter%patte
- Page 370 and 371: KSH ( 1) KSH(l) with the parameter
- Page 372 and 373: KSH ( 1) KSH(l) redirected using a
- Page 374 and 375: KSH ( 1) KSH(l) variables whose sco
- Page 376 and 377: KSH ( 1 ) KSH(l) Command Re-entry.
- Page 378 and 379: KSH(l) KSH(l) using paper terminals
- Page 380 and 381: KSH ( 1) KSH ( 1) [count]Tc Equival
- Page 382 and 383: KSH ( 1) KSH(I) Line feed and print
- Page 384 and 385: KSH ( 1 ) KSH ( 1) fc -e - [ old= n
- Page 386 and 387: KSH ( 1 ) KSH(l) ?, the remainder o
- Page 388 and 389: KSH (l) KSH(l) test [ expr ] Evalua
- Page 390 and 391: KSH ( 1 ) KSH(l) ulimit [ -cdfmpt 1
- Page 393 and 394: LD ( 1 ) LD (1) NAME ld - link edit
- Page 395: LD ( 1 ) FILES LD ( 1) allow compat
- Page 399: LINE(l) NAME line - read one line S
- Page 402 and 403: LINT(l) LINT ( 1) FILES The -D, -U
- Page 405 and 406: LORDER ( l ) LORDER (l) NAME !order
- Page 407 and 408: LP ( l ) LP (1) NAME lp, cancel - s
- Page 409 and 410: LPSTAT ( 1 ) LPSTAT ( l ) NAME lpst
- Page 411 and 412: LS (I) LS (I) NAME Is - list conten
- Page 413: LS (l) LS (l) The indications of se
- Page 416 and 417: M4 ( 1) M4 ( 1) the collection of t
- Page 418 and 419: M4 (1) sysval maketemp m4exit m4wra
- Page 420 and 421: MAIL ( 1) MAIL (l) FILES each perso
- Page 422 and 423: MAKE(l) MAKE (l) .PRECIOUS Dependen
- Page 424 and 425: MAKE (l) MAKE (l) Strings (for the
- Page 426 and 427: MAKE ( 1) MAKE ( 1) Libraries If a
- Page 428 and 429: .� ... ,' ' · - -
- Page 430 and 431: ,�
- Page 432 and 433: (�
- Page 434 and 435: I� / _:�
- Page 437 and 438: MM(I) MM(I) NAME mm, osdd, checkmm
- Page 439 and 440: MMT ( l ) MMT ( l ) NAME mmt, mvt -
- Page 441 and 442: MORE ( I) MORE ( l ) NAME more, pag
- Page 443 and 444: MORE ( I ) MORE (I ) v Start up the
- Page 445 and 446: NEWFORM (l) NEWFORM (l) NAME newfor
LEX ( I ) LEX ( I )<br />
NAME<br />
lex - generate programs for simple lexical tasks<br />
SYNOPSIS<br />
lex [ -rctvn ] [ file ] ...<br />
DESCRIPTION<br />
Lex generates programs to be used in simple lexical analysis of<br />
text.<br />
The input files (standard input default) contain strings and<br />
expressions to be searched for, and C text to be executed when<br />
strings are found.<br />
A file lex.yy.c is generated which, when loaded with the library,<br />
copies the input to the output except when a string specified in<br />
the file is found; then the corresponding program text is executed.<br />
The actual string matched is left in yytext, an external character<br />
array. Matching is done in order of the strings in the file. The<br />
strings may contain square brackets to indicate character classes,<br />
as in [a.bx-z] to indicate a., b, x, y, and z; and the operators *,<br />
+, and ? mean respectively any non-negative number of, any<br />
positive number of, and either zero or one occurrences of, the previous<br />
character or character class. The character • is the class of<br />
all ASCII characters except new-line. Parentheses for grouping and<br />
vertical bar for alternation are also supported. The notation<br />
r { d, e} in a rule indicates between d and e instances of regular<br />
expression r. It has higher precedence than I , but lower than *,<br />
? , +, and concatenation. The character A at the beginning of an<br />
expression permits a successful match only immediately after a<br />
new-line, and the character $ at the end of an expression requires<br />
a trailing new-line. The character / in an expression indicates<br />
trailing context; only the part of the expression up to the slash is<br />
returned in yytext, but the remainder of the expression must follow<br />
in the input stream. An operator character may be used as an<br />
ordinary symbol if it is within " symbols or preceded by \. Thus<br />
[a.-zA-Z]+ matches a string of letters.<br />
Three subroutines defined as macros are expected: input() to read<br />
a character; unput( c ) to replace a character read; and output( c )<br />
to place an output character. They are defined in terms of the<br />
standard streams, but you can override them. The program generated<br />
is named yylex(), and the library contains a main() which<br />
calls it. The action REJECT on the right side of the rule causes<br />
this match to be rejected and the next suitable match executed;<br />
the function yymore() accumulates additional characters into the<br />
same yytext; and the function yyless(p) pushes back the portion<br />
of the string matched beginning at p, which should be between<br />
yytext and yytext+yyleng . The macros input and output use files<br />
yyin and yyout to read from and write to, defaulted to stdin<br />
and stdout, respectively.<br />
Any line beginning with a blank is assumed to contain only C text<br />
and is copied; if it precedes %% it is copied into the external<br />
definition area of the lex.yy.c file. All rules should follow a%%,<br />
as in YACC. Lines preceding %% which begin with a non-blank<br />
- 1 -