1
0

lex 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .TH LEX 1
  2. .SH NAME
  3. lex \- generator of lexical analysis programs
  4. .SH SYNOPSIS
  5. .B lex
  6. [
  7. .B -tvn
  8. ]
  9. [
  10. .I file ...
  11. ]
  12. .SH DESCRIPTION
  13. .I Lex
  14. generates programs to be used in simple lexical analysis of text.
  15. The input
  16. .I files
  17. (standard input default)
  18. contain regular expressions
  19. to be searched for and actions written in C to be executed when
  20. expressions are found.
  21. .PP
  22. A C source program,
  23. .B lex.yy.c
  24. is generated.
  25. This program, when run, copies unrecognized portions of
  26. the input to the output,
  27. and executes the associated
  28. C action for each regular expression that is recognized.
  29. .PP
  30. The options have the following meanings.
  31. .TP
  32. .B -t
  33. Place the result on the standard output instead of in file
  34. .BR lex.yy.c .
  35. .TP
  36. .B -v
  37. Print a one-line summary of statistics of the generated analyzer.
  38. .TP
  39. .B -n
  40. Opposite of
  41. .BR -v ;
  42. .B -n
  43. is default.
  44. .SH EXAMPLES
  45. This program converts upper case to lower,
  46. removes blanks at the end of lines,
  47. and replaces multiple blanks by single blanks.
  48. .PP
  49. .EX
  50. %%
  51. [A-Z] putchar(yytext[0]+\'a\'-\'A\');
  52. [ ]+$
  53. [ ]+ putchar(\' \');
  54. .EE
  55. .SH FILES
  56. .TF /sys/lib/lex/ncform
  57. .TP
  58. .B lex.yy.c
  59. output
  60. .TP
  61. .B /sys/lib/lex/ncform
  62. template
  63. .SH "SEE ALSO"
  64. .IR yacc (1),
  65. .IR sed (1)
  66. .br
  67. M. E. Lesk and E. Schmidt,
  68. `LEX\(emLexical Analyzer Generator',
  69. .I
  70. Unix Research System Programmer's Manual,
  71. Tenth Edition, Volume 2.
  72. .SH SOURCE
  73. .B /sys/src/cmd/lex
  74. .SH BUGS
  75. Cannot handle
  76. .SM UTF.
  77. .br
  78. The asteroid to kill this dinosaur is still in orbit.