home *** CD-ROM | disk | FTP | other *** search
- /*
- * lex.h
- * Copyright © 1992 Niklas Röjemo
- */
-
- #ifndef _lex_h
- #define _lex_h
-
- #ifndef _global_h
- #include "global.h"
- #endif
-
- typedef enum {
- Op_lnot,Op_not,Op_neg,Op_none, /* unop */
- Op_mul,Op_div,Op_mod, /* 10 */
- Op_add,Op_sub, /* 9 */
- Op_and, /* 8 */
- Op_or, /* 7 */
- Op_xor, /* 6 */
- Op_asr,Op_sr,Op_sl,Op_ror,Op_rol, /* 5 */
- Op_le,Op_ge,Op_lt,Op_gt, /* 4 */
- Op_eq,Op_ne, /* 3 */
- Op_land, /* 2 */
- Op_lor /* 1 */
- } Operator;
-
- typedef enum { LexId, /* start with character */
- LexString, /* "jsgd" */
- LexInt, /* start with digit */
- LexFloat, /* start with digit contains dot */
- LexOperator,/* + - * % / >> >>> << */
- /* ~ & | ^ ! && || */
- /* == != <= >= */
- LexPosition,/* . representing current position */
- LexStorage, /* @ representing current storage counter */
- LexDelim, /* ()[]{}, */
- LexNone
- } LexTag;
-
-
- typedef union {
- LexTag tag; /* LexStorage LexDelim LexNone */
- struct {
- LexTag tag;
- char *str;
- int len;
- int hash;
- } LexId;
- struct {
- LexTag tag;
- char *str;
- int len;
- } LexString;
- struct {
- LexTag tag;
- int value;
- } LexInt;
- struct {
- LexTag tag;
- FLOAT value;
- } LexFloat;
- struct {
- LexTag tag;
- Operator op;
- int pri;
- } LexOperator;
- struct {
- LexTag tag;
- char delim;
- } LexDelim;
- } Lex;
-
- Lex lexGetId(void);
- Lex lexGetPrim(void);
- Lex lexGetBinop(void);
- int lexNextPri(void);
-
- #endif
-