home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / language / as / source / h / lex < prev    next >
Encoding:
Text File  |  1993-12-26  |  1.9 KB  |  79 lines

  1. /*
  2.  *   lex.h
  3.  * Copyright © 1992 Niklas Röjemo
  4.  */
  5.  
  6. #ifndef _lex_h
  7. #define _lex_h
  8.  
  9. #ifndef _global_h
  10. #include "global.h"
  11. #endif
  12.  
  13. typedef enum {
  14.   Op_fload,Op_fexec,Op_fsize,Op_fattr, /* unop */
  15.   Op_lnot,Op_not,Op_neg,Op_none,       /* unop */
  16.   Op_mul,Op_div,Op_mod,                /* 10 */
  17.   Op_add,Op_sub,                       /*  9 */
  18.   Op_and,                              /*  8 */
  19.   Op_or,                               /*  7 */
  20.   Op_xor,                              /*  6 */
  21.   Op_asr,Op_sr,Op_sl,Op_ror,Op_rol,    /*  5 */
  22.   Op_le,Op_ge,Op_lt,Op_gt,             /*  4 */
  23.   Op_eq,Op_ne,                         /*  3 */
  24.   Op_land,                             /*  2 */
  25.   Op_lor                               /*  1 */
  26. } Operator;
  27.  
  28. typedef enum {  LexId,      /* start with character */
  29.                 LexString,  /* "jsgd" */
  30.                 LexInt,     /* start with digit */
  31.                 LexFloat,   /* start with digit contains dot */
  32.                 LexOperator,/* + - * % / >> >>> << */
  33.                             /* ~ & | ^ ! && || */
  34.                             /* == != <= >= */
  35.                 LexPosition,/* . representing current position */
  36.                 LexStorage, /* @ representing current storage counter */
  37.                 LexDelim,   /* ()[]{}, */
  38.                 LexNone
  39. } LexTag;
  40.  
  41.  
  42. typedef union {
  43.   LexTag tag;    /* LexStorage LexDelim LexNone */
  44.   struct {
  45.     LexTag  tag;
  46.     char   *str;
  47.     int     len;
  48.     int     hash;
  49.   } LexId;
  50.   struct {
  51.     LexTag  tag;
  52.     char   *str;
  53.     int     len;
  54.   } LexString;
  55.   struct {
  56.     LexTag  tag;
  57.     int     value;
  58.   } LexInt;
  59.   struct {
  60.     LexTag  tag;
  61.     FLOAT  value;
  62.   } LexFloat;
  63.   struct {
  64.     LexTag   tag;
  65.     Operator op;
  66.     int      pri;
  67.   } LexOperator;
  68.   struct {
  69.     LexTag  tag;
  70.     char    delim;
  71.   } LexDelim;
  72. } Lex;
  73.  
  74. Lex lexGetId(void);
  75. Lex lexGetPrim(void);
  76. Lex lexGetBinop(void);
  77. int lexNextPri(void);
  78. #endif
  79.