llex.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. ** $Id: llex.h,v 1.8 1998/05/27 13:03:40 roberto Exp roberto $
  3. ** Lexical Analizer
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef llex_h
  7. #define llex_h
  8. #include "lobject.h"
  9. #include "lzio.h"
  10. #define FIRST_RESERVED 260
  11. /* maximum length of a reserved word (+1 for terminal 0) */
  12. #define TOKEN_LEN 15
  13. enum RESERVED {
  14. /* terminal symbols denoted by reserved words */
  15. AND = FIRST_RESERVED,
  16. DO, ELSE, ELSEIF, END, FUNCTION, IF, LOCAL, NIL, NOT, OR,
  17. REPEAT, RETURN, THEN, UNTIL, WHILE,
  18. /* other terminal symbols */
  19. NAME, CONC, DOTS, EQ, GE, LE, NE, NUMBER, STRING, EOS};
  20. #define MAX_IFS 5
  21. /* "ifstate" keeps the state of each nested $if the lexical is dealing with. */
  22. struct ifState {
  23. int elsepart; /* true if its in the $else part */
  24. int condition; /* true if $if condition is true */
  25. int skip; /* true if part must be skipped */
  26. };
  27. typedef struct LexState {
  28. int current; /* look ahead character */
  29. int token; /* look ahead token */
  30. struct FuncState *fs; /* 'FuncState' is private for the parser */
  31. union {
  32. real r;
  33. TaggedString *ts;
  34. } seminfo; /* semantics information */
  35. struct zio *lex_z; /* input stream */
  36. int linenumber; /* input line counter */
  37. int iflevel; /* level of nested $if's (for lexical analysis) */
  38. struct ifState ifstate[MAX_IFS];
  39. } LexState;
  40. void luaX_init (void);
  41. void luaX_setinput (LexState *LS, ZIO *z);
  42. int luaX_lex (LexState *LS);
  43. void luaX_syntaxerror (LexState *ls, char *s, char *token);
  44. void luaX_error (LexState *ls, char *s);
  45. void luaX_token2str (LexState *ls, int token, char *s);
  46. #endif