home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / GED403R.LZX / Install / Install.run / GOLDEDDATA / developer / examples / scanner / source / pascal.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-11  |  1.8 KB  |  65 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for Pascal style functions & procedure. Scan
  17.   handlers are plain functions (LoadSeg'ed by GED): no standard C startup code,
  18.   no library calls.
  19.   
  20.   DICE-C:
  21.   
  22.   dcc pascal.c -// -l0 -md -mRR -o ram:pascal
  23.  
  24.   ------------------------------------------------------------------------------
  25. */
  26.  
  27. #include <exec/types.h>
  28.  
  29. #define UPPER(a) ((a) & 95)
  30.  
  31. ULONG
  32. ScanHandlerPascal(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  33. {
  34.     const char *version = "$VER: Pascal 1.0 (11.12.95)";
  35.  
  36.     if (len > 9) {
  37.  
  38.         if (UPPER(**text) == 'F') {
  39.  
  40.             if ((UPPER((*text)[1]) == 'U') && (UPPER((*text)[2]) == 'N') && (UPPER((*text)[3]) == 'C') && (UPPER((*text)[4]) == 'T') && (UPPER((*text)[5]) == 'I') && (UPPER((*text)[6]) == 'O') && (UPPER((*text)[7]) == 'N') && ((*text)[8] == ' ')) {
  41.  
  42.                 // found FUNCTION
  43.  
  44.                 *text += 9;
  45.  
  46.                 return(len - 9);
  47.             }
  48.         }
  49.         else if (UPPER(**text) == 'P') {
  50.  
  51.             if ((UPPER((*text)[1]) == 'R') && (UPPER((*text)[2]) == 'O') && (UPPER((*text)[3]) == 'C') && (UPPER((*text)[4]) == 'E') && (UPPER((*text)[5]) == 'D') && (UPPER((*text)[6]) == 'U') && (UPPER((*text)[7]) == 'R') && (UPPER((*text)[8]) == 'E') && ((*text)[9] == ' ')) {
  52.  
  53.                 // found PROCEDURE
  54.  
  55.                 *text += 10;
  56.  
  57.                 return(len - 10);
  58.             }
  59.         }
  60.     }
  61.  
  62.     return(FALSE);
  63. }
  64.  
  65.