home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / assembler / as / src / h / lex < prev    next >
Encoding:
Text File  |  1993-02-10  |  1.8 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_lnot,Op_not,Op_neg,Op_none,    /* unop */
  15.   Op_mul,Op_div,Op_mod,             /* 10 */
  16.   Op_add,Op_sub,                    /*  9 */
  17.   Op_and,                           /*  8 */
  18.   Op_or,                            /*  7 */
  19.   Op_xor,                           /*  6 */
  20.   Op_asr,Op_sr,Op_sl,Op_ror,Op_rol, /*  5 */
  21.   Op_le,Op_ge,Op_lt,Op_gt,          /*  4 */
  22.   Op_eq,Op_ne,                      /*  3 */
  23.   Op_land,                          /*  2 */
  24.   Op_lor                            /*  1 */
  25. } Operator;
  26.  
  27. typedef enum {  LexId,      /* start with character */
  28.                 LexString,  /* "jsgd" */
  29.                 LexInt,     /* start with digit */
  30.                 LexFloat,   /* start with digit contains dot */
  31.                 LexOperator,/* + - * % / >> >>> << */
  32.                             /* ~ & | ^ ! && || */
  33.                             /* == != <= >= */
  34.                 LexPosition,/* . representing current position */
  35.                 LexStorage, /* @ representing current storage counter */
  36.                 LexDelim,   /* ()[]{}, */
  37.                 LexNone
  38. } LexTag;
  39.  
  40.  
  41. typedef union {
  42.   LexTag tag;    /* LexStorage LexDelim LexNone */
  43.   struct {
  44.     LexTag  tag;
  45.     char   *str;
  46.     int     len;
  47.     int     hash;
  48.   } LexId;
  49.   struct {
  50.     LexTag  tag;
  51.     char   *str;
  52.     int     len;
  53.   } LexString;
  54.   struct {
  55.     LexTag  tag;
  56.     int     value;
  57.   } LexInt;
  58.   struct {
  59.     LexTag  tag;
  60.     FLOAT  value;
  61.   } LexFloat;
  62.   struct {
  63.     LexTag   tag;
  64.     Operator op;
  65.     int      pri;
  66.   } LexOperator;
  67.   struct {
  68.     LexTag  tag;
  69.     char    delim;
  70.   } LexDelim;
  71. } Lex;
  72.  
  73. Lex lexGetId(void);
  74. Lex lexGetPrim(void);
  75. Lex lexGetBinop(void);
  76. int lexNextPri(void);
  77.  
  78. #endif
  79.