home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Add-Ons / CodeWarrior / DASM 2.0 / DASM Src.sit / SRC / EXPRESS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-16  |  2.5 KB  |  126 lines

  1. #ifndef _H_express
  2. #define _H_express
  3.  
  4. #define MAXBYTE            255
  5.  
  6. #define MAXWORD            65535
  7.  
  8. #define VARSIZE            32     // number of characters in a variable name
  9.  
  10. #define NUMVARS            50    // number of variables to store
  11.  
  12. #define CLASS_NULL            0
  13. #define CLASS_BYTE            1
  14. #define CLASS_WORD            2
  15. #define CLASS_LONG            3
  16. #define CLASS_PTR            4
  17.  
  18. enum
  19. {
  20.     TOKEN_END = 0,
  21.     TOKEN_PLUS,
  22.     TOKEN_MINUS,
  23.     TOKEN_MULT,
  24.     TOKEN_DIV,
  25.     TOKEN_RPAREN,
  26.     TOKEN_LPAREN,
  27.     TOKEN_CONST,
  28.     TOKEN_VAR,
  29.     TOKEN_AND,
  30.     TOKEN_OR,
  31.     TOKEN_CARET,
  32.     TOKEN_MOD,
  33.     TOKEN_LSHIFT,
  34.     TOKEN_RSHIFT,
  35.     TOKEN_NOT,
  36.     TOKEN_EQUAL,
  37.     TOKEN_LESSTHAN,
  38.     TOKEN_GREATERTHAN,
  39.     TOKEN_LESSTHANOREQUAL,
  40.     TOKEN_GREATERTHANOREQUAL,
  41.     TOKEN_NOTEQUAL,
  42.     TOKEN_LOGICALNOT
  43. };
  44.  
  45. #define ERROR_RES_STR (129)
  46.  
  47. typedef enum
  48. {
  49.     kError = 0,        // used to signal warning or error
  50.     kWarning
  51. }ErrorType;
  52.  
  53. enum
  54. {
  55.     NOERR = 0,
  56.  
  57.     ERROR_SYNTAX,
  58.     ERROR_DIVZERO,
  59.     ERROR_MISBALPAREN,
  60.     ERROR_NOSUCHVAR,
  61.     ERROR_INVALVAR,
  62.     ERROR_MISSINGPARAM,
  63.     ERROR_MACRO,
  64.     ERROR_MACROPARAM,
  65.     ERROR_NOSUCHMACRO,
  66.     ERROR_MACROPARMSIZE,
  67.     ERROR_MACROPARMCOUNT,
  68.     ERROR_PREVDEFINED,
  69.     ERROR_TOOBIG,
  70.     ERROR_FILENOTFOUND,
  71.  
  72.     ERROR_FATAL,
  73.  
  74.     ERROR_HASHFULL = ERROR_FATAL,
  75.     ERROR_GROWCHUNK,
  76.     ERROR_MEMORY,
  77.     ERROR_TOOMANYERRORS,
  78.  
  79.     ERROR_EOL,
  80.     ERROR_EOF,
  81.  
  82.     ERROR_SAVING,    // generic message for filei/o failure
  83.  
  84.     FIRST_WARNING,
  85.  
  86.     WARNING_PREFS = FIRST_WARNING,
  87.     WARNING_RESPSEUDO,
  88.     WARNING_UNUSEDPARAM,
  89.  
  90.     ERROR_COUNT
  91. };
  92.  
  93. #define digit(x) ((x >= '0' && x <= '9' ) ? x- '0' : toupper(x) - '7' )
  94.  
  95. typedef unsigned char token;
  96.  
  97. struct VARIABLE
  98. {
  99.     char name[VARSIZE];
  100.     long value;
  101. };
  102.  
  103. // Prototypes
  104.  
  105. OSErr TokenizeExpression( token * * t , const char * * s );
  106.  
  107. void AddToken(token * * stream, token t);    /* add a token to the stream */
  108. OSErr AddConst(token * * stream, const char * * s );    /* add a constant */
  109. void AddWord ( token * * stream, long i );
  110. void AddLong ( token * * stream, long i );
  111.  
  112. long DecLong ( const char * * s );
  113. long HexLong ( const char * * s );
  114. long BinLong ( const char * * s );
  115. long ASCIILong ( const char * * s ,OSErr *error);
  116.  
  117. OSErr AddVar(token * * t, const char * * s );     /* add a varaible to the stream */
  118. void AddPtr(token * * t, long * p);
  119.  
  120. OSErr EvalExpression ( ULONG * lvalue , token ** p );
  121. OSErr EvalFactor ( ULONG * lvalue, token * * p );
  122. OSErr EvalNumber ( ULONG * lvalue, token * * p );
  123. OSErr EvalConst( ULONG * lvalue, token * * p );
  124. OSErr EvalVar( ULONG * lvalue, token * * p );
  125. OSErr DoExpr(Ptr *isPtr, ULONG *answer);
  126.  
  127. #endif
  128.