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

/tutorial/backtracking/expand_expression/abstract/expression_item.e

http://github.com/tybor/Liberty
Specman e | 93 lines | 59 code | 13 blank | 21 comment | 0 complexity | 27c1c410088803874b495ab808c4975c MD5 | raw file
 1-- See the Copyright notice at the end of this file.
 2--
 3class EXPRESSION_ITEM
 4	-- very raw class to make the expresion tree
 5	-- not any safety check is done, be careful
 6	-- no comment
 7
 8inherit
 9	EXPRESSION_ITEM_GLOBALS
10		redefine out
11		end
12
13creation {ANY}
14	make_or, make_and, make_value, make_failure, make_success, make_empty
15
16feature {ANY}
17	first, second: like Current
18
19	type: INTEGER
20
21	value: STRING
22
23	make_failure is
24		do
25			type := Failure_item
26		end
27
28	make_success is
29		do
30			type := Success_item
31		end
32
33	make_empty is
34		do
35			type := Empty_item
36		end
37
38	make_value (val: STRING) is
39		do
40			type := Value_item
41			value := val
42		end
43
44	make_or (f, s: like Current) is
45		do
46			type := Or_item
47			first := f
48			second := s
49		end
50
51	make_and (f, s: like Current) is
52		do
53			type := And_item
54			first := f
55			second := s
56		end
57
58	out: STRING is
59		do
60			inspect
61				type
62			when Empty_item then
63				Result := to_pointer.out + ": empty"
64			when Failure_item then
65				Result := to_pointer.out + ": failure"
66			when Success_item then
67				Result := to_pointer.out + ": success"
68			when Value_item then
69				Result := to_pointer.out + ": value=" + value
70			when And_item then
71				Result := to_pointer.out + ": " + first.to_pointer.out + " and " + second.to_pointer.out
72			when Or_item then
73				Result := to_pointer.out + ": " + first.to_pointer.out + " or " + second.to_pointer.out
74			end
75		end
76
77end -- class EXPRESSION_ITEM
78--
79-- ------------------------------------------------------------------------------------------------------------------------------
80-- Copyright notice below. Please read.
81--
82-- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be
83-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
84-- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added.
85-- You are allowed to redistribute it and sell it, alone or as a part of another product.
86--
87-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
88-- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
89--
90-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
91--
92-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
93-- ------------------------------------------------------------------------------------------------------------------------------