home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / mit2mot1 / scanner.l < prev    next >
Text File  |  1993-10-23  |  889b  |  37 lines

  1. %{
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include "ytab.h"
  6. #include "global.h"
  7.  
  8. unsigned long line_num = 1;
  9. %}
  10.  
  11. ID    [A-Za-z_\.][A-Za-z0-9_]*(\.?)
  12. NUM    ([0-9]+)|(0x[0-9a-fA-f]+)
  13. WS    [     ][     ]*
  14. ES    \\([abfnrtv'"?\\]|[0-7]{1,3}|x[0-9a-fA-F]+)
  15.  
  16. %%
  17.  
  18. {WS}            ;
  19. "|".*$            ;
  20. ^"#".*$            ;
  21. {NUM}            {yylval.numval=strtol(yytext, NULL, 0); return NUMBER;}
  22. {ID}            {
  23.             int n=lookup(yytext, yylval.str);
  24.               if (n==0) {
  25.               char *s=yytext+yyleng-1;
  26.                 strcpy(yylval.str, yytext);
  27.                 if (*s=='.') *s='_';
  28.                 return ID;
  29.               } else return n;
  30.             }
  31. [0-9]:            {strcpy(yylval.str, yytext); return TMPLABEL;}
  32. [0-9][fb]        {strcpy(yylval.str, yytext); return TMPLABELfb;}
  33. \"([^"\n\\]|{ES})*\"    {strcpy(yylval.str, yytext); return STRING;}
  34. [-+(),:@&^!*/%<>#]    return *yytext;
  35. "\n"            {line_num++; return NL;}
  36. .            yyerror("Illegal character %c", *yytext);
  37.