home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / useful / dist / util / libs / reqtools / glue / gcc / gcc_glue.lha / fd2gcc / fd2gcc.l < prev    next >
Encoding:
Lex Description  |  1993-02-26  |  2.2 KB  |  179 lines

  1. %{
  2. #include "fd2gcc.tab.h"
  3.  
  4. #define YY_USER_INIT BEGIN FD
  5.  
  6. extern int      yylineno;
  7. extern char    *identifyer;
  8. %}
  9.  
  10. %START FD FDCMT PROTO PROTOCMT
  11.  
  12. WHITE    [ \t]
  13. NUMBER    [0-9]
  14. LETTER    [A-Za-z_]
  15. ALFNUM    [A-Za-z_0-9]
  16. REGCHAR    [dDaA]
  17. REGNUM    [0-7]
  18.  
  19. CMTSTART    "/*"
  20. CMTEND        "*/"
  21.  
  22. PTR            "*"
  23. BUILTIN        "char"|"int"|"long"|"float"|"double"|"void"|"BYTE"|"UBYTE"|"WORD"|"UWORD"|"LONG"|"ULONG"|"FLOAT"|"DOUBLE"|"VOID"|"BOOL"|"APTR"|"BPTR"|"CPTR"|"STRPTR"
  24. OTHER        "Tag"|"CxObj"|"IX"|"CxMsg"|"PLANEPTR"|"DisplayInfoHandle"|"Msg"
  25. UNSIGNED    "unsigned"
  26.  
  27. %%
  28.  
  29. {WHITE}+    {
  30.         }
  31.  
  32. <FD>^"*".*"\n"    {
  33.     yylineno++;
  34.     return(COMMENT);
  35.         }
  36. <FD>^"##private"    {
  37.     return(PRIVATE);
  38.         }
  39. <FD>^"##public"    {
  40.     return(PUBLIC);
  41.         }
  42. <FD>^"##base"    {
  43.     return(BASE);
  44.         }
  45. <FD>^"##bias"    {
  46.     return(BIAS);
  47.         }
  48. <FD>^"##end"    {
  49.     return(END);
  50.         }
  51. <FD>{NUMBER}+    {
  52.     return(NUMBER);
  53.         }
  54. <FD>{REGCHAR}{REGNUM}    {
  55.     return(REGISTER);
  56.         }
  57. <FD>{LETTER}+{ALFNUM}*    {
  58.     strcpy(identifyer, yytext);
  59.     return(IDENTIFYER);
  60.         }
  61. <FD>"("        {
  62.     return(OPEN);
  63.         }
  64. <FD>")"        {
  65.     return(CLOSE);
  66.         }
  67. <FD>","        {
  68.     return(ARGSEP);
  69.         }
  70. <FD>"/"        {
  71.     return(REGSEP);
  72.         }
  73.  
  74. <FD>{CMTSTART}    {
  75.     BEGIN FDCMT;
  76.         }
  77.  
  78. <FDCMT>{CMTEND}    {
  79.     BEGIN FD;
  80.     }
  81. <FDCMT>"\n"        {
  82.     yylineno++;
  83.     }
  84. <FDCMT>.            {
  85.     }
  86.  
  87. <FD>"#ifndef".*"\n"    {
  88.     yylineno++;
  89.     BEGIN    PROTO;
  90.         }
  91.  
  92. <PROTO>"struct"    {
  93.     return(STRUCT);
  94.         }
  95.  
  96. <PROTO>{UNSIGNED}{WHITE}+({BUILTIN}|{OTHER})    {
  97.     return(BUILTIN);
  98.         }
  99.  
  100. <PROTO>({BUILTIN}|{OTHER})    {
  101.     return(BUILTIN);
  102.         }
  103.  
  104. <PROTO>{LETTER}+{ALFNUM}*    {
  105.     strcpy(identifyer, yytext);
  106.     return(IDENTIFYER);
  107.         }
  108.  
  109. <PROTO>"..."    {
  110.     return(VARARGS);
  111.         }
  112.  
  113. <PROTO>({PTR}{WHITE}*)+    {
  114.     return(PTR);
  115.         }
  116.  
  117. <PROTO>"("        {
  118.     return(OPEN);
  119.         }
  120. <PROTO>")"        {
  121.     return(CLOSE);
  122.         }
  123. <PROTO>","        {
  124.     return(ARGSEP);
  125.         }
  126.  
  127. <PROTO>";"    {
  128.     return(SEMICOL);
  129.         }
  130.  
  131. <PROTO>{CMTSTART}    {
  132.     BEGIN PROTOCMT;
  133.         }
  134.  
  135. <PROTOCMT>{CMTEND}    {
  136.     BEGIN PROTO;
  137.     }
  138. <PROTOCMT>"\n"        {
  139.     yylineno++;
  140.     }
  141. <PROTOCMT>.            {
  142.     }
  143.  
  144. <PROTO>"#ifndef".*"\n"    {
  145.     yylineno++;
  146.         }
  147. <PROTO>"#define".*"\n"    {
  148.     yylineno++;
  149.         }
  150. <PROTO>"#endif".*"\n"    {
  151.     yylineno++;
  152.         }
  153. <PROTO>"#include".*"\n"    {
  154.     yylineno++;
  155.         }
  156.  
  157. <PROTO>"\n"    {
  158.     yylineno++;
  159.         }
  160.  
  161. <PROTO>.    {
  162.         }
  163.  
  164.  
  165. "\n"    {
  166.     yylineno++;
  167.     return(NEWLINE);
  168.         }
  169.  
  170. .        {
  171.     return(yytext[0]);
  172.         }
  173.  
  174. %%
  175.  
  176. /* lexical part of .fd file parsing     */
  177.  
  178. int             yylineno = 0;
  179.