/src/lib/regular_expression/low_level/backtracking_regular_expression_pattern.e

http://github.com/tybor/Liberty · Specman e · 61 lines · 25 code · 6 blank · 30 comment · 0 complexity · b6e56c0f10049b515977a179aa24680f MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. expanded class BACKTRACKING_REGULAR_EXPRESSION_PATTERN
  5. --
  6. -- Class for backtracking (compiled) regular expressions pattern.
  7. --
  8. feature {ANY}
  9. group_count: INTEGER
  10. -- The count of groups of the regular expression.
  11. is_valid: BOOLEAN
  12. -- Is the current pattern valid?
  13. do
  14. Result := root /= Void
  15. end
  16. feature {BACKTRACKING_REGULAR_EXPRESSION}
  17. root: BACKTRACKING_NODE
  18. -- The root item.
  19. substrings_names: BIJECTIVE_DICTIONARY[INTEGER, FIXED_STRING]
  20. feature {BACKTRACKING_REGULAR_EXPRESSION_BUILDER}
  21. make (top: like root; grpcnt: INTEGER; subnames: like substrings_names)
  22. -- Initializing
  23. require
  24. top_not_void: top /= Void
  25. valid_group_count: grpcnt >= 0
  26. valid_subnames: subnames.for_all(agent (c, i: INTEGER; s: FIXED_STRING): BOOLEAN do Result := i.in_range(0, c) and then s /= Void end (grpcnt, ?, ?))
  27. do
  28. root := top
  29. group_count := grpcnt
  30. substrings_names := subnames
  31. ensure
  32. definition: root = top and group_count = grpcnt
  33. valid: is_valid
  34. end
  35. end -- class BACKTRACKING_REGULAR_EXPRESSION_PATTERN
  36. --
  37. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  38. --
  39. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  40. -- of this software and associated documentation files (the "Software"), to deal
  41. -- in the Software without restriction, including without limitation the rights
  42. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43. -- copies of the Software, and to permit persons to whom the Software is
  44. -- furnished to do so, subject to the following conditions:
  45. --
  46. -- The above copyright notice and this permission notice shall be included in
  47. -- all copies or substantial portions of the Software.
  48. --
  49. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  52. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  54. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  55. -- THE SOFTWARE.