summaryrefslogtreecommitdiff
path: root/trunk/CIAO/CCF/CCF/CIDL/Parser.hpp
blob: 719f97f184d3c293b270d7803c6ca6158e51e14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// file      : CCF/CIDL/Parser.hpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#ifndef CCF_CIDL_PARSER_HPP
#define CCF_CIDL_PARSER_HPP

#include "CCF/CompilerElements/Context.hpp"

#include "CCF/IDL3/Parser.hpp"

#include "CCF/CIDL/LexicalAnalyzer.hpp"
#include "CCF/CIDL/SemanticAction.hpp"

namespace CCF
{
  namespace CIDL
  {
    using IDL3::ActionExecutor;
    using IDL3::NoArgAction;
    using IDL3::OneArgAction;
    using IDL3::TwoArgAction;

    class Parser : public virtual IDL3::Parser
    {
    protected:
      LexicalAnalyzer const& lexer_;
      SemanticAction::Factory& actions_;

      //
      // Primitives (alphabetic order).
      //

      KeywordParser COMPOSITION;
      KeywordParser ENTITY;
      KeywordParser EXECUTOR;
      KeywordParser IMPLEMENTS;
      KeywordParser PROCESS;
      KeywordParser SERVICE;
      KeywordParser SESSION;

      //
      // Language
      //

      Rule extension;

      // Composition
      Rule composition_decl;
      Rule composition_category;

      // Home executor
      Rule home_executor_decl;
      Rule home_executor_home_impl_decl;
      Rule home_executor_executor_decl;

    public:
      Parser (CompilerElements::Context& context,
              Diagnostic::Stream& dout,
              LexicalAnalyzer const& l,
              SemanticAction::Factory& f);

    protected:
      void
      act_composition_begin_core (Iterator begin, Iterator) const
      {
        SemanticAction::Composition::Category::Value c;

        if((*begin)->lexeme () == "entity")
        {
          c = SemanticAction::Composition::Category::entity;
        }
        else if ((*begin)->lexeme () == "process")
        {
          c = SemanticAction::Composition::Category::process;
        }
        else if ((*begin)->lexeme () == "service")
        {
          c = SemanticAction::Composition::Category::service;
        }
        else
        {
          c = SemanticAction::Composition::Category::session;
        }

        begin++;

        actions_.composition ().begin (
          ReferenceCounting::strict_cast<SimpleIdentifier> (*begin), c);
      }

      // Composition
      //
      ActionExecutor<Parser>
      act_composition_begin;

      ScopeAction
      act_composition_open_scope;

      ScopeAction
      act_composition_close_scope;

      NoArgAction<SemanticAction::Composition>
      act_composition_end;

      // Home Executor
      //
      OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor>
      act_home_executor_begin;

      OneArgAction<IdentifierPtr, SemanticAction::HomeExecutor>
      act_home_executor_implements;

      OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor>
      act_home_executor_manages;

      NoArgAction<SemanticAction::HomeExecutor>
      act_home_executor_end;
    };
  }
}

#endif  // CCF_CIDL_PARSER_HPP