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

parse.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.
00003 
00004   Permission to use, copy, distribute and modify this software and   
00005   its documentation for any purpose is hereby granted without fee,        
00006   provided that the above copyright notice appear in all copies and that 
00007   both that copyright notice and this permission notice appear in 
00008   supporting documentation.
00009 
00010   Shigeru Chiba makes no representations about the suitability of this 
00011   software for any purpose.  It is provided "as is" without express or
00012   implied warranty.
00013 */
00014 
00015 #ifndef _parse_h
00016 #define _parse_h
00017 
00018 #include "types.h"
00019 
00020 class Lex;
00021 class Token;
00022 class Environment;
00023 class Ptree;
00024 class Encoding;
00025 
00026 /*
00027   Naming conventions for member functions
00028 
00029   r<name>:   grammar rule (terminal or non-terminal)
00030   opt<name>: optional terminal/non-termianl symbol
00031   is<name>:  is the following symbol <name>?
00032 */
00033 
00034 class Parser : public Object {
00035 public:
00036     Parser(Lex*);
00037     bool ErrorMessage(const char*, Ptree* = nil, Ptree* = nil);
00038     void WarningMessage(const char*, Ptree* = nil, Ptree* = nil);
00039     int NumOfErrors() { return nerrors; }
00040     uint LineNumber(char* pos, char*& fname, int& fname_len);
00041 
00042     bool rProgram(Ptree*&);
00043 
00044 protected:
00045     enum DeclKind { kDeclarator, kArgDeclarator, kCastDeclarator };
00046     enum TemplateDeclKind { tdk_unknown, tdk_decl, tdk_instantiation, 
00047                             tdk_specialization, num_tdks };
00048 
00049     bool SyntaxError();
00050     void ShowMessageHead(char*);
00051 
00052     bool rDefinition(Ptree*&);
00053     bool rNullDeclaration(Ptree*&);
00054     bool rTypedef(Ptree*&);
00055     bool rTypeSpecifier(Ptree*&, bool, Encoding&);
00056     bool isTypeSpecifier();
00057     bool rMetaclassDecl(Ptree*&);
00058     bool rMetaArguments(Ptree*&);
00059     bool rLinkageSpec(Ptree*&);
00060     bool rNamespaceSpec(Ptree*&);
00061     bool rUsing(Ptree*&);
00062     bool rLinkageBody(Ptree*&);
00063     bool rTemplateDecl(Ptree*&);
00064     bool rTemplateDecl2(Ptree*&, TemplateDeclKind &kind);
00065     bool rTempArgList(Ptree*&);
00066     bool rTempArgDeclaration(Ptree*&);
00067     bool rExternTemplateDecl(Ptree*&);
00068 
00069     bool rDeclaration(Ptree*&);
00070     bool rIntegralDeclaration(Ptree*&, Encoding&, Ptree*, Ptree*, Ptree*);
00071     bool rConstDeclaration(Ptree*&, Encoding&, Ptree*, Ptree*);
00072     bool rOtherDeclaration(Ptree*&, Encoding&, Ptree*, Ptree*, Ptree*);
00073 
00074     bool isConstructorDecl();
00075     bool isPtrToMember(int);
00076     bool optMemberSpec(Ptree*&);
00077     bool optStorageSpec(Ptree*&);
00078     bool optCvQualify(Ptree*&);
00079     bool optIntegralTypeOrClassSpec(Ptree*&, Encoding&);
00080     bool rConstructorDecl(Ptree*&, Encoding&);
00081     bool optThrowDecl(Ptree*&);
00082 
00083     bool rDeclarators(Ptree*&, Encoding&, bool, bool = FALSE);
00084     bool rDeclaratorWithInit(Ptree*&, Encoding&, bool, bool);
00085     bool rDeclarator(Ptree*&, DeclKind, bool, Encoding&, Encoding&, bool,
00086                      bool = FALSE);
00087     bool rDeclarator2(Ptree*&, DeclKind, bool, Encoding&, Encoding&, bool,
00088                       bool, Ptree**);
00089     bool optPtrOperator(Ptree*&, Encoding&);
00090     bool rMemberInitializers(Ptree*&);
00091     bool rMemberInit(Ptree*&);
00092 
00093     bool rName(Ptree*&, Encoding&);
00094     bool rOperatorName(Ptree*&, Encoding&);
00095     bool rCastOperatorName(Ptree*&, Encoding&);
00096     bool rPtrToMember(Ptree*&, Encoding&);
00097     bool rTemplateArgs(Ptree*&, Encoding&);
00098 
00099     bool rArgDeclListOrInit(Ptree*&, bool&, Encoding&, bool);
00100     bool rArgDeclList(Ptree*&, Encoding&);
00101     bool rArgDeclaration(Ptree*&, Encoding&);
00102 
00103     bool rFunctionArguments(Ptree*&);
00104     bool rInitializeExpr(Ptree*&);
00105 
00106     bool rEnumSpec(Ptree*&, Encoding&);
00107     bool rEnumBody(Ptree*&);
00108     bool rClassSpec(Ptree*&, Encoding&);
00109     bool rBaseSpecifiers(Ptree*&);
00110     bool rClassBody(Ptree*&);
00111     bool rClassMember(Ptree*&);
00112     bool rAccessDecl(Ptree*&);
00113     bool rUserAccessSpec(Ptree*&);
00114 
00115     bool rCommaExpression(Ptree*&);
00116 
00117     bool rExpression(Ptree*&);
00118     bool rConditionalExpr(Ptree*&);
00119     bool rLogicalOrExpr(Ptree*&, bool);
00120     bool rLogicalAndExpr(Ptree*&, bool);
00121     bool rInclusiveOrExpr(Ptree*&, bool);
00122     bool rExclusiveOrExpr(Ptree*&, bool);
00123     bool rAndExpr(Ptree*&, bool);
00124     bool rEqualityExpr(Ptree*&, bool);
00125     bool rRelationalExpr(Ptree*&, bool);
00126     bool rShiftExpr(Ptree*&);
00127     bool rAdditiveExpr(Ptree*&);
00128     bool rMultiplyExpr(Ptree*&);
00129     bool rPmExpr(Ptree*&);
00130     bool rCastExpr(Ptree*&);
00131     bool rTypeName(Ptree*&);
00132     bool rTypeName(Ptree*&, Encoding&);
00133     bool rUnaryExpr(Ptree*&);
00134     bool rThrowExpr(Ptree*&);
00135     bool rSizeofExpr(Ptree*&);
00136     bool isAllocateExpr(int);
00137     bool rAllocateExpr(Ptree*&);
00138     bool rUserdefKeyword(Ptree*&);
00139     bool rAllocateType(Ptree*&);
00140     bool rNewDeclarator(Ptree*&, Encoding&);
00141     bool rAllocateInitializer(Ptree*&);
00142     bool rPostfixExpr(Ptree*&);
00143     bool rPrimaryExpr(Ptree*&);
00144     bool rUserdefStatement(Ptree*&);
00145     bool rVarName(Ptree*&);
00146     bool rVarNameCore(Ptree*&, Encoding&);
00147     bool isTemplateArgs();
00148 
00149     bool rFunctionBody(Ptree*&);
00150     bool rCompoundStatement(Ptree*&);
00151     bool rStatement(Ptree*&);
00152     bool rIfStatement(Ptree*&);
00153     bool rSwitchStatement(Ptree*&);
00154     bool rWhileStatement(Ptree*&);
00155     bool rDoStatement(Ptree*&);
00156     bool rForStatement(Ptree*&);
00157     bool rTryStatement(Ptree*&);
00158 
00159     bool rExprStatement(Ptree*&);
00160     bool rDeclarationStatement(Ptree*&);
00161     bool rIntegralDeclStatement(Ptree*&, Encoding&, Ptree*, Ptree*, Ptree*);
00162     bool rOtherDeclStatement(Ptree*&, Encoding&, Ptree*, Ptree*);
00163 
00164     bool MaybeTypeNameOrClassTemplate(Token&);
00165     void SkipTo(int token);
00166 
00167 private:
00168     bool moreVarName();
00169 
00170 private:
00171     Lex* lex;
00172     int nerrors;
00173 };
00174 
00175 #endif /* _parse_h */

Generated on Mon Feb 10 17:32:54 2003 for VFiasco Semantics Compiler by doxygen1.2.15