123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #ifndef _MON_LIB_LEX_H
- #define _MON_LIB_LEX_H
- #include <sys/cdefs.h>
- #include <stdio.h>
- #define LXT_BADTOKEN 0
- #define LXT_ACCEPT 1
- #define LXT_BEGIN 2
- #define LXT_CLOSE 3
- #define LXT_COLON 4
- #define LXT_COMMA 5
- #define LXT_CPU 6
- #define LXT_END 7
- #define LXT_IF 8
- #define LXT_IN 9
- #define LXT_IO 10
- #define LXT_MEM 11
- #define LXT_MONITOR 12
- #define LXT_MUX 13
- #define LXT_OPEN 14
- #define LXT_PF 15
- #define LXT_PORT 16
- #define LXT_SOURCE 17
- #define LXT_STREAM 18
- #define LXT_TO 19
- #define LXT_WRITE 20
- struct lex {
- char *buffer;
- const char *filename;
- FILE *fh;
- char *token;
- long value;
- int bsize;
- int cline;
- int curpos;
- int endpos;
- int op;
- int unget;
- int tokpos;
- enum { LXY_STRING, LXY_NUMBER, LXY_UNKNOWN }
- type;
- };
- __BEGIN_DECLS
- struct lex *open_lex(const char *);
- void close_lex(struct lex *);
- int lex_nexttoken(struct lex *);
- void lex_ungettoken(struct lex *);
- const char* parse_opcode(int);
- int parse_token(const char *);
- void parse_error(struct lex *, const char *);
- __END_DECLS
- #define EXPECT(l, x) do { \
- lex_nexttoken((l)); \
- if ((l)->op != (x)) { \
- parse_error((l), parse_opcode((x))); \
- return 0; \
- } \
- } while (0);
- #endif
|