]> granicus.if.org Git - clang/blob - include/clang/Parse/Action.h
add parsing, ast building and pretty printing support for C++ throw expressions.
[clang] / include / clang / Parse / Action.h
1 //===--- Action.h - Parser Action Interface ---------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file defines the Action and EmptyAction interface.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_PARSE_ACTION_H
15 #define LLVM_CLANG_PARSE_ACTION_H
16
17 #include "clang/Basic/IdentifierTable.h"
18 #include "clang/Basic/SourceLocation.h"
19 #include "clang/Basic/TokenKinds.h"
20
21 namespace clang {
22   // Semantic.
23   class DeclSpec;
24   class ObjCDeclSpec;
25   class Declarator;
26   class AttributeList;
27   // Parse.
28   class Scope;
29   class Action;
30   class Selector;
31   // Lex.
32   class Token;
33
34 /// Action - As the parser reads the input file and recognizes the productions
35 /// of the grammar, it invokes methods on this class to turn the parsed input
36 /// into something useful: e.g. a parse tree.
37 ///
38 /// The callback methods that this class provides are phrased as actions that
39 /// the parser has just done or is about to do when the method is called.  They
40 /// are not requests that the actions module do the specified action.
41 ///
42 /// All of the methods here are optional except isTypeName(), which must be
43 /// specified in order for the parse to complete accurately.  The EmptyAction
44 /// class does this bare-minimum of tracking to implement this functionality.
45 class Action {
46 public:
47   /// Out-of-line virtual destructor to provide home for this class.
48   virtual ~Action();
49   
50   // Types - Though these don't actually enforce strong typing, they document
51   // what types are required to be identical for the actions.
52   typedef void ExprTy;
53   typedef void StmtTy;
54   typedef void DeclTy;
55   typedef void TypeTy;
56   typedef void AttrTy;
57   
58   /// ActionResult - This structure is used while parsing/acting on expressions,
59   /// stmts, etc.  It encapsulates both the object returned by the action, plus
60   /// a sense of whether or not it is valid.
61   template<unsigned UID>
62   struct ActionResult {
63     void *Val;
64     bool isInvalid;
65     
66     ActionResult(bool Invalid = false) : Val(0), isInvalid(Invalid) {}
67     template<typename ActualExprTy>
68     ActionResult(ActualExprTy *val) : Val(val), isInvalid(false) {}
69     
70     const ActionResult &operator=(void *RHS) {
71       Val = RHS;
72       isInvalid = false;
73       return *this;
74     }
75   };
76
77   /// Expr/Stmt/TypeResult - Provide a unique type to wrap ExprTy/StmtTy/TypeTy,
78   /// providing strong typing and allowing for failure.
79   typedef ActionResult<0> ExprResult;
80   typedef ActionResult<1> StmtResult;
81   typedef ActionResult<2> TypeResult;
82   
83   /// Deletion callbacks - Since the parser doesn't know the concrete types of
84   /// the AST nodes being generated, it must do callbacks to delete objects when
85   /// recovering from errors.
86   virtual void DeleteExpr(ExprTy *E) {}
87   virtual void DeleteStmt(StmtTy *E) {}
88   
89   /// Statistics.
90   virtual void PrintStats() const {}
91   //===--------------------------------------------------------------------===//
92   // Declaration Tracking Callbacks.
93   //===--------------------------------------------------------------------===//
94   
95   /// isTypeName - Return non-null if the specified identifier is a typedef name
96   /// in the current scope.
97   virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const = 0;
98   
99   /// ActOnDeclarator - This callback is invoked when a declarator is parsed and
100   /// 'Init' specifies the initializer if any.  This is for things like:
101   /// "int X = 4" or "typedef int foo".
102   ///
103   /// LastInGroup is non-null for cases where one declspec has multiple
104   /// declarators on it.  For example in 'int A, B', ActOnDeclarator will be
105   /// called with LastInGroup=A when invoked for B.
106   virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,DeclTy *LastInGroup) {
107     return 0;
108   }
109
110   /// AddInitializerToDecl - This action is called immediately after 
111   /// ParseDeclarator (when an initializer is present). The code is factored 
112   /// this way to make sure we are able to handle the following:
113   ///   void func() { int xx = xx; }
114   /// This allows ActOnDeclarator to register "xx" prior to parsing the
115   /// initializer. The declaration above should still result in a warning, 
116   /// since the reference to "xx" is uninitialized.
117   virtual void AddInitializerToDecl(DeclTy *Dcl, ExprTy *Init) {
118     return;
119   }
120   /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this
121   /// gives the actions implementation a chance to process the group as a whole.
122   virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group) {
123     return Group;
124   }
125
126   /// ActOnStartOfFunctionDef - This is called at the start of a function
127   /// definition, instead of calling ActOnDeclarator.  The Declarator includes
128   /// information about formal arguments that are part of this function.
129   virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
130     // Default to ActOnDeclarator.
131     return ActOnDeclarator(FnBodyScope, D, 0);
132   }
133
134   virtual void ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
135     return;
136   }
137   
138   /// ActOnFunctionDefBody - This is called when a function body has completed
139   /// parsing.  Decl is the DeclTy returned by ParseStartOfFunctionDef.
140   virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body) {
141     return Decl;
142   }
143
144   virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *AsmString) {
145     return 0;
146   }
147   
148   /// ActOnPopScope - This callback is called immediately before the specified
149   /// scope is popped and deleted.
150   virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {}
151
152   /// ActOnTranslationUnitScope - This callback is called once, immediately
153   /// after creating the translation unit scope (in Parser::Initialize).
154   virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {}
155     
156   /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
157   /// no declarator (e.g. "struct foo;") is parsed.
158   virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
159     return 0;
160   }
161
162   virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
163                                    SourceLocation RBrace, const char *Lang,
164                                    unsigned StrSize, DeclTy *D) {
165     return 0;
166   }
167   
168   //===--------------------------------------------------------------------===//
169   // Type Parsing Callbacks.
170   //===--------------------------------------------------------------------===//
171   
172   virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
173     return 0;
174   }
175   
176   virtual TypeResult ActOnParamDeclaratorType(Scope *S, Declarator &D) {
177     return 0;
178   }
179   
180   enum TagKind {
181     TK_Reference,   // Reference to a tag:  'struct foo *X;'
182     TK_Declaration, // Fwd decl of a tag:   'struct foo;'
183     TK_Definition   // Definition of a tag: 'struct foo { int X; } Y;'
184   };
185   virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK,
186                            SourceLocation KWLoc, IdentifierInfo *Name,
187                            SourceLocation NameLoc, AttributeList *Attr) {
188     // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
189     // is (struct/union/enum/class).
190     return 0;
191   }
192   
193   virtual DeclTy *ActOnField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart,
194                              Declarator &D, ExprTy *BitfieldWidth) {
195     return 0;
196   }
197   virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl,
198                            DeclTy **Fields, unsigned NumFields, 
199                            SourceLocation LBrac, SourceLocation RBrac,
200                            tok::ObjCKeywordKind *visibility = 0) {}
201   virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
202                                     DeclTy *LastEnumConstant,
203                                     SourceLocation IdLoc, IdentifierInfo *Id,
204                                     SourceLocation EqualLoc, ExprTy *Val) {
205     return 0;
206   }
207   virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
208                              DeclTy **Elements, unsigned NumElements) {}
209
210   //===--------------------------------------------------------------------===//
211   // Statement Parsing Callbacks.
212   //===--------------------------------------------------------------------===//
213   
214   virtual StmtResult ActOnNullStmt(SourceLocation SemiLoc) {
215     return 0;
216   }
217   
218   virtual StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
219                                        StmtTy **Elts, unsigned NumElts,
220                                        bool isStmtExpr) {
221     return 0;
222   }
223   virtual StmtResult ActOnDeclStmt(DeclTy *Decl) {
224     return 0;
225   }
226   
227   virtual StmtResult ActOnExprStmt(ExprTy *Expr) {
228     return StmtResult(Expr);
229   }
230   
231   /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
232   /// which can specify an RHS value.
233   virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
234                                    SourceLocation DotDotDotLoc, ExprTy *RHSVal,
235                                    SourceLocation ColonLoc, StmtTy *SubStmt) {
236     return 0;
237   }
238   virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
239                                       SourceLocation ColonLoc, StmtTy *SubStmt,
240                                       Scope *CurScope){
241     return 0;
242   }
243   
244   virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
245                                     SourceLocation ColonLoc, StmtTy *SubStmt) {
246     return 0;
247   }
248   
249   virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
250                                  StmtTy *ThenVal, SourceLocation ElseLoc,
251                                  StmtTy *ElseVal) {
252     return 0; 
253   }
254   
255   virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond) {
256     return 0;
257   }
258   
259   virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
260                                            StmtTy *Switch, ExprTy *Body) {
261     return 0;
262   }
263
264   virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
265                                     StmtTy *Body) {
266     return 0;
267   }
268   virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
269                                  SourceLocation WhileLoc, ExprTy *Cond) {
270     return 0;
271   }
272   virtual StmtResult ActOnForStmt(SourceLocation ForLoc, 
273                                   SourceLocation LParenLoc, 
274                                   StmtTy *First, ExprTy *Second, ExprTy *Third,
275                                   SourceLocation RParenLoc, StmtTy *Body) {
276     return 0;
277   }
278   virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, 
279                                   SourceLocation LParenLoc, 
280                                   StmtTy *First, ExprTy *Second,
281                                   SourceLocation RParenLoc, StmtTy *Body) {
282     return 0;
283   }
284   virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
285                                    SourceLocation LabelLoc,
286                                    IdentifierInfo *LabelII) {
287     return 0;
288   }
289   virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
290                                            SourceLocation StarLoc,
291                                            ExprTy *DestExp) {
292     return 0;
293   }
294   virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
295                                        Scope *CurScope) {
296     return 0;
297   }
298   virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope) {
299     return 0;
300   }
301   virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
302                                      ExprTy *RetValExp) {
303     return 0;
304   }
305   virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
306                                   bool IsSimple,                                  
307                                   bool IsVolatile,
308                                   unsigned NumOutputs,
309                                   unsigned NumInputs,
310                                   std::string *Names,
311                                   ExprTy **Constraints,
312                                   ExprTy **Exprs,
313                                   ExprTy *AsmString,
314                                   unsigned NumClobbers,
315                                   ExprTy **Clobbers,
316                                   SourceLocation RParenLoc) {
317     return 0;
318   }
319   
320   // Objective-c statements
321   virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, 
322                                           SourceLocation RParen, StmtTy *Parm, 
323                                           StmtTy *Body, StmtTy *CatchList) {
324     return 0;
325   }
326   
327   virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, 
328                                             StmtTy *Body) {
329     return 0;
330   }
331   
332   virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, 
333                                         StmtTy *Try, 
334                                         StmtTy *Catch, StmtTy *Finally) {
335     return 0;
336   }
337   
338   virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, 
339                                           StmtTy *Throw) {
340     return 0;
341   }
342   
343   virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, 
344                                         ExprTy *SynchExpr, 
345                                         StmtTy *SynchBody) {
346     return 0;
347   }
348   
349   //===--------------------------------------------------------------------===//
350   // Expression Parsing Callbacks.
351   //===--------------------------------------------------------------------===//
352   
353   // Primary Expressions.
354   
355   /// ActOnIdentifierExpr - Parse an identifier in expression context.
356   /// 'HasTrailingLParen' indicates whether or not the identifier has a '('
357   /// token immediately after it.
358   virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
359                                          IdentifierInfo &II,
360                                          bool HasTrailingLParen) {
361     return 0;
362   }
363   
364   virtual ExprResult ActOnPreDefinedExpr(SourceLocation Loc,
365                                          tok::TokenKind Kind) {
366     return 0;
367   }
368   virtual ExprResult ActOnCharacterConstant(const Token &) { return 0; }
369   virtual ExprResult ActOnNumericConstant(const Token &) { return 0; }
370   
371   /// ActOnStringLiteral - The specified tokens were lexed as pasted string
372   /// fragments (e.g. "foo" "bar" L"baz").
373   virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks) {
374     return 0;
375   }
376   
377   virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
378                                     ExprTy *Val) {
379     return Val;  // Default impl returns operand.
380   }
381   
382   // Postfix Expressions.
383   virtual ExprResult ActOnPostfixUnaryOp(SourceLocation OpLoc, 
384                                          tok::TokenKind Kind, ExprTy *Input) {
385     return 0;
386   }
387   virtual ExprResult ActOnArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
388                                              ExprTy *Idx, SourceLocation RLoc) {
389     return 0;
390   }
391   virtual ExprResult ActOnMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
392                                               tok::TokenKind OpKind,
393                                               SourceLocation MemberLoc,
394                                               IdentifierInfo &Member) {
395     return 0;
396   }
397   
398   /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
399   /// This provides the location of the left/right parens and a list of comma
400   /// locations.  There are guaranteed to be one fewer commas than arguments,
401   /// unless there are zero arguments.
402   virtual ExprResult ActOnCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
403                                    ExprTy **Args, unsigned NumArgs,
404                                    SourceLocation *CommaLocs,
405                                    SourceLocation RParenLoc) {
406     return 0;
407   }
408   
409   // Unary Operators.  'Tok' is the token for the operator.
410   virtual ExprResult ActOnUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
411                                   ExprTy *Input) {
412     return 0;
413   }
414   virtual ExprResult 
415     ActOnSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof, 
416                                SourceLocation LParenLoc, TypeTy *Ty,
417                                SourceLocation RParenLoc) {
418     return 0;
419   }
420   
421   virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty,
422                                           SourceLocation RParen, ExprTy *Op) {
423     return 0;
424   }
425   virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
426                                    ExprTy **InitList, unsigned NumInit,
427                                    SourceLocation RParenLoc) {
428     return 0;
429   }
430   virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
431                                    SourceLocation RParenLoc, ExprTy *Op) {
432     return 0;
433   }
434   
435   virtual ExprResult ActOnBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
436                                 ExprTy *LHS, ExprTy *RHS) {
437     return 0;
438   }
439
440   /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
441   /// in the case of a the GNU conditional expr extension.
442   virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, 
443                                         SourceLocation ColonLoc,
444                                         ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){
445     return 0;
446   }
447   
448   //===---------------------- GNU Extension Expressions -------------------===//
449
450   virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
451                                     IdentifierInfo *LabelII) { // "&&foo"
452     return 0;
453   }
454   
455   virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
456                                    SourceLocation RPLoc) { // "({..})"
457     return 0;
458   }
459   
460   // __builtin_offsetof(type, identifier(.identifier|[expr])*)
461   struct OffsetOfComponent {
462     SourceLocation LocStart, LocEnd;
463     bool isBrackets;  // true if [expr], false if .ident
464     union {
465       IdentifierInfo *IdentInfo;
466       ExprTy *E;
467     } U;
468   };
469   
470   virtual ExprResult ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc,
471                                           SourceLocation TypeLoc, TypeTy *Arg1,
472                                           OffsetOfComponent *CompPtr,
473                                           unsigned NumComponents,
474                                           SourceLocation RParenLoc) {
475     return 0;
476   }
477   
478   // __builtin_types_compatible_p(type1, type2)
479   virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, 
480                                               TypeTy *arg1, TypeTy *arg2,
481                                               SourceLocation RPLoc) {
482     return 0;
483   }
484   // __builtin_choose_expr(constExpr, expr1, expr2)
485   virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, 
486                                      ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
487                                      SourceLocation RPLoc) {
488     return 0;
489   }
490   // __builtin_overload(...)
491   virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs,
492                                        SourceLocation *CommaLocs,
493                                        SourceLocation BuiltinLoc, 
494                                        SourceLocation RPLoc) {
495     return 0;
496   }
497   
498
499   // __builtin_va_arg(expr, type)
500   virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
501                                 ExprTy *expr, TypeTy *type,
502                                 SourceLocation RPLoc) {
503     return 0;
504   }
505   
506   //===------------------------- C++ Expressions --------------------------===//
507   
508   /// ActOnCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
509   virtual ExprResult ActOnCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
510                                    SourceLocation LAngleBracketLoc, TypeTy *Ty,
511                                    SourceLocation RAngleBracketLoc,
512                                    SourceLocation LParenLoc, ExprTy *Op,
513                                    SourceLocation RParenLoc) {
514     return 0;
515   }
516
517   /// ActOnCXXBoolLiteral - Parse {true,false} literals.
518   virtual ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
519                                          tok::TokenKind Kind) {
520     return 0;
521   }
522
523   /// ActOnCXXThrow - Parse throw expressions.
524   virtual ExprResult ActOnCXXThrow(SourceLocation OpLoc,
525                                    ExprTy *Op = 0) {
526     return 0;
527   }
528   //===----------------------- Obj-C Declarations -------------------------===//
529   
530   // ActOnStartClassInterface - this action is called immdiately after parsing
531   // the prologue for a class interface (before parsing the instance 
532   // variables). Instance variables are processed by ActOnFields().
533   virtual DeclTy *ActOnStartClassInterface(
534     SourceLocation AtInterafceLoc,
535     IdentifierInfo *ClassName, 
536     SourceLocation ClassLoc,
537     IdentifierInfo *SuperName, 
538     SourceLocation SuperLoc,
539     IdentifierInfo **ProtocolNames, 
540     unsigned NumProtocols,
541     SourceLocation EndProtoLoc,
542     AttributeList *AttrList) {
543     return 0;
544   }
545   
546   /// ActOnCompatiblityAlias - this action is called after complete parsing of
547   /// @compaatibility_alias declaration. It sets up the alias relationships.
548   virtual DeclTy *ActOnCompatiblityAlias(
549     SourceLocation AtCompatibilityAliasLoc,
550     IdentifierInfo *AliasName,  SourceLocation AliasLocation,
551     IdentifierInfo *ClassName, SourceLocation ClassLocation) {
552     return 0;
553   }
554   
555   // ActOnStartProtocolInterface - this action is called immdiately after
556   // parsing the prologue for a protocol interface.
557   virtual DeclTy *ActOnStartProtocolInterface(
558     SourceLocation AtProtoInterfaceLoc,
559     IdentifierInfo *ProtocolName, 
560     SourceLocation ProtocolLoc,
561     IdentifierInfo **ProtoRefNames, 
562     unsigned NumProtoRefs,
563     SourceLocation EndProtoLoc) {
564     return 0;
565   }
566   // ActOnStartCategoryInterface - this action is called immdiately after
567   // parsing the prologue for a category interface.
568   virtual DeclTy *ActOnStartCategoryInterface(
569     SourceLocation AtInterfaceLoc,
570     IdentifierInfo *ClassName, 
571     SourceLocation ClassLoc,
572     IdentifierInfo *CategoryName, 
573     SourceLocation CategoryLoc,
574     IdentifierInfo **ProtoRefNames, 
575     unsigned NumProtoRefs,
576     SourceLocation EndProtoLoc) {
577     return 0;
578   }
579   // ActOnStartClassImplementation - this action is called immdiately after
580   // parsing the prologue for a class implementation. Instance variables are 
581   // processed by ActOnFields().
582   virtual DeclTy *ActOnStartClassImplementation(
583     SourceLocation AtClassImplLoc,
584     IdentifierInfo *ClassName, 
585     SourceLocation ClassLoc,
586     IdentifierInfo *SuperClassname, 
587     SourceLocation SuperClassLoc) {
588     return 0;
589   }
590   // ActOnStartCategoryImplementation - this action is called immdiately after
591   // parsing the prologue for a category implementation.
592   virtual DeclTy *ActOnStartCategoryImplementation(
593     SourceLocation AtCatImplLoc,
594     IdentifierInfo *ClassName, 
595     SourceLocation ClassLoc,
596     IdentifierInfo *CatName,
597     SourceLocation CatLoc) {
598     return 0;
599   }  
600   // ActOnMethodDeclaration - called for all method declarations. 
601   virtual DeclTy *ActOnMethodDeclaration(
602     SourceLocation BeginLoc,   // location of the + or -.
603     SourceLocation EndLoc,     // location of the ; or {.
604     tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class.
605     DeclTy *ClassDecl,         // class this methods belongs to.
606     ObjCDeclSpec &ReturnQT,    // for return type's in inout etc.
607     TypeTy *ReturnType,        // the method return type.
608     Selector Sel,              // a unique name for the method.
609     ObjCDeclSpec *ArgQT,       // for arguments' in inout etc.
610     TypeTy **ArgTypes,         // non-zero when Sel.getNumArgs() > 0
611     IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0
612     AttributeList *AttrList,   // optional
613     // tok::objc_not_keyword, tok::objc_optional, tok::objc_required    
614     tok::ObjCKeywordKind impKind,
615     bool isVariadic = false) {
616     return 0;
617   }
618   // ActOnAtEnd - called to mark the @end. For declarations (interfaces,
619   // protocols, categories), the parser passes all methods/properties. 
620   // For class implementations, these values default to 0. For implementations,
621   // methods are processed incrementally (by ActOnMethodDeclaration above).
622   virtual void ActOnAtEnd(
623     SourceLocation AtEndLoc, 
624     DeclTy *classDecl,
625     DeclTy **allMethods = 0, 
626     unsigned allNum = 0,
627     DeclTy **allProperties = 0, 
628     unsigned pNum = 0) {
629     return;
630   }
631   // ActOnAddObjCProperties - called to build one property AST
632   virtual DeclTy *ActOnAddObjCProperties (SourceLocation AtLoc,
633     DeclTy **allProperties, unsigned NumProperties, ObjCDeclSpec &DS) {
634     return 0;
635   }
636                                      
637   // ActOnClassMessage - used for both unary and keyword messages.
638   // ArgExprs is optional - if it is present, the number of expressions
639   // is obtained from NumArgs.
640   virtual ExprResult ActOnClassMessage(
641     Scope *S,
642     IdentifierInfo *receivingClassName, 
643     Selector Sel,
644     SourceLocation lbrac, 
645     SourceLocation rbrac, 
646     ExprTy **ArgExprs, unsigned NumArgs) {
647     return 0;
648   }
649   // ActOnInstanceMessage - used for both unary and keyword messages.
650   // ArgExprs is optional - if it is present, the number of expressions
651   // is obtained from NumArgs.
652   virtual ExprResult ActOnInstanceMessage(
653     ExprTy *receiver, Selector Sel,
654     SourceLocation lbrac, SourceLocation rbrac, 
655     ExprTy **ArgExprs, unsigned NumArgs) {
656     return 0;
657   }
658   virtual DeclTy *ActOnForwardClassDeclaration(
659     SourceLocation AtClassLoc,
660     IdentifierInfo **IdentList,
661     unsigned NumElts) {
662     return 0;
663   }
664   virtual DeclTy *ActOnForwardProtocolDeclaration(
665     SourceLocation AtProtocolLoc,
666     IdentifierInfo **IdentList,
667     unsigned NumElts) {
668     return 0;
669   }
670   
671   /// FindProtocolDeclaration - This routine looks up protocols and
672   /// issues error if they are not declared. It returns list of valid
673   /// protocols found.
674   virtual void FindProtocolDeclaration(SourceLocation TypeLoc,
675                                        IdentifierInfo **ProtocolId,
676                                        unsigned NumProtocols,
677                                        llvm::SmallVector<DeclTy *, 8> &
678                                        Protocols) {
679   }
680                                                
681                                                
682   //===----------------------- Obj-C Expressions --------------------------===//
683
684   virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, 
685                                             ExprTy **Strings,
686                                             unsigned NumStrings) {
687     return 0;
688   }
689
690   virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
691                                                SourceLocation EncLoc,
692                                                SourceLocation LParenLoc,
693                                                TypeTy *Ty,
694                                                SourceLocation RParenLoc) {
695     return 0;
696   }
697   
698   virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
699                                                  SourceLocation AtLoc,
700                                                  SourceLocation SelLoc,
701                                                  SourceLocation LParenLoc,
702                                                  SourceLocation RParenLoc) {
703     return 0;
704   }
705   
706   virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolId,
707                                                  SourceLocation AtLoc,
708                                                  SourceLocation ProtoLoc,
709                                                  SourceLocation LParenLoc,
710                                                  SourceLocation RParenLoc) {
711     return 0;
712   } 
713 };
714
715 /// MinimalAction - Minimal actions are used by light-weight clients of the
716 /// parser that do not need name resolution or significant semantic analysis to
717 /// be performed.  The actions implemented here are in the form of unresolved
718 /// identifiers.  By using a simpler interface than the SemanticAction class,
719 /// the parser doesn't have to build complex data structures and thus runs more
720 /// quickly.
721 class MinimalAction : public Action {
722   /// Translation Unit Scope - useful to Objective-C actions that need
723   /// to lookup file scope declarations in the "ordinary" C decl namespace.
724   /// For example, user-defined classes, built-in "id" type, etc.
725   Scope *TUScope;
726   IdentifierTable &Idents;
727 public:
728   MinimalAction(IdentifierTable &IT) : Idents(IT) {}
729   
730   /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to
731   /// determine whether the name is a typedef or not in this scope.
732   virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;
733   
734   /// ActOnDeclarator - If this is a typedef declarator, we modify the
735   /// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
736   /// popped.
737   virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
738   
739   /// ActOnPopScope - When a scope is popped, if any typedefs are now 
740   /// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field.
741   virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
742   virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
743   
744   virtual DeclTy *ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
745                                                IdentifierInfo **IdentList,
746                                                unsigned NumElts);
747   
748   virtual DeclTy *ActOnStartClassInterface(SourceLocation interLoc,
749                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
750                     IdentifierInfo *SuperName, SourceLocation SuperLoc,
751                     IdentifierInfo **ProtocolNames, unsigned NumProtocols,
752                     SourceLocation EndProtoLoc, AttributeList *AttrList);
753 };
754
755 }  // end namespace clang
756
757 #endif