Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

tools/SFlexLexer.h

Go to the documentation of this file.
00001 /* #start# ***********************************************************
00002 
00003                              Scheduling Simulator
00004                     Lehrstuhl f"ur Effiziente Algorithmen
00005                        Technische Universit"at M"unchen
00006 
00007  File    : $Id: SFlexLexer.h,v 1.2 2002/11/07 12:05:23 taeubig Exp $
00008 
00009  Purpose : SFlexLexer capsulates one lexical analyzer, which all modifiers 
00010            can use to load() from file. The logical analyzer is defined by 
00011            'lexan.l', the input file for flex (Fast Lexical Analyzer 
00012            Generator). There is only one instance of SFlexLexer for all 
00013            modifiers SFooMod. With SFooMod::getLexer()  the modifiers 
00014            can get full access to the underlying lexer. The lexer returns
00015            tokens for parsing the content of a file.
00016 
00017  RCS-Log:
00018  $Log: SFlexLexer.h,v $
00019  Revision 1.2  2002/11/07 12:05:23  taeubig
00020  Added standard namespace (std::)
00021 
00022  Revision 1.1  2002/08/29 12:59:59  taeubig
00023  Added the sources
00024 
00025  Revision 1.13  2000/05/24 12:53:42  taeubig
00026  New compiler (gcc-2.95) and new Qt (2.1)
00027  Replaced "list" by "leda_list" etc.
00028 
00029  Revision 1.12  2000/01/12 11:31:31  zoidl
00030  added javadoc comments and cosmetic changes in getDescription
00031 
00032  Revision 1.11  2000/01/11 17:26:17  zoidl
00033  added javadoc comments
00034 
00035  Revision 1.10  1999/12/02 00:22:10  zoidl
00036  added readIdentifier() and readToken() to simplify loading
00037 
00038  Revision 1.9  1999/11/23 19:49:58  zoidl
00039  added support for round brackets and semicolon
00040 
00041  Revision 1.8  1999/11/10 15:06:52  zoidl
00042  added parseLong()
00043 
00044  Revision 1.7  1999/11/08 00:23:31  zoidl
00045  workaround: lex doesn't reset line number on switch_stream, do it myself
00046  now
00047 
00048  Revision 1.6  1999/11/05 14:24:14  zoidl
00049  even more flexibility in loading double values
00050 
00051  Revision 1.5  1999/11/04 22:19:36  zoidl
00052  loading jobs more flexible
00053 
00054  Revision 1.4  1999/10/29 11:17:05  schickin
00055  example for new SFlexLexer-design added
00056 
00057  Revision 1.3  1999/10/14 14:32:42  zoidl
00058  nc
00059 
00060  Revision 1.2  1999/10/06 13:42:09  zoidl
00061  changed error handling
00062 
00063  Revision 1.1  1999/09/28 16:50:57  zoidl
00064  lexical analyzer for future load-routines added
00065 
00066 
00067  * #end# ************************************************************* */
00068 
00069 #ifndef SFLEXLEXER_H
00070 #define SFLEXLEXER_H
00071 
00072 #include <FlexLexer.h>
00073 #include <LEDA/string.h>
00074 
00083 // defined them globally because lexan.l must access them, too
00084 enum SFlexLexerToken {QUOTES=100, EQUAL, CRVDBRKT_OPEN, CRVDBRKT_CLOSE,
00085                       SQRBRKT_OPEN, SQRBRKT_CLOSE, RNDBRKT_OPEN,
00086                       RNDBRKT_CLOSE, COLON, SEMICOLON, COMMA, ULONG, 
00087                       DOUBLE, LONG, BOOL, STRING, IDENTIFIER, UNKNOWN};
00088 
00089 //  had to define it, because flex seems not to able to set the line number
00090 //  to 1, if the input-stream is switched (perhaps a bug in flex ?)
00091 extern int _myLineNo; // defined in lexan.h
00092 
00093 
00102 class SFlexLexer : public yyFlexLexer
00103 {
00104  public:
00109   SFlexLexer(std::istream *in);
00110 
00113   ~SFlexLexer();
00114 
00120   void errMsg(const char* msg);
00121   
00126   SFlexLexerToken getToken();
00127 
00133   virtual int lineno() const
00134     { return _myLineNo; };
00135 
00141   void ungetToken()
00142     { _unGet = true; };
00143   
00148   bool parseDouble();
00149   
00154   bool parseLong();
00155   
00161   void setErrorCaption(char* cap)
00162     { _caption = leda_string(cap); };
00163 
00171   bool readIdentifier(const char* ident);
00172 
00179   bool readToken(const SFlexLexerToken token);
00180 
00181  private:
00183   SFlexLexerToken _currTok;
00184   // if true, next time the current token will be returned
00185   bool _unGet;
00186   FlexLexer* _pLex;
00187   leda_string _caption;
00188 };
00189 
00190 #endif

Generated on Thu May 22 16:48:09 2003 for Sketch-it! by doxygen1.2.18