home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / compcomp / tpyacc / yreflex.l < prev    next >
Text File  |  1991-04-30  |  1KB  |  84 lines

  1.  
  2. %{
  3.  
  4. (* Lexical analyzer for the YREF program, V1.1 4-30-91 AG
  5.    implements a lexical analyzer for Yacc grammars *)
  6.  
  7. function yywrap : Boolean;
  8.   begin
  9.     yywrap := true; (* files are closed by main program *)
  10.   end(*yywrap*);
  11.  
  12. %}
  13.  
  14. L            [A-Za-z_]
  15. D            [0-9]
  16. Q            \\([0-7]{1,3}|.)
  17. P            [\\%]
  18.  
  19. %%
  20.  
  21. %{
  22.  
  23. var c : Char;
  24.  
  25. %}
  26.  
  27.   (* whitespace: *)
  28.  
  29. [ \t\n]            ;
  30.  
  31.   (* comments: *)
  32.  
  33. "/*"            skip('*/');
  34.  
  35.   (* identifiers, literals and numbers: *)
  36.  
  37. {L}({L}|{D})*        begin
  38.                           symlineno := yylineno;
  39.               yylval := key(yytext, max_syms, lookup, entry);
  40.                           scan(c);
  41.                           if c=':' then
  42.                 return(C_ID)
  43.               else
  44.                 return(ID);
  45.             end;
  46.  
  47. '([^'\n\\]|{Q})+'    |
  48. \"([^"\n\\]|{Q})+\"    return(LITERAL);
  49.  
  50. {D}+            return(NUMBER);
  51.  
  52.   (* keywords (various synonyms): *)
  53.  
  54. {P}token        |
  55. {P}term            |
  56. {P}0            return(PTOKEN);
  57.  
  58. {P}left            |
  59. {P}<            return(PLEFT);
  60.  
  61. {P}right        |
  62. {P}>            return(PRIGHT);
  63.  
  64. {P}nonassoc        |
  65. {P}binary        |
  66. {P}2            return(PNONASSOC);
  67.  
  68. {P}type            return(PTYPE);
  69.  
  70. {P}start        return(PSTART);
  71.  
  72. {P}prec            |
  73. {P}=            return(PPREC);
  74.  
  75. {P}{P}            return(PP);
  76.  
  77. {P}\{            return(LCURL);
  78.  
  79. {P}\}            return(RCURL);
  80.  
  81.   (* others: *)
  82.  
  83. .            returnc(yytext[1]);
  84.