/src/lib/regular_expression/internal/regular_expression_items/regular_expression_item_range.e

http://github.com/tybor/Liberty · Specman e · 57 lines · 24 code · 6 blank · 27 comment · 1 complexity · 79252d8aaa99f0a2732ca9d65a7c395e MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class REGULAR_EXPRESSION_ITEM_RANGE
  5. --
  6. -- accept a character in a range
  7. --
  8. inherit
  9. REGULAR_EXPRESSION_ITEM
  10. create {ANY}
  11. make
  12. feature {ANY}
  13. lower, upper: CHARACTER
  14. -- lower and upper range
  15. make (low, up: CHARACTER)
  16. do
  17. lower := low
  18. upper := up
  19. ensure
  20. definition: lower = low and upper = up
  21. end
  22. explore (matcher: BACKTRACKING_REGULAR_EXPRESSION)
  23. do
  24. if matcher.valid_last_character and then matcher.last_character.in_range(lower, upper) then
  25. matcher.advance
  26. matcher.continue
  27. else
  28. matcher.backtrack
  29. end
  30. end
  31. end -- class REGULAR_EXPRESSION_ITEM_RANGE
  32. --
  33. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  34. --
  35. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  36. -- of this software and associated documentation files (the "Software"), to deal
  37. -- in the Software without restriction, including without limitation the rights
  38. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  39. -- copies of the Software, and to permit persons to whom the Software is
  40. -- furnished to do so, subject to the following conditions:
  41. --
  42. -- The above copyright notice and this permission notice shall be included in
  43. -- all copies or substantial portions of the Software.
  44. --
  45. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  48. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  49. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  51. -- THE SOFTWARE.