PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/tools/syntax/tree/liberty_ast_type_definition.e

http://github.com/tybor/Liberty
Specman e | 116 lines | 85 code | 17 blank | 14 comment | 1 complexity | 777581ecd13f13113f301f867aa12ea3 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_TYPE_DEFINITION
 16
 17inherit
 18   LIBERTY_AST_NON_TERMINAL_NODE
 19
 20create {LIBERTY_NODE_FACTORY}
 21   make
 22
 23feature {LIBERTY_AST_HANDLER}
 24   is_class_type: BOOLEAN is
 25      do
 26         Result := nodes.last.name.is_equal(once "Effective_Type_Parameters")
 27      end
 28
 29   is_separate: BOOLEAN is
 30      do
 31         Result := nodes.first.name.is_equal(once "KW separate")
 32      end
 33
 34   type_name: LIBERTY_AST_CLASS_NAME is
 35      require
 36         is_class_type
 37      do
 38         if is_separate then
 39            Result ::= nodes.item(1)
 40         else
 41            Result ::= nodes.item(0)
 42         end
 43      end
 44
 45   type_parameters: LIBERTY_AST_EFFECTIVE_TYPE_PARAMETERS is
 46      require
 47         is_class_type
 48      do
 49         Result ::= nodes.last
 50      end
 51
 52   is_anchor: BOOLEAN is
 53      do
 54         Result := nodes.first.name.is_equal(once "KW like")
 55      end
 56
 57   is_like_result: BOOLEAN is
 58      do
 59         Result := is_anchor and then nodes.item(1).name.is_equal(once "KW Result")
 60      ensure
 61         Result implies is_anchor
 62      end
 63
 64   is_like_current: BOOLEAN is
 65      do
 66         Result := is_anchor and then nodes.item(1).name.is_equal(once "KW Current")
 67      ensure
 68         Result implies is_anchor
 69      end
 70
 71   is_like_entity: BOOLEAN is
 72      do
 73         Result := is_anchor and then nodes.item(1).name.is_equal(once "KW entity name")
 74      ensure
 75         Result implies is_anchor
 76      end
 77
 78   entity_anchor: LIBERTY_AST_ENTITY_NAME is
 79      require
 80         is_like_entity
 81      do
 82         Result ::= nodes.item(1)
 83      end
 84
 85   anchor_remainder: LIBERTY_AST_R10 is
 86      require
 87         is_anchor
 88      do
 89         Result ::= nodes.item(2)
 90      end
 91
 92   anchor_index: INTEGER is
 93      require
 94         is_anchor
 95      local
 96         anchor: EIFFEL_TERMINAL_NODE
 97      do
 98         anchor ::= nodes.first
 99         Result := anchor.image.index
100      end
101
102feature {ANY}
103   count: INTEGER is
104      do
105         Result := nodes.count
106      end
107
108   name: STRING is "Type_Definition"
109
110feature {}
111   possible_counts: SET[INTEGER] is
112      once
113         Result := {AVL_SET[INTEGER] << 2, 3 >> }
114      end
115
116end