PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/test/lib/regular_expression/aux_substitute_01.e

http://github.com/tybor/Liberty
Specman e | 63 lines | 34 code | 6 blank | 23 comment | 0 complexity | 2bceefbc8a0ac97486ad0e582412f0b9 MD5 | raw file
 1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
 2-- See the Copyright notice at the end of this file.
 3--
 4class AUX_SUBSTITUTE_01
 5   --
 6   -- Regular expression matcher for expression "(a)(a)"
 7
 8inherit
 9   REGULAR_EXPRESSION
10      redefine default_create
11      end
12
13feature {ANY}
14   default_create
15      do
16         pattern := once "aa"
17         create substrings_first_indexes.make(0, 2)
18         create substrings_last_indexes.make(0, 2)
19         substitution_pattern_ready := False
20      end
21
22   match_from (text: STRING; first_index: INTEGER): BOOLEAN
23      local
24         pos, i: INTEGER
25      do
26         pos := text.substring_index(pattern, first_index)
27         Result := pos /= 0
28         substrings_first_indexes.put(pos, 0)
29         substrings_last_indexes.put(pos + pattern.count - 1, 0)
30         from
31            i := pattern.count.min(9)
32         until
33            i < 1
34         loop
35            substrings_first_indexes.put(pos + i - 1, i)
36            substrings_last_indexes.put(pos + i - 1, i)
37            i := i - 1
38         end
39      end
40
41   can_match: BOOLEAN True
42
43   pattern: STRING
44
45end -- class AUX_SUBSTITUTE_01
46--
47-- ------------------------------------------------------------------------------------------------------------------------------
48-- Copyright notice below. Please read.
49--
50-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
51-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
52-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
53-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
54-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
55-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
56--
57-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
58-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
59--
60-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
61--
62-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
63-- ------------------------------------------------------------------------------------------------------------------------------