00001 #include "SIGEL_RobotIO/SIG_Scanner.h" 00002 #include <stdio.h> 00003 00004 namespace SIGEL_RobotIO { 00005 namespace Symbol { 00006 int const None = -1; 00007 int const EOS = -2; 00008 } 00009 00010 SIG_Scanner::SIG_Scanner (QString liesdas) 00011 : text (liesdas), 00012 position (0), 00013 lineposition (1), 00014 currentSymType (Symbol::None) 00015 { } 00016 00017 SIG_Scanner::~SIG_Scanner (void) 00018 { } 00019 00020 void SIG_Scanner::skipWhiteSpace (void) 00021 { 00022 bool commentdetected; 00023 do { 00024 while ((position < text.length ()) && 00025 (text [position].isSpace ())) { 00026 if (text [position] == '\n') 00027 lineposition++; 00028 position++; 00029 } 00030 if ((position < text.length ()) && 00031 (text [position] == '#')) { 00032 commentdetected = true; 00033 while ((position < text.length ()) && 00034 (text [position] != '\n')) 00035 position++; 00036 } else 00037 commentdetected = false; 00038 } while (commentdetected); 00039 } 00040 00041 void SIG_Scanner::peekSymbol (int & symType, QString & symbol) 00042 { 00043 symType = currentSymType; 00044 symbol = currentSymbol; 00045 } 00046 00047 void SIG_Scanner::readSymbol (int & symType, QString & symbol) 00048 { 00049 peekSymbol (symType, symbol); 00050 nextSymbol (); 00051 } 00052 00053 int SIG_Scanner::currentLine (void) const 00054 { 00055 return lineposition; 00056 } 00057 }