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