/*
* CPreParser: P a r s e r H e a d e r
*
* Generated from: cpre.g
*
* Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-1995
* Parr Research Corporation
* with Purdue University Electrical Engineering
* with AHPCRC, University of Minnesota
* ANTLR Version 1.33j
*/
#ifndef CPreParser_h
#define CPreParser_h
#ifdef _MSC_VER
// Disable some warnings that appear commonly in Rogue Wave STL
#pragma warning (disable:4786) // long debug names
#pragma warning (disable:4146) // unary minus operator applied to unsigned type
#pragma warning (disable:4018) // '>' : signed/unsigned mismatch
#endif
#include "tokens.h"
#include "FastToken.h"
#include "ATokPtr.h"
#include "JLStr.h"
class TokenList;
#include "AParser.h"
class CPreParser : public ANTLRParser {
public:
enum ANTLRConstants { ConstLLK = 1 };
protected:
static const ANTLRChar * const _token_tbl[];
public:
static const ANTLRChar* const * GetTokenTable() { return _token_tbl; }
private:
public:
// need virtual dtor in case parser destroyed by ptr to base
virtual void init();
virtual ~CPreParser();
// notification of include EOF from external buffer object
virtual void OnIncludeEof() = 0;
// Preprocessor options
enum Option {
OptMSExtensions, // emit MS-extension tokens; otherwise they are IDs
OptBool, // emit bool,true,false tokens; otherwise they are IDs
OptWCharT, // emit wchar_t as a TOK_WCHAR_T token; otherwise it is an TOK_ID
OptPragmas, // send #pragma lines on to the C++ parser
OptExpandPragmas, // expand #pragma token list
OptTrackInclude, // track include stack on stdout
OptTypename, // emit 'typename' as TOK_TYPENAME, otherwise TOK_ID
OptMax // always last -- for error checking
};
protected:
//
// Set/Get preprocessor options
//
virtual void SetOption(Option option, bool value) = 0;
virtual bool GetOption(Option option) const = 0;
//
// Token lists for collecting tokens and identifiers
//
TokenList* tempTokenList;
TokenList* tempIdentifierList;
virtual void ClearTokenList(TokenList* tokenList) = 0;
virtual void AppendToTokenList(TokenList* tokenList, const ANTLRTokenPtr& tokPtr) = 0;
//
// Symbol table management
//
// Implicitly uses tempTokenList
virtual void EnterSimpleMacro(const ANTLRTokenPtr& name) = 0;
// Implicitly uses tempIdentifierList and tempTokenList
virtual void EnterFunctionMacro(const ANTLRTokenPtr& name) = 0;
virtual void UndefineMacro(const ANTLRTokenPtr& name) = 0;
virtual bool MacroIsDefined(const ANTLRTokenPtr& name) = 0;
virtual bool IsFunctionLikeMacro(const ANTLRTokenPtr& name) = 0;
//
// #if block tracking.
//
virtual void EnterIfBlock(bool isTrue, const ANTLRTokenPtr& token) = 0;
virtual void EnterElifBlock(bool isTrue, const ANTLRTokenPtr& token) = 0;
virtual void EnterElseBlock(const ANTLRTokenPtr& token) = 0;
virtual void ExitIfBlock(const ANTLRTokenPtr& token) = 0;
virtual bool IfBlockTrue() const = 0;
virtual bool EnclosingIfBlockTrue() const = 0;
//
// Evaluates the expression represented by tempTokenList
virtual bool EvaluateExpression() = 0;
//
// File inclusion
virtual void IncludeFile(const ANTLRTokenPtr& includeToken) = 0;
// Methods for errors detected in code
virtual void HandlePndError() = 0;
virtual void HandleError(const JLStr& msg, const ANTLRTokenPtr& token) = 0;
virtual void FatalError(const JLStr& msg) = 0;
// Always call this method to output tokens
// This method checks the token for type-conversion (bool, wchar_t, etc).
virtual void OutputTokenBase(ANTLRTokenPtr& tokPtr) const = 0;
// Output of tokens -- override these methods for physical token output
virtual void ExpandAndOutputTokenList(TokenList *list) = 0;
virtual void OutputTokenList(const TokenList *list) const = 0;
virtual void OutputToken(const ANTLRTokenPtr& tokPtr) const = 0;
// pragma processing
virtual void HandlePragma() = 0;
static SetWordType err1[24];
static SetWordType err2[24];
static SetWordType err3[24];
static SetWordType LEGAL_MACRO_NAMES_set[24];
static SetWordType err5[24];
static SetWordType err6[24];
static SetWordType setwd1[181];
static SetWordType PND_NEWLINE_set[24];
static SetWordType err8[24];
static SetWordType setwd2[181];
static SetWordType LRPAREN_DIRECTIVE_SLCOMMENT_NEWLINE_set[24];
static SetWordType SLCOMMENT_NEWLINE_set[24];
static SetWordType err11[24];
static SetWordType setwd3[181];
private:
void zzdflthandlers( int _signal, int *_retsignal );
public:
CPreParser(ANTLRTokenBuffer *input);
void preprocessing_file(void);
bool preprocessing_chunk(void);
void group(void);
void group_part(void);
void pp_line(void);
void if_line(void);
void ifdef_line(void);
void ifndef_line(void);
void elif_line(void);
void else_line(void);
void endif_line(void);
void control_line(void);
void include_line(void);
void define_line(void);
void function_macro_definition(void);
void id_macro_definition(void);
void undef_line(void);
void line_line(void);
void error_line(void);
void pragma_line(void);
void identifier_list( bool collecting );
void token_list_for_ppline( bool collecting );
void parenthesized_token_list(void);
void token_list_no_rparen(void);
void token_list( bool collecting );
static SetWordType RPAREN_NEWLINE_set[24];
static SetWordType LPAREN_RPAREN_set[24];
static SetWordType GREATERTHAN_NEWLINE_set[24];
static SetWordType MSEXT_TOKEN_CLASS_set[24];
};
#endif /* CPreParser_h */