CalcLexer.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/calculator/CalcLexer.h#2 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2009-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef Fennel_CalcLexer_Included
00024 #define Fennel_CalcLexer_Included
00025 
00026 #include "fennel/calculator/CalcCommon.h"
00027 #include "fennel/calculator/InstructionCommon.h"
00028 #include "fennel/calculator/CalcTypedefs.h"
00029 
00030 #ifdef DONOT_INCLUDE_FLEX_HEADER
00031 class CalcYYFlexLexer;
00032 #else
00033 #undef yyFlexLexer
00034 #define yyFlexLexer CalcYYFlexLexer
00035 #include <FlexLexer.h>
00036 #endif
00037 
00038 /*FENNEL_BEGIN_NAMESPACE*/
00039 
00040 using namespace fennel;
00041 
00049 /* NOTE: Objects with constructor/desctructor/copy not
00050  * allowed in union. */
00051 typedef union
00052 {
00053     double      v_double;
00054     int64_t     v_int64;
00055     uint64_t    v_uint64;
00056     TProgramCounter                 v_pc;
00057     StandardTypeDescriptorOrdinal   v_type;
00058     RegisterReference::ERegisterSet v_regset;
00059     RegisterReference*              p_regref;
00060     Instruction*                    p_inst;
00061 } CalcTokenUnion;
00062 
00071 typedef struct
00072 {
00074     CalcTokenUnion u;
00077     std::string    v_opcode;
00078     std::string    v_string;
00079     std::vector<RegisterReference*> v_register_list;
00080 } CalcTokenValue;
00081 
00083 
00089 class FENNEL_CALCULATOR_EXPORT CalcLexer
00090     : public CalcYYFlexLexer
00091 {
00092   public:
00093       explicit
00095       CalcLexer(): CalcYYFlexLexer(), yycolno(1), yylineno(1), yypos(0) {}
00096 
00099       int yylex();
00100 
00102       int getPosition() const       { return yypos;   }
00104       int getColumn() const         { return yycolno; }
00106       CalcYYLocType&  getLocation() { return yyloc;   }
00108       CalcTokenValue& getValue()    { return yylval;  }
00109 
00111       void LexerError(const char* msg);
00112 
00113   protected:
00117       void updateLocation();
00118 
00119       int hex(char ch);
00120       string hex2string(const char* buf, uint buflen);
00121 
00123       int yycolno;
00125       int yylineno;
00127       int yypos;
00129       CalcTokenValue yylval;
00131       CalcYYLocType  yyloc;
00132 };
00133 
00134 /*FENNEL_END_NAMESPACE */
00135 
00136 #endif
00137 
00138 // End CalcLexer

Generated on Mon Jun 22 04:00:17 2009 for Fennel by  doxygen 1.5.1