home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 December / PCO_1298.ISO / filesbbs / os2 / fn128os2.arj / FN128OS2.ZIP / fn128os2 / src / lex.l < prev    next >
Encoding:
Lex Description  |  1998-10-02  |  3.4 KB  |  143 lines

  1. %{
  2. /*
  3.  # $Id: lex.l,v 1.6 1998/03/10 14:11:33 fbm Exp fbm $
  4.  # Copyright (C) 1997,1998 Farrell McKay
  5.  # All rights reserved.
  6.  #
  7.  # This file is part of the Fortify distribution, a toolkit for
  8.  # upgrading the cryptographic strength of the Netscape Navigator
  9.  # web browser, authored by Farrell McKay.
  10.  #
  11.  # This toolkit is provided to the recipient under the
  12.  # following terms and conditions:-
  13.  #   1.  This copyright notice must not be removed or modified.
  14.  #   2.  This toolkit may not be reproduced or included in any commercial
  15.  #       media distribution, or commercial publication (for example CD-ROM,
  16.  #       disk, book, magazine, journal) without first obtaining the author's
  17.  #       express permission.
  18.  #   3.  This toolkit, or any component of this toolkit, may not be
  19.  #       commercially resold, redeveloped, rewritten, enhanced or otherwise
  20.  #       used as the basis for commercial venture, without first obtaining
  21.  #       the author's express permission.
  22.  #   4.  Subject to the above conditions being observed (1-3), this toolkit
  23.  #       may be freely reproduced or redistributed.
  24.  #   5.  This software is provided "as-is", without express or implied
  25.  #       warranty.  In no event shall the author be liable for any direct,
  26.  #       indirect or consequential damages however caused.
  27.  #   6.  Subject to the above conditions being observed (1-5),
  28.  #       this toolkit may be used at no cost to the recipient.
  29.  #
  30.  # Farrell McKay
  31.  # Wayfarer Systems Pty Ltd        contact@fortify.net
  32.  */
  33.  
  34. #include <stdlib.h>
  35. #include <sys/types.h>
  36. #include "misc.h"
  37. #include "morpher.h"
  38. #ifdef OS2
  39. #include "y_tab.h"
  40. #else
  41. #include "y.tab.h"
  42. #endif
  43.  
  44. #ifndef YYLMAX
  45. #define YYLMAX 1024
  46. #endif
  47.  
  48. extern YYSTYPE        yylval;
  49.  
  50. static int        linenum;
  51.  
  52. extern int        yylex();
  53.  
  54. void
  55. lex_file_input(FILE *fp)
  56. {
  57.     linenum = 1;
  58.     yyin = fp;
  59. }
  60.  
  61. int
  62. yywrap()
  63. {
  64.     return 1;
  65. }
  66.  
  67. void
  68. yyerror(const char *msg)
  69. {
  70.     fprintf(stderr, "%s (at or before line %d)\n", msg, linenum);
  71.     exit(2);
  72. }
  73.  
  74. /*
  75. %p n       Number of positions                     2500 
  76. %n n       Number of states                         500 
  77. %a n       Number of transitions                   2000 
  78. %e n       Number of parse tree nodes              1000 
  79. %k n       Number of packed character classes     10000 
  80. %o n       Size of the output array                3000
  81. */
  82.  
  83. %}
  84.  
  85. %a             5000
  86. %o            10000
  87.  
  88. D            [0-9]
  89. H            [0-9a-f]
  90. E            (\\.)
  91. Z            [^ \f\t\n\.{}\[\],;"]
  92.  
  93. %%
  94.  
  95. #.*\n            { linenum++; }
  96. ;.*\n            { linenum++; }
  97.  
  98. init            { return INIT; }
  99. grammar            { return GRAMMAR; }
  100. target            { return TARGET; }
  101. text_offset        { return TEXT_OFFSET; }
  102. data_offset        { return DATA_OFFSET; }
  103. rodata_offset        { return RODATA_OFFSET; }
  104.  
  105. segment            { return SEGMENT; }
  106. msg            { return MSG; }
  107. grade            { return GRADE; }
  108. base            { return BASE; }
  109. offset            { return OFFSET; }
  110. old_value        { return OLD; }
  111. new_value        { return NEW; }
  112. context            { return CONTEXT; }
  113.  
  114. text            { return TEXT; }
  115. data            { return DATA; }
  116. rodata            { return RODATA; }
  117.  
  118. print            { return PRINT; }
  119. assert            { return ASSERT; }
  120. ptr            { return PTR; }
  121. addr            { return ADDR; }
  122.  
  123. ==            { return EQ; }
  124. !=            { return NE; }
  125. \<            { return LT; }
  126. \<=            { return LE; }
  127. \>            { return GT; }
  128. \>=            { return GE; }
  129.  
  130. \"(\\.|[^\\"\n])*\"    { return STRING; }
  131.  
  132. [+-]?0x{H}+        { yylval.ul = (unsigned long) strtol(yytext, (char **)0, 0); return NUM; }
  133. [+-]?{D}+        { yylval.ul = (unsigned long) strtol(yytext, (char **)0, 0); return NUM; }
  134.  
  135. [ \f\t]            ;
  136. \n                      { linenum++; }
  137.  
  138. ({E}|{Z})+        { return TOKEN; }
  139.  
  140. .            { return yytext[0]; }
  141.  
  142. %%
  143.