/* Copright 1992-1995 Joern Rennecke */ #ifndef LEX_H #define LEX_H #include "alloc.h" #ifndef LEXDEBUG #define LEXDEBUG YYDEBUG #endif #ifndef YYDEBUG #define YYDEBUG 0 #endif #define MBUF_SIZE 4096 #define MNAME_SIZE 256 #define I_TYPE_UNKNOWN 0 #define I_TYPE_LIMBO 1 #define I_TYPE_GLOBAL 2 /* function, variable AND efuns/simul_efuns */ #define I_TYPE_PARAM 3 #define I_TYPE_LOCAL 4 #define I_TYPE_RESWORD 5 #define I_TYPE_DEFINE 6 #define I_TYPE_DEFARG 7 /* * The expected newline character is '\n' . '\r' '\n' and '\n' \r' is * tolerated, but not recommended. * Some characters are set aside to encode tokens from macro expansion. * Their codes are selected so that they are in a range with '\0', * which marks the end of the mmapped file, and '\n' . In ASCII, which is the * expected character set, the only legal character that gets 'trapped' is * '\t'. In EBCDIC it should be pretty much the same unless you want to * turn on the card puncher while compiling LPC :-) */ /* LC is short for 'Lexical scanner Code */ #define LC_EOF '\0' #define LC_DEFARG '\1' /* ASCII SOH */ #define LC_IDENT '\2' /* ASCII STX */ #define LC_STRING '\3' #define LC_POP '\4' /* ASCII EOT */ #define LC_MAX_SPECIAL LC_POP #define LC_NL '\n' #define LC_MAX LC_NL struct expand_stack { /* argument text goes here */ /* argument pointers go here */ struct expand_stack *pop; char *ret; char **arg; }; struct defn { union { char *str; char *(*fun)(char *, char **, struct expand_stack *); struct token *tokens; /* negative indexing */ } exps; short nargs; char permanent; char special; }; struct s_reswords { char *name; int code; int32 value; }; struct ident { char *name; p_int namelen; short type; uint16 hash; struct ident *next; /* next in hash chain */ struct ident *inferior; union ident_u /* TRANSPARENT_UNION */ { struct ident_global { short function, variable, efun, sim_efun; } global; struct defn define; int defarg; struct { int code; uint32 value; } terminal; int param; struct { int16 offset; uint8 vtype; uint16 line; } local; } u; struct ident *next_all; }; #define NEW_IDENT(id, id_type, init) \ ((id)->type == I_TYPE_UNKNOWN ? \ ((id)->type = (id_type), id->u = (init), (id)) : \ ((id)->type != (id_type) ? \ new_ident((id), (id_type), (init)) : (id))) struct efun_shadow { struct ident *shadow; struct efun_shadow *next; }; struct idhash_ret { char *p; int32 hash; }; struct string_concat { char *start; struct string_concat *next; }; extern struct incstate *inctop; extern int pragma_strong_types; extern int current_line; extern svalue all_proto_closures; extern int yylex(); extern struct ident *make_shared_identifier(char *, mp_int, uint16, int); extern void free_shared_identifier(struct ident*); extern void commandline_define(char *); extern struct idhash_ret idhash(char *p); extern void lex_open(int, svalue); void store_include_info(svalue); void store_include_end(void); svalue concat_strings(char *str, mp_int length, struct string_concat *next); void lex_close(p_int); struct ident *new_ident(struct ident *, int, union ident_u); #endif /* LEX_H */