Infinity Calculator implementation for Assignment 2 in Computer Organization.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
501 B

#ifndef TOKH
#define TOKH
#include <stddef.h>
typedef int token_t;
#define TOK_NULL 0
#define TOK_ERR -1
#define TOK_NUMDEC 1
#define TOK_NUMHEX 2
#define TOK_NUMBIN 3
#define TOK_LPAREN 4
#define TOK_RPAREN 5
#define TOK_PLUS 6
#define TOK_MINUS 7
#define TOK_STAR 8
#define TOK_FSLASH 9
#define TOK_CARROT 10
extern const char *input_str, *token_str;
token_t tokenize();
#define ISDIGIT(c) (c >= '0' && c <= '9')
#define ISHEX(c) ((c & 0xDF) >= 'A' && (c & 0xDF) <= 'F') || ISDIGIT(c)
#endif