BaseTraverse.str 4.41 KB
Newer Older
1
/*
2
3
4
 * BaseTraverse.str:
 * this file is a part of CxxGrammar from the Transformers project.
 * Copyright (C) 2003, 2004  EPITA Research and Development Laboratory.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
david_v's avatar
david_v committed
21
22
23
24
25
26
27
28
module BaseTraverse

imports

  lib

imports

29
  AsFix
30
  Cxx
david_v's avatar
david_v committed
31
32
33
34
35
36
37
38
39
  BaseTraverseCandidate
  Identifier
  LocalOrGlobal
  Lookup
  NestedNameSpecifier
  Options

rules

40
41
42
43
  BaseTraverse-1 : |BaseSpecifier[ Dummy0-opt la1 NestedNameSpecifier la2 ClassName ]| ->
                   |BaseSpecifier[ Dummy0-opt' la1 NestedNameSpecifier' la2 ClassName' ]|
                   where < BaseTraverse-core > [Dummy0-opt, Some (NestedNameSpecifier), ClassName] =>
                         [Dummy0-opt', Some (NestedNameSpecifier'), ClassName']
david_v's avatar
david_v committed
44

45
46
47
48
  BaseTraverse-1' : |BaseSpecifier[ Dummy0-opt la ClassName ]| ->
                    |BaseSpecifier[ Dummy0-opt' la ClassName' ]|
                    where < BaseTraverse-core > [Dummy0-opt, None, ClassName]
                            => [Dummy0-opt', None, ClassName']
david_v's avatar
david_v committed
49

50
51
52
53
  BaseTraverse-2 : |BaseSpecifier[ virtual la1 AccessSpecifier-opt la2 Dummy0-opt la3 NestedNameSpecifier la4 ClassName ]|
                   -> |BaseSpecifier[ virtual la1 AccessSpecifier-opt la2 Dummy0-opt' la3 NestedNameSpecifier' la4 ClassName' ]|
                   where < BaseTraverse-core > [Dummy0-opt, Some (NestedNameSpecifier), ClassName]
                           => [Dummy0-opt', Some (NestedNameSpecifier'), ClassName']
david_v's avatar
david_v committed
54

55
56
57
58
  BaseTraverse-2 : |BaseSpecifier[ AccessSpecifier la1 Dummy7-opt la2 Dummy0-opt la3 NestedNameSpecifier la4 ClassName ]|
                   -> |BaseSpecifier[ AccessSpecifier la1 Dummy7-opt la2 Dummy0-opt' la3 NestedNameSpecifier' la4 ClassName' ]|
                   where < BaseTraverse-core > [Dummy0-opt, Some (NestedNameSpecifier), ClassName]
                           => [Dummy0-opt', Some (NestedNameSpecifier'), ClassName']
david_v's avatar
david_v committed
59

60
61
62
63
  BaseTraverse-2' : |BaseSpecifier[ virtual la1 AccessSpecifier-opt la2 Dummy0-opt la3 ClassName ]|
                   -> |BaseSpecifier[ virtual la1 AccessSpecifier-opt la2 Dummy0-opt' la3 ClassName' ]|
                   where < BaseTraverse-core > [Dummy0-opt, None, ClassName]
                           => [Dummy0-opt', None, ClassName']
david_v's avatar
david_v committed
64

65
66
67
68
  BaseTraverse-2' : |BaseSpecifier[ AccessSpecifier la1 Dummy7-opt la2 Dummy0-opt la3 ClassName ]|
                   -> |BaseSpecifier[ AccessSpecifier la1 Dummy7-opt la2 Dummy0-opt' la3 ClassName' ]|
                   where < BaseTraverse-core > [Dummy0-opt, None, ClassName]
                           => [Dummy0-opt', None, ClassName']
david_v's avatar
david_v committed
69
70
71

  BaseTraverse-core : [global,
                       nested,
72
                       name@|ClassName[ ID ]|] ->
david_v's avatar
david_v committed
73
74
75
                      [global',
                       nested',
                       name]
76
                      where < identifier > ID => ID'
david_v's avatar
david_v committed
77
78
79
                          ; < rewrite (!"$namespace") > "$value" => local
                          ; < local-or-global > global => global'
                          ; < opt-apply (nested-name-specifier) > nested => nested'
80
                          ; < lookup' > ID'
david_v's avatar
david_v committed
81
82
                          ; < rewrite (!"$namespace") > "$value" => base
                          ; < ?list-key (xs); !xs > base => base'
83
                          ; < conc; ?x; !list-key (x) > (base', [string-key (ID')]) => inherit
david_v's avatar
david_v committed
84
85
                          ; < rewrite (!local) <+ (!Nil) > "$inherit" => inherits
                          ; < conc > (inherits, [inherit]) => inherits'
86
                          ; < my-assert (!local) > ("$inherit", inherits')
david_v's avatar
david_v committed
87
88
89

strategies

90
  base-traverse-stop(s) = base-traverse-candidate
david_v's avatar
david_v committed
91
92
93
94
95

  base-traverse = scope (!"$namespace",
                         (base-traverse-candidate;
                          (BaseTraverse-1 <+ BaseTraverse-1' <+
                           BaseTraverse-2 <+ BaseTraverse-2')))