/tutorial/backtracking/logigram/description.e
Specman e | 131 lines | 93 code | 20 blank | 18 comment | 1 complexity | e0cc68beb4131f32df49340b1b703354 MD5 | raw file
1-- See the Copyright notice at the end of this file. 2-- 3class DESCRIPTION 4 5creation {ANY} 6 make 7 8feature {ANY} 9 group: GROUP 10 11 group_array: FAST_ARRAY[like group] 12 13 group_dictionary: AVL_DICTIONARY[like group, STRING] 14 15 constraints: CONSTRAINT_SET 16 17 make is 18 do 19 create group_array.with_capacity(10) 20 create group_dictionary.make 21 create constraints.make 22 end 23 24 add_group_atomic (name: STRING) is 25 do 26 create group.make_atomic(name, 1 + group_array.upper) 27 add_group 28 end 29 30 add_group_numeric (name: STRING) is 31 do 32 create group.make_numeric(name, 1 + group_array.upper) 33 add_group 34 end 35 36 add_group_ordered (name: STRING) is 37 do 38 create group.make_ordered(name, 1 + group_array.upper) 39 add_group 40 end 41 42 get_item (group_name, item_name: STRING): ITEM_ITEM is 43 do 44 goto_name(group_name) 45 group.goto_name(item_name) 46 Result := group.item 47 end 48 49 get_group (group_name: STRING): GROUP is 50 do 51 goto_name(group_name) 52 Result := group 53 end 54 55 goto_name (group_name: STRING) is 56 do 57 group := group_dictionary.at(group_name) 58 end 59 60 goto_index (group_index: INTEGER) is 61 do 62 group := group_array.item(group_index) 63 end 64 65 group_count: INTEGER is 66 do 67 Result := group_array.count 68 end 69 70 is_valid: BOOLEAN is 71 local 72 i: INTEGER 73 do 74 if not group_array.is_empty then 75 from 76 Result := True 77 i := group_array.lower + 1 78 until 79 i > group_array.upper 80 loop 81 Result := group_array.first.item_count = group_array.item(i).item_count 82 i := i + 1 83 end 84 end 85 end 86 87 dimension: INTEGER is 88 require 89 is_valid 90 do 91 Result := group_array.first.item_count 92 end 93 94 get_var (group_name, var_name: STRING): ITEM_VAR is 95 do 96 goto_name(group_name) 97 group.get_var(var_name) 98 Result := group.var 99 end 100 101 get_anonymous_var (group_name: STRING): ITEM_VAR is 102 do 103 goto_name(group_name) 104 group.get_anonymous_var 105 Result := group.var 106 end 107 108feature {} 109 add_group is 110 do 111 group_array.add_last(group) 112 group_dictionary.add(group, group.name) 113 end 114 115end -- class DESCRIPTION 116-- 117-- ------------------------------------------------------------------------------------------------------------------------------ 118-- Copyright notice below. Please read. 119-- 120-- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be 121-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 122-- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added. 123-- You are allowed to redistribute it and sell it, alone or as a part of another product. 124-- 125-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 126-- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 127-- 128-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 129-- 130-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 131-- ------------------------------------------------------------------------------------------------------------------------------