scanner.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Kamil Dudka <xdudka00@stud.fit.vutbr.cz>
00003  *
00004  * This file is part of rob08
00005  *
00006  * rob08 is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * any later version.
00010  *
00011  * rob08 is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with rob08.  If not, see <http://www.gnu.org/licenses/>.
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 /* SCANNER_H */

Generated on Fri Jul 10 22:42:01 2009 for rob08 by  doxygen 1.5.4