toker.h 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. The Toker converts an inout stream into tokens for use by the parser.
  3. */
  4. #ifndef TOKER_H
  5. #define TOKER_H
  6. enum{
  7. DIM=0x8000,GOTO,GOSUB,EXIT,RETURN,
  8. IF,THEN,ELSE,ENDIF,ELSEIF,
  9. WHILE,WEND,
  10. FOR,TO,STEP,NEXT,
  11. FUNCTION,ENDFUNCTION,
  12. TYPE,ENDTYPE,EACH,
  13. GLOBAL,LOCAL,FIELD,BBCONST,
  14. SELECT,CASE,DEFAULT,ENDSELECT,
  15. REPEAT,UNTIL,FOREVER,
  16. DATA,READ,RESTORE,
  17. ABS,SGN,MOD,
  18. PI,BBTRUE,BBFALSE,
  19. BBINT,BBFLOAT,BBSTR,
  20. INCLUDE,
  21. BBNEW,BBDELETE,FIRST,LAST,INSERT,BEFORE,AFTER,BBNULL,
  22. OBJECT,BBHANDLE,
  23. AND,OR,XOR,NOT,SHL,SHR,SAR,
  24. LE,GE,NE,
  25. IDENT,INTCONST,BINCONST,HEXCONST,FLOATCONST,STRINGCONST
  26. };
  27. class Toker{
  28. public:
  29. Toker( istream &in );
  30. int pos();
  31. int curr();
  32. int next();
  33. string text();
  34. int lookAhead( int n );
  35. static int chars_toked;
  36. static map<string,int> &getKeywords();
  37. private:
  38. struct Toke{
  39. int n,from,to;
  40. Toke( int n,int f,int t ):n(n),from(f),to(t){}
  41. };
  42. istream &in;
  43. string line;
  44. vector<Toke> tokes;
  45. void nextline();
  46. int curr_row,curr_toke;
  47. };
  48. #endif