Synopsis - Synopsis/PTree/Visitor.hh

File: Synopsis/PTree/Visitor.hh

      1//
      2// Copyright (C) 2004 Stefan Seefeld
      3// All rights reserved.
      4// Licensed to the public under the terms of the GNU LGPL (>= 2),
      5// see the file COPYING for details.
      6//
      7#ifndef Synopsis_PTree_Visitor_hh_
      8#define Synopsis_PTree_Visitor_hh_
      9
     10#include <Synopsis/PTree/NodesFwd.hh>
     11
     12namespace Synopsis
     13{
     14namespace PTree
     15{
     16
     17//. The Visitor class is used to dynamically resolve
     18//. type information about a given Node.
     19//. The default implementation does nothing, so you
     20//. only need to implement the methods you actually need.
     21//. Any types for which no corresponding 'visit' methods
     22//. exist will be caught by the 'visit' of the closest parent.
     23class Visitor
     24{
     25public:
     26  virtual ~Visitor() {}
     27  virtual void visit(Node *) {}
     28  virtual void visit(Atom *) {}
     29  virtual void visit(List *) {}
     30  // atoms...
     31  virtual void visit(Literal *);
     32  virtual void visit(CommentedAtom *);
     33  virtual void visit(DupAtom *);
     34  virtual void visit(Identifier *);
     35  virtual void visit(Keyword *);
     36  virtual void visit(Kwd::Auto *);
     37  virtual void visit(Kwd::Break *);
     38  virtual void visit(Kwd::Bool *);
     39  virtual void visit(Kwd::Case *);
     40  virtual void visit(Kwd::Catch *);
     41  virtual void visit(Kwd::Char *);
     42  virtual void visit(Kwd::Class *);
     43  virtual void visit(Kwd::Continue *);
     44  virtual void visit(Kwd::Const *);
     45  virtual void visit(Kwd::Default *);
     46  virtual void visit(Kwd::Delete *);
     47  virtual void visit(Kwd::Double *);
     48  virtual void visit(Kwd::Do *);
     49  virtual void visit(Kwd::Else *);
     50  virtual void visit(Kwd::Extern *);
     51  virtual void visit(Kwd::Float *);
     52  virtual void visit(Kwd::For *);
     53  virtual void visit(Kwd::Friend *);
     54  virtual void visit(Kwd::Goto *);
     55  virtual void visit(Kwd::Inline *);
     56  virtual void visit(Kwd::If *);
     57  virtual void visit(Kwd::Int *);
     58  virtual void visit(Kwd::Long *);
     59  virtual void visit(Kwd::Mutable *);
     60  virtual void visit(Kwd::Namespace *);
     61  virtual void visit(Kwd::New *);
     62  virtual void visit(Kwd::Operator *);
     63  virtual void visit(Kwd::Private *);
     64  virtual void visit(Kwd::Protected *);
     65  virtual void visit(Kwd::Public *);
     66  virtual void visit(Kwd::Register *);
     67  virtual void visit(Kwd::Return *);
     68  virtual void visit(Kwd::Short *);
     69  virtual void visit(Kwd::Signed *);
     70  virtual void visit(Kwd::Static *);
     71  virtual void visit(Kwd::Struct *);
     72  virtual void visit(Kwd::Switch *);
     73  virtual void visit(Kwd::Template *);
     74  virtual void visit(Kwd::This *);
     75  virtual void visit(Kwd::Throw *);
     76  virtual void visit(Kwd::Try *);
     77  virtual void visit(Kwd::Typedef *);
     78  virtual void visit(Kwd::Typename *);
     79  virtual void visit(Kwd::Union *);
     80  virtual void visit(Kwd::Unsigned *);
     81  virtual void visit(Kwd::Using *);
     82  virtual void visit(Kwd::Virtual *);
     83  virtual void visit(Kwd::Void *);
     84  virtual void visit(Kwd::Volatile *);
     85  virtual void visit(Kwd::WChar *);
     86  virtual void visit(Kwd::While *);
     87  //. [ { [ <statement>* ] } ]
     88  virtual void visit(Brace *);
     89  //. [ { [ <statement>* ] } ]
     90  virtual void visit(Block *);
     91  virtual void visit(ClassBody *);
     92  virtual void visit(Typedef *);
     93  //. [ template < [types] > [decl] ]
     94  virtual void visit(TemplateDecl *);
     95  virtual void visit(TemplateInstantiation *);
     96  virtual void visit(ExternTemplate *);
     97  virtual void visit(MetaclassDecl *);
     98  //. [ extern ["C++"] [{ body }] ]
     99  virtual void visit(LinkageSpec *);
    100  //. [ namespace <identifier> [{ body }] ]
    101  virtual void visit(NamespaceSpec *);
    102  //. [ using namespace Foo ; ]
    103  virtual void visit(UsingDirective *);
    104  //. One of:
    105  //.
    106  //. - Variables: [ [modifiers] name [declarators] ; ]
    107  //. - Function: prototype: [ [modifiers] name [declarators] ; ]
    108  //. - Typedef: ?
    109  //. - Class definition: [ [modifiers] [class foo ...] [declarators]? ; ]
    110  virtual void visit(Declaration *);
    111  //. [ namespace Foo = Bar ; ]
    112  virtual void visit(NamespaceAlias *);
    113  //. Function definition: [ [modifiers] name declarator [ { ... } ] ]
    114  virtual void visit(FunctionDefinition *);
    115  //. One of:
    116  //.
    117  //. - [ decl-specifier-seq ]
    118  //. - [ decl-specifier-seq declarator ]
    119  //. - [ decl-specifier-seq declarator = assignment-expression ]
    120  //. - [ decl-specifier-seq abstract-declarator ]
    121  //. - [ decl-specifier-seq abstract-declarator = assignment-expression ]
    122  //. - [ decl-specifier-seq = assignment-expression ]
    123  virtual void visit(ParameterDeclaration *);
    124  //. [ using Foo `::` x ; ]
    125  virtual void visit(UsingDeclaration *);
    126  //. [ [ declarator { = <expr> } ] , ... ]
    127  virtual void visit(Declarator *);
    128  virtual void visit(Name *);
    129  //. [ [type] ( [expr] ) ]
    130  virtual void visit(FstyleCastExpr *);
    131  virtual void visit(ClassSpec *);
    132  //. [ enum [name] [{ [name [= value] ]* }] ]
    133  virtual void visit(EnumSpec *);
    134  //. One of:
    135  //.
    136  //. - [typename]
    137  //. - [typename identifier]
    138  //. - [typename identifier = type-id]
    139  virtual void visit(TypeParameter *);
    140  virtual void visit(AccessSpec *);
    141  virtual void visit(AccessDecl *);
    142  virtual void visit(UserAccessSpec *);
    143  //. [ if ( expr ) statement (else statement)? ]
    144  virtual void visit(IfStatement *);
    145  //. [ switch ( expr ) statement ]
    146  virtual void visit(SwitchStatement *);
    147  //. [ while ( expr ) statement ]
    148  virtual void visit(WhileStatement *);
    149  //. [ do [{ ... }] while ( [...] ) ; ]
    150  virtual void visit(DoStatement *);
    151  //. [ for ( stmt expr ; expr ) statement ]
    152  virtual void visit(ForStatement *);
    153  //. [ try [{}] [catch ( arg ) [{}] ]* ]
    154  virtual void visit(TryStatement *);
    155  //. [ break ; ]
    156  virtual void visit(BreakStatement *);
    157  virtual void visit(ContinueStatement *);
    158  virtual void visit(ReturnStatement *);
    159  virtual void visit(GotoStatement *);
    160  //. [ case expr : [expr] ]
    161  virtual void visit(CaseStatement *);
    162  //. [ default : [expr] ]
    163  virtual void visit(DefaultStatement *);
    164  virtual void visit(LabelStatement *);
    165  virtual void visit(ExprStatement *);
    166  //. [ expr (, expr)* ]
    167  virtual void visit(Expression *);
    168  //. [left = right]
    169  virtual void visit(AssignExpr *);
    170  virtual void visit(CondExpr *);
    171  //. [left op right]
    172  virtual void visit(InfixExpr *);
    173  virtual void visit(PmExpr *);
    174  //. ( type-expr ) expr   ..type-expr is type encoded
    175  virtual void visit(CastExpr *);
    176  //. [op expr]
    177  virtual void visit(UnaryExpr *);
    178  //. [ throw [expr] ]
    179  virtual void visit(ThrowExpr *);
    180  //. [ sizeof ( [type [???] ] ) ]
    181  virtual void visit(SizeofExpr *);
    182  virtual void visit(OffsetofExpr *);
    183  virtual void visit(TypeidExpr *);
    184  virtual void visit(TypeofExpr *);
    185  virtual void visit(NewExpr *);
    186  //. [ delete [expr] ]
    187  virtual void visit(DeleteExpr *);
    188  //. <postfix> \[ <expr> \]
    189  virtual void visit(ArrayExpr *);
    190  //. [ postfix ( args ) ]
    191  virtual void visit(FuncallExpr *);
    192  //. [ expr ++ ]
    193  virtual void visit(PostfixExpr *);
    194  //. [ postfix . name ]
    195  virtual void visit(DotMemberExpr *);
    196  //. [ postfix -> name ]
    197  virtual void visit(ArrowMemberExpr *);
    198  //. [ ( expr ) ]
    199  virtual void visit(ParenExpr *);
    200};
    201
    202}
    203}
    204
    205#endif

Generated on Thu Apr 16 16:28:03 2009 by
synopsis (version devel)