teapot-spreadsheet/scanner.h

52 lines
990 B
C

#ifndef SCANNER_H
#define SCANNER_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
EMPTY
#ifndef __cplusplus
, STRING, FLOAT, INT, OPERATOR, LIDENT, FIDENT, LOCATION, EEK
#endif
} Type;
extern const char *Type_Name[];
typedef enum { PLUS, MINUS, MUL, DIV, OP, CP, COMMA, LT, LE, GE, GT, ISEQUAL, ABOUTEQ, NE, POW, MOD } Operator;
typedef struct
{
Type type;
union
{
char *string;
double flt;
long integer;
Operator op;
char *lident;
int fident;
int location[3];
char *err;
} u;
} Token;
#define NULLTOKEN ((Token*)0)
#define EMPTY_TVEC ((Token**)0)
int identcode(const char *s, size_t len);
Token **scan(const char **s);
size_t printtok(char* dest, size_t size, size_t field_width,
int quote_strings, int use_scientific,
int precision, int verbose_error, Token *tok);
void print(char *s, size_t size, size_t chars, int quote, int scientific, int precision, Token **n);
#ifdef __cplusplus
}
#endif
#endif