00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SCANNER_H
00021 #define SCANNER_H
00022
00023 #include "config.h"
00024
00025 #include "term.h"
00026
00027 #ifndef BUILDING_DOX
00028 # include <iostream>
00029 # include <string>
00030 # include <vector>
00031 #endif
00032
00036 enum EToken {
00037 ET_NULL = 0,
00038
00039 ET_GET_WHISKER_STATUS,
00040 ET_GET_COMPASS_HEADING,
00041 ET_GET_COMPASS_HEADING_EX,
00042 ET_GET_TEMP,
00043 ET_GET_WATER,
00044 ET_GET_PIR,
00045 ET_GET_SONAR,
00046 ET_GET_TILT,
00047 ET_GET_BATT_VOLTAGE,
00048 ET_GET_SW_VERSION,
00049 ET_GET_BUTTONS,
00050 ET_GET_LIGHT_LEVEL,
00051 ET_GET_SOUND_LEVEL,
00052 ET_GET_ENCODER_COUNTS,
00053 ET_CMD_PG,
00054 ET_CMD_PH,
00055 ET_CMD_PL,
00056 ET_CMD_PM,
00057 ET_CMD_PN,
00058 ET_CMD_PS,
00059 ET_CMD_PW
00060 };
00062 std::ostream& operator<<(std::ostream &, EToken);
00063
00067 struct Token {
00068 EToken type;
00069 int lineno;
00070 std::string text;
00071 typedef STD_VECTOR(unsigned) TArgVector;
00072 TArgVector args;
00073
00074 Token():
00075 type(ET_NULL),
00076 lineno(0)
00077 {
00078 }
00079 Token(EToken type_, int lineno_, const std::string &text_):
00080 type(type_),
00081 lineno(lineno_),
00082 text(text_)
00083 {
00084 }
00085 };
00087 std::ostream& operator<<(std::ostream &, const Token &);
00088
00092 class IScanner: public IErrorSensitive {
00093 public:
00094 virtual ~IScanner() { }
00100 virtual bool readNext(Token &token) = 0;
00101 };
00102
00106 class ScannerFactory {
00107 public:
00115 static IScanner* createScanner(ICharReader *reader, std::string fileName);
00116 private:
00117 ScannerFactory();
00118 };
00119
00120 #endif