Modules |
Files |
Inheritance Tree |
Inheritance Graph |
Name Index |
Config
File: Synopsis/Parser/C++/occ/parse.h
1| /*
2| Copyright (C) 1997-2000 Shigeru Chiba, University of Tsukuba.
3|
4| Permission to use, copy, distribute and modify this software and
5| its documentation for any purpose is hereby granted without fee,
6| provided that the above copyright notice appear in all copies and that
7| both that copyright notice and this permission notice appear in
8| supporting documentation.
9|
10| Shigeru Chiba makes no representations about the suitability of this
11| software for any purpose. It is provided "as is" without express or
12| implied warranty.
13| */
14|
15| #ifndef _parse_h
16| #define _parse_h
17|
18| #include "types.h"
19|
20| class Lex;
21| class Token;
22| class Environment;
23| class Ptree;
24| class Encoding;
25|
26|
27|
28|
29|
30|
31|
32|
33|
34| class Parser : public Object {
35| public:
36| Parser(Lex*);
37| bool ErrorMessage(const char*, Ptree* = nil, Ptree* = nil);
38| void WarningMessage(const char*, Ptree* = nil, Ptree* = nil);
39| int NumOfErrors() { return nerrors; }
40| uint LineNumber(char* pos, char*& fname, int& fname_len);
41|
42| bool rProgram(Ptree*&);
43|
44| protected:
45| enum DeclKind { kDeclarator, kArgDeclarator, kCastDeclarator };
46| enum TemplateDeclKind { tdk_unknown, tdk_decl, tdk_instantiation,
47| tdk_specialization, num_tdks };
48|
49| bool SyntaxError();
50| void ShowMessageHead(char*);
51|
52| bool rDefinition(Ptree*&);
53| bool rNullDeclaration(Ptree*&);
54| bool rTypedef(Ptree*&);
55| bool rTypeSpecifier(Ptree*&, bool, Encoding&);
56| bool isTypeSpecifier();
57| bool rMetaclassDecl(Ptree*&);
58| bool rMetaArguments(Ptree*&);
59| bool rLinkageSpec(Ptree*&);
60| bool rNamespaceSpec(Ptree*&);
61| bool rUsing(Ptree*&);
62| bool rLinkageBody(Ptree*&);
63| bool rTemplateDecl(Ptree*&);
64| bool rTemplateDecl2(Ptree*&, TemplateDeclKind &kind);
65| bool rTempArgList(Ptree*&);
66| bool rTempArgDeclaration(Ptree*&);
67| bool rExternTemplateDecl(Ptree*&);
68|
69| bool rDeclaration(Ptree*&);
70| bool rIntegralDeclaration(Ptree*&, Encoding&, Ptree*, Ptree*, Ptree*);
71| bool rConstDeclaration(Ptree*&, Encoding&, Ptree*, Ptree*);
72| bool rOtherDeclaration(Ptree*&, Encoding&, Ptree*, Ptree*, Ptree*);
73|
74| bool isConstructorDecl();
75| bool isPtrToMember(int);
76| bool optMemberSpec(Ptree*&);
77| bool optStorageSpec(Ptree*&);
78| bool optCvQualify(Ptree*&);
79| bool optIntegralTypeOrClassSpec(Ptree*&, Encoding&);
80| bool rConstructorDecl(Ptree*&, Encoding&);
81| bool optThrowDecl(Ptree*&);
82|
83| bool rDeclarators(Ptree*&, Encoding&, bool, bool = FALSE);
84| bool rDeclaratorWithInit(Ptree*&, Encoding&, bool, bool);
85| bool rDeclarator(Ptree*&, DeclKind, bool, Encoding&, Encoding&, bool,
86| bool = FALSE);
87| bool rDeclarator2(Ptree*&, DeclKind, bool, Encoding&, Encoding&, bool,
88| bool, Ptree**);
89| bool optPtrOperator(Ptree*&, Encoding&);
90| bool rMemberInitializers(Ptree*&);
91| bool rMemberInit(Ptree*&);
92|
93| bool rName(Ptree*&, Encoding&);
94| bool rOperatorName(Ptree*&, Encoding&);
95| bool rCastOperatorName(Ptree*&, Encoding&);
96| bool rPtrToMember(Ptree*&, Encoding&);
97| bool rTemplateArgs(Ptree*&, Encoding&);
98|
99| bool rArgDeclListOrInit(Ptree*&, bool&, Encoding&, bool);
100| bool rArgDeclList(Ptree*&, Encoding&);
101| bool rArgDeclaration(Ptree*&, Encoding&);
102|
103| bool rFunctionArguments(Ptree*&);
104| bool rInitializeExpr(Ptree*&);
105|
106| bool rEnumSpec(Ptree*&, Encoding&);
107| bool rEnumBody(Ptree*&);
108| bool rClassSpec(Ptree*&, Encoding&);
109| bool rBaseSpecifiers(Ptree*&);
110| bool rClassBody(Ptree*&);
111| bool rClassMember(Ptree*&);
112| bool rAccessDecl(Ptree*&);
113| bool rUserAccessSpec(Ptree*&);
114|
115| bool rCommaExpression(Ptree*&);
116|
117| bool rExpression(Ptree*&);
118| bool rConditionalExpr(Ptree*&);
119| bool rLogicalOrExpr(Ptree*&, bool);
120| bool rLogicalAndExpr(Ptree*&, bool);
121| bool rInclusiveOrExpr(Ptree*&, bool);
122| bool rExclusiveOrExpr(Ptree*&, bool);
123| bool rAndExpr(Ptree*&, bool);
124| bool rEqualityExpr(Ptree*&, bool);
125| bool rRelationalExpr(Ptree*&, bool);
126| bool rShiftExpr(Ptree*&);
127| bool rAdditiveExpr(Ptree*&);
128| bool rMultiplyExpr(Ptree*&);
129| bool rPmExpr(Ptree*&);
130| bool rCastExpr(Ptree*&);
131| bool rTypeName(Ptree*&);
132| bool rTypeName(Ptree*&, Encoding&);
133| bool rUnaryExpr(Ptree*&);
134| bool rThrowExpr(Ptree*&);
135| bool rSizeofExpr(Ptree*&);
136| bool rTypeidExpr(Ptree*&);
137| bool isAllocateExpr(int);
138| bool rAllocateExpr(Ptree*&);
139| bool rUserdefKeyword(Ptree*&);
140| bool rAllocateType(Ptree*&);
141| bool rNewDeclarator(Ptree*&, Encoding&);
142| bool rAllocateInitializer(Ptree*&);
143| bool rPostfixExpr(Ptree*&);
144| bool rPrimaryExpr(Ptree*&);
145| bool rUserdefStatement(Ptree*&);
146| bool rVarName(Ptree*&);
147| bool rVarNameCore(Ptree*&, Encoding&);
148| bool isTemplateArgs();
149|
150| bool rCondition(Ptree*&);
151|
152| bool rFunctionBody(Ptree*&);
153| bool rCompoundStatement(Ptree*&);
154| bool rStatement(Ptree*&);
155| bool rIfStatement(Ptree*&);
156| bool rSwitchStatement(Ptree*&);
157| bool rWhileStatement(Ptree*&);
158| bool rDoStatement(Ptree*&);
159| bool rForStatement(Ptree*&);
160| bool rTryStatement(Ptree*&);
161|
162| bool rExprStatement(Ptree*&);
163| bool rDeclarationStatement(Ptree*&);
164| bool rIntegralDeclStatement(Ptree*&, Encoding&, Ptree*, Ptree*, Ptree*);
165| bool rOtherDeclStatement(Ptree*&, Encoding&, Ptree*, Ptree*);
166|
167| bool MaybeTypeNameOrClassTemplate(Token&);
168| void SkipTo(int token);
169|
170| private:
171| bool moreVarName();
172|
173| private:
174| Lex* lex;
175| int nerrors;
176| Ptree* comments;
177| };
178|
179| #endif /* _parse_h */