lex 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .TH LEX 1
  2. .SH NAME
  3. lex \- generator of lexical analysis programs
  4. .SH SYNOPSIS
  5. .B lex
  6. [
  7. .B -tvn9
  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. .TP
  45. .B -9
  46. Adds code to be able to compile through the native C compilers.
  47. .SH EXAMPLES
  48. This program converts upper case to lower,
  49. removes blanks at the end of lines,
  50. and replaces multiple blanks by single blanks.
  51. .PP
  52. .EX
  53. %%
  54. [A-Z] putchar(yytext[0]+\'a\'-\'A\');
  55. [ ]+$
  56. [ ]+ putchar(\' \');
  57. .EE
  58. .SH FILES
  59. .TF /sys/lib/lex/ncform
  60. .TP
  61. .B lex.yy.c
  62. output
  63. .TP
  64. .B /sys/lib/lex/ncform
  65. template
  66. .SH "SEE ALSO"
  67. .IR yacc (1),
  68. .IR sed (1)
  69. .br
  70. M. E. Lesk and E. Schmidt,
  71. `LEX\(emLexical Analyzer Generator',
  72. .I
  73. Unix Research System Programmer's Manual,
  74. Tenth Edition, Volume 2.
  75. .SH SOURCE
  76. .B /sys/src/cmd/lex
  77. .SH BUGS
  78. Cannot handle
  79. .SM UTF.
  80. .br
  81. The asteroid to kill this dinosaur is still in orbit.