home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume17 / pps / c.l < prev    next >
Text File  |  1989-02-06  |  1KB  |  89 lines

  1. %{
  2. #ifndef lint
  3. static char rcsid[] = "$Header: c.l,v 0.0 88/06/22 05:22:01 on Rel $";
  4. #endif
  5. #include "pps.h"
  6. #include <ctype.h>
  7.  
  8. int nbrace;
  9. %}
  10. letter    [A-Za-z_]
  11. digit    [0-9]
  12. white    [ \t]
  13. %Start COMMENT STRING1 STRING2 KEYWORD
  14. %%
  15. <INITIAL>^{white}*{letter}({letter}|{digit})*/{white}*\(    {
  16.             register char *cp = yytext;
  17.             if (nbrace == 0) {
  18.                 while (isspace(*cp++))
  19.                     ;
  20.                 funct(--cp);
  21.             }
  22.             REJECT;
  23.         }
  24. <INITIAL>{letter}({letter}|{digit})*    {
  25.             int kw = iskw(yytext);
  26.             if (kw)
  27.                 begin(KEYWORD);
  28.             ECHO;
  29.             if (kw)
  30.                 begin(INITIAL);
  31.         }
  32. <INITIAL>\"    { begin(STRING1); ECHO; }
  33. <INITIAL>\'    { begin(STRING2); ECHO; }
  34. <INITIAL>\/\*    { begin(COMMENT); ECHO; }
  35. <STRING1>\\.    { ECHO; }
  36. <STRING2>\\.    { ECHO; }
  37. <STRING1>\"    { ECHO; begin(INITIAL); }
  38. <STRING2>\'    { ECHO; begin(INITIAL); }
  39. <COMMENT>\*\/    { ECHO; begin(INITIAL); }
  40. [\t\n\f]+    { space(yytext); }
  41. <INITIAL>\{    { nbrace++; REJECT; }
  42. <INITIAL>\}    { nbrace--; REJECT; }
  43. .        { ECHO; }
  44. %%
  45. /*
  46.  * This should better be sorted by frequency.
  47.  */
  48. char *keywords[] = {
  49.     "   ",
  50.     "asm",
  51.     "auto",
  52.     "break",
  53.     "case",
  54.     "char",
  55.     "continue",
  56.     "default",
  57.     "define",
  58.     "do",
  59.     "double",
  60.     "else",
  61.     "endif",
  62.     "enum",
  63.     "extern",
  64.     "float",
  65.     "for",
  66.     "fortran",
  67.     "goto",
  68.     "if",
  69.     "ifdef",
  70.     "ifndef",
  71.     "include",
  72.     "int",
  73.     "long",
  74.     "register",
  75.     "return",
  76.     "short",
  77.     "sizeof",
  78.     "static",
  79.     "struct",
  80.     "switch",
  81.     "typedef",
  82.     "undef",
  83.     "union",
  84.     "unsigned",
  85.     "void", 
  86.     "while",
  87.     NULL
  88. };
  89.