PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/syntax/tree/liberty_ast_creation.e

http://github.com/tybor/Liberty
Specman e | 90 lines | 64 code | 12 blank | 14 comment | 4 complexity | 74b519246b8cac46740b1e0a395ea870 MD5 | raw file
 1-- This file is part of Liberty Eiffel.
 2--
 3-- Liberty Eiffel is free software: you can redistribute it and/or modify
 4-- it under the terms of the GNU General Public License as published by
 5-- the Free Software Foundation, version 3 of the License.
 6--
 7-- Liberty Eiffel is distributed in the hope that it will be useful,
 8-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10-- GNU General Public License for more details.
11--
12-- You should have received a copy of the GNU General Public License
13-- along with Liberty Eiffel.  If not, see <http://www.gnu.org/licenses/>.
14--
15class LIBERTY_AST_CREATION
16
17inherit
18   LIBERTY_AST_NON_TERMINAL_NODE
19
20create {LIBERTY_NODE_FACTORY}
21   make
22
23feature {LIBERTY_AST_HANDLER}
24   has_type_definition: BOOLEAN is
25      do
26         Result := nodes.item(1).name.is_equal(once "KW {")
27      end
28
29   has_creation_feature_call: BOOLEAN is
30      do
31         if has_type_definition then
32            Result := count = 8
33         else
34            Result := count = 5
35         end
36      end
37
38   writable: LIBERTY_AST_WRITABLE is
39      do
40         if has_type_definition then
41            Result ::= nodes.item(4)
42         else
43            Result ::= nodes.item(1)
44         end
45      end
46
47   type_definition: LIBERTY_AST_TYPE_DEFINITION is
48      require
49         has_type_definition
50      do
51         Result ::= nodes.item(2)
52      end
53
54   creation_feature_name: LIBERTY_AST_ENTITY_NAME is
55      require
56         has_creation_feature_call
57      do
58         if has_type_definition then
59            Result ::= nodes.item(6)
60         else
61            Result ::= nodes.item(3)
62         end
63      end
64
65   creation_feature_actuals: LIBERTY_AST_ACTUALS is
66      require
67         has_creation_feature_call
68      do
69         if has_type_definition then
70            Result ::= nodes.item(7)
71         else
72            Result ::= nodes.item(4)
73         end
74      end
75
76feature {ANY}
77   count: INTEGER is
78      do
79         Result := nodes.count
80      end
81
82   name: STRING is "Creation"
83
84feature {}
85   possible_counts: SET[INTEGER] is
86      once
87         Result := {AVL_SET[INTEGER] << 2, 5, 8 >> }
88      end
89
90end